From 8f04339d16e9b9a92f67e8e61d6de91e0db527ca Mon Sep 17 00:00:00 2001 From: Johan Brichau Date: Thu, 2 Jan 2025 14:22:51 +0100 Subject: [PATCH] Expanded the testcase for secureHashFor: to also cover (any) bytearray as argument since this method is used in Seaside with any String or ByteArray --- .../instance/testSecureHashFor.st | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/repository/Grease-Tests-Core.package/GRPlatformTest.class/instance/testSecureHashFor.st b/repository/Grease-Tests-Core.package/GRPlatformTest.class/instance/testSecureHashFor.st index f6521ee3..5a6dfb9f 100644 --- a/repository/Grease-Tests-Core.package/GRPlatformTest.class/instance/testSecureHashFor.st +++ b/repository/Grease-Tests-Core.package/GRPlatformTest.class/instance/testSecureHashFor.st @@ -1,9 +1,19 @@ tests testSecureHashFor - "Make sure the platform class provides a #secureHashFor: method. The method is called by Seaside when hashing passwords. The Squeak implementation returns a SHA-1 hash but another equivalent hash method could also be used." + "Make sure the platform class provides a #secureHashFor: method. The method is called by Seaside when hashing passwords. + The Pharo implementation returns a SHA-1 hash but another equivalent hash method could also be used." - | a b | + | a b c d invalidUtf8 e f | a := self platform secureHashFor: 'foobar'. b := self platform secureHashFor: 'foobar'. + self assert: a equals: b. + + c := self platform secureHashFor: #[102 111 111 98 97 114]. + d := self platform secureHashFor: #[102 111 111 98 97 114]. + self assert: c equals: d. - self assert: (a = b) \ No newline at end of file + "The following ensures any byte array can be used (and not only the onces containing valid utf8)" + invalidUtf8 := #[160 161]. + e := self platform secureHashFor: invalidUtf8. + f := self platform secureHashFor: invalidUtf8. + self assert: e equals: f \ No newline at end of file