Skip to content

Commit

Permalink
Merge pull request #182 from SeasideSt/secureHash-test
Browse files Browse the repository at this point in the history
Expanded the testcase for GRPlatform>>secureHashFor:
  • Loading branch information
jbrichau authored Jan 2, 2025
2 parents 5e8378a + 8f04339 commit 38b9f56
Showing 1 changed file with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -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)
"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

0 comments on commit 38b9f56

Please sign in to comment.