Skip to content

Commit 8f04339

Browse files
author
Johan Brichau
committed
Expanded the testcase for secureHashFor: to also cover (any) bytearray as argument since this method is used in Seaside with any String or ByteArray
1 parent 5e8378a commit 8f04339

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
11
tests
22
testSecureHashFor
3-
"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."
3+
"Make sure the platform class provides a #secureHashFor: method. The method is called by Seaside when hashing passwords.
4+
The Pharo implementation returns a SHA-1 hash but another equivalent hash method could also be used."
45

5-
| a b |
6+
| a b c d invalidUtf8 e f |
67
a := self platform secureHashFor: 'foobar'.
78
b := self platform secureHashFor: 'foobar'.
9+
self assert: a equals: b.
10+
11+
c := self platform secureHashFor: #[102 111 111 98 97 114].
12+
d := self platform secureHashFor: #[102 111 111 98 97 114].
13+
self assert: c equals: d.
814

9-
self assert: (a = b)
15+
"The following ensures any byte array can be used (and not only the onces containing valid utf8)"
16+
invalidUtf8 := #[160 161].
17+
e := self platform secureHashFor: invalidUtf8.
18+
f := self platform secureHashFor: invalidUtf8.
19+
self assert: e equals: f

0 commit comments

Comments
 (0)