From f75febab6ed1d19b882e15379e6f2f3c65a7e3d5 Mon Sep 17 00:00:00 2001 From: Pablo Tesone Date: Mon, 18 Jun 2018 10:06:47 +0200 Subject: [PATCH 1/2] Adding deprecation of old CredentialProvider class API, and adding tests. --- .../instance/tearDown.st | 1 + .../instance/testDeprecatedAPI.st | 10 +++++++ .../instance/testDeprecatedGetterAPI.st | 3 ++ .../testStoreInNonExistingDirectory.st | 30 +++++++++++++++++++ .../instance/testStoreInNonExistingFile.st | 27 +++++++++++++++++ .../properties.json | 3 +- .../class/plaintextCredentials..st | 15 ++++++++++ .../class/plaintextCredentials.st | 16 ++++++++++ 8 files changed, 104 insertions(+), 1 deletion(-) create mode 100644 Iceberg-Tests.package/IceCredentialStoreTest.class/instance/testDeprecatedAPI.st create mode 100644 Iceberg-Tests.package/IceCredentialStoreTest.class/instance/testDeprecatedGetterAPI.st create mode 100644 Iceberg-Tests.package/IceCredentialStoreTest.class/instance/testStoreInNonExistingDirectory.st create mode 100644 Iceberg-Tests.package/IceCredentialStoreTest.class/instance/testStoreInNonExistingFile.st create mode 100644 Iceberg.package/IceCredentialsProvider.class/class/plaintextCredentials..st create mode 100644 Iceberg.package/IceCredentialsProvider.class/class/plaintextCredentials.st diff --git a/Iceberg-Tests.package/IceCredentialStoreTest.class/instance/tearDown.st b/Iceberg-Tests.package/IceCredentialStoreTest.class/instance/tearDown.st index 8a4fc52eaa..3c71815cb3 100644 --- a/Iceberg-Tests.package/IceCredentialStoreTest.class/instance/tearDown.st +++ b/Iceberg-Tests.package/IceCredentialStoreTest.class/instance/tearDown.st @@ -1,4 +1,5 @@ running tearDown file ifNotNil: [ file ensureDelete ]. + dir ifNotNil: [ dir ensureDeleteAll ]. super tearDown diff --git a/Iceberg-Tests.package/IceCredentialStoreTest.class/instance/testDeprecatedAPI.st b/Iceberg-Tests.package/IceCredentialStoreTest.class/instance/testDeprecatedAPI.st new file mode 100644 index 0000000000..f6f0d27e26 --- /dev/null +++ b/Iceberg-Tests.package/IceCredentialStoreTest.class/instance/testDeprecatedAPI.st @@ -0,0 +1,10 @@ +tests +testDeprecatedAPI + self + should: [ IceCredentialsProvider + plaintextCredentials: + (IcePlaintextCredentials new + username: 'anUser'; + password: '*****'; + yourself) ] + raise: Deprecation \ No newline at end of file diff --git a/Iceberg-Tests.package/IceCredentialStoreTest.class/instance/testDeprecatedGetterAPI.st b/Iceberg-Tests.package/IceCredentialStoreTest.class/instance/testDeprecatedGetterAPI.st new file mode 100644 index 0000000000..1a4f4ec95b --- /dev/null +++ b/Iceberg-Tests.package/IceCredentialStoreTest.class/instance/testDeprecatedGetterAPI.st @@ -0,0 +1,3 @@ +tests +testDeprecatedGetterAPI + self should: [ IceCredentialsProvider plaintextCredentials ] raise: Deprecation \ No newline at end of file diff --git a/Iceberg-Tests.package/IceCredentialStoreTest.class/instance/testStoreInNonExistingDirectory.st b/Iceberg-Tests.package/IceCredentialStoreTest.class/instance/testStoreInNonExistingDirectory.st new file mode 100644 index 0000000000..c968054ecb --- /dev/null +++ b/Iceberg-Tests.package/IceCredentialStoreTest.class/instance/testStoreInNonExistingDirectory.st @@ -0,0 +1,30 @@ +tests - store +testStoreInNonExistingDirectory + + | newStore cred otherStore | + + dir := FileLocator temp / 'nonExisting'. + file := FileLocator temp / 'nonExisting' / 'nonExisting.fuel'. + + self deny: dir exists. + + newStore := IceCredentialStore new + storeFile: file; + saveIntoStore; + yourself. + + newStore storeCredential: (IcePlaintextCredentials new + host: 'github.com'; + password: 'aasd'; + username: 'aaa'; + yourself). + + otherStore := IceCredentialStore new + storeFile: file; + loadFromStore; + yourself. + + cred := otherStore plaintextCredentialForHostname: 'github.com'. + self assert: cred isPresent. + + \ No newline at end of file diff --git a/Iceberg-Tests.package/IceCredentialStoreTest.class/instance/testStoreInNonExistingFile.st b/Iceberg-Tests.package/IceCredentialStoreTest.class/instance/testStoreInNonExistingFile.st new file mode 100644 index 0000000000..95f5402055 --- /dev/null +++ b/Iceberg-Tests.package/IceCredentialStoreTest.class/instance/testStoreInNonExistingFile.st @@ -0,0 +1,27 @@ +tests - store +testStoreInNonExistingFile + + | newStore cred otherStore | + + file := FileLocator temp / 'nonExisting.fuel'. + + newStore := IceCredentialStore new + storeFile: file; + saveIntoStore; + yourself. + + newStore storeCredential: (IcePlaintextCredentials new + host: 'github.com'; + password: 'aasd'; + username: 'aaa'; + yourself). + + otherStore := IceCredentialStore new + storeFile: file; + loadFromStore; + yourself. + + cred := otherStore plaintextCredentialForHostname: 'github.com'. + self assert: cred isPresent. + + \ No newline at end of file diff --git a/Iceberg-Tests.package/IceCredentialStoreTest.class/properties.json b/Iceberg-Tests.package/IceCredentialStoreTest.class/properties.json index 00eacde90b..6746830b91 100644 --- a/Iceberg-Tests.package/IceCredentialStoreTest.class/properties.json +++ b/Iceberg-Tests.package/IceCredentialStoreTest.class/properties.json @@ -7,7 +7,8 @@ "classvars" : [ ], "instvars" : [ "store", - "file" + "file", + "dir" ], "name" : "IceCredentialStoreTest", "type" : "normal" diff --git a/Iceberg.package/IceCredentialsProvider.class/class/plaintextCredentials..st b/Iceberg.package/IceCredentialsProvider.class/class/plaintextCredentials..st new file mode 100644 index 0000000000..6e27803eb7 --- /dev/null +++ b/Iceberg.package/IceCredentialsProvider.class/class/plaintextCredentials..st @@ -0,0 +1,15 @@ +deprecated +plaintextCredentials: anIcePlaintextCredentials + + self deprecated: ' + This API has been deprecated. The new CredentialStore hosts the keys by hostname. + The code should be changed to: + IceCredentialStore current + storeCredential: (IcePlaintextCredentials new + username: ''user''; + password: ''password''; + host: ''github.com''; + yourself). + + However this modification will break with older versions of Iceberg ( < 1.1.0 ). + ' \ No newline at end of file diff --git a/Iceberg.package/IceCredentialsProvider.class/class/plaintextCredentials.st b/Iceberg.package/IceCredentialsProvider.class/class/plaintextCredentials.st new file mode 100644 index 0000000000..b4bfebe22f --- /dev/null +++ b/Iceberg.package/IceCredentialsProvider.class/class/plaintextCredentials.st @@ -0,0 +1,16 @@ +deprecated +plaintextCredentials + + self deprecated: ' + This method have been deprecated. The new CredentialStore keeps the keys by host. There is no default key for all the hosts. + You should use: + + CredentialStore current plaintextCredentialForHostname: ''aHost.com''. + + This method will return an empty IcePlaintextCredentials for compatibility. + + + Attention: Changing any script to use this new API, will break compatibility with Iceberg version < 1.1.0 + '. + + ^ IcePlaintextCredentials new \ No newline at end of file From 51cbb52a4dd2e4f223b92f12d03d69e9b748c5c4 Mon Sep 17 00:00:00 2001 From: Guille Polito Date: Mon, 18 Jun 2018 10:55:38 +0200 Subject: [PATCH 2/2] Better comment --- .../class/plaintextCredentials..st | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Iceberg.package/IceCredentialsProvider.class/class/plaintextCredentials..st b/Iceberg.package/IceCredentialsProvider.class/class/plaintextCredentials..st index 6e27803eb7..58ee5f4a85 100644 --- a/Iceberg.package/IceCredentialsProvider.class/class/plaintextCredentials..st +++ b/Iceberg.package/IceCredentialsProvider.class/class/plaintextCredentials..st @@ -11,5 +11,6 @@ plaintextCredentials: anIcePlaintextCredentials host: ''github.com''; yourself). - However this modification will break with older versions of Iceberg ( < 1.1.0 ). - ' \ No newline at end of file + However this modification will break with older versions of Iceberg ( < 1.1.0 ). + + This method does nothing for compatibility.'