@@ -31,8 +31,8 @@ public function testConstructorThrowsOnInvalidPeriod(): void
31
31
public function testGetCodeReturnsCorrectResults (): void
32
32
{
33
33
$ tfa = new TwoFactorAuth ('Test ' );
34
- $ this ->assertEquals ('543160 ' , $ tfa ->getCode ('VMR466AB62ZBOKHE ' , 1426847216 ));
35
- $ this ->assertEquals ('538532 ' , $ tfa ->getCode ('VMR466AB62ZBOKHE ' , 0 ));
34
+ $ this ->assertSame ('543160 ' , $ tfa ->getCode ('VMR466AB62ZBOKHE ' , 1426847216 ));
35
+ $ this ->assertSame ('538532 ' , $ tfa ->getCode ('VMR466AB62ZBOKHE ' , 0 ));
36
36
}
37
37
38
38
public function testEnsureAllTimeProvidersReturnCorrectTime (): void
@@ -74,23 +74,23 @@ public function testVerifyCorrectTimeSliceIsReturned(): void
74
74
// We test with discrepancy 3 (so total of 7 codes: c-3, c-2, c-1, c, c+1, c+2, c+3
75
75
// Ensure each corresponding timeslice is returned correctly
76
76
$ this ->assertTrue ($ tfa ->verifyCode ('VMR466AB62ZBOKHE ' , '534113 ' , 3 , 1426847190 , $ timeslice1 ));
77
- $ this ->assertEquals (47561570 , $ timeslice1 );
77
+ $ this ->assertSame (47561570 , $ timeslice1 );
78
78
$ this ->assertTrue ($ tfa ->verifyCode ('VMR466AB62ZBOKHE ' , '819652 ' , 3 , 1426847190 , $ timeslice2 ));
79
- $ this ->assertEquals (47561571 , $ timeslice2 );
79
+ $ this ->assertSame (47561571 , $ timeslice2 );
80
80
$ this ->assertTrue ($ tfa ->verifyCode ('VMR466AB62ZBOKHE ' , '915954 ' , 3 , 1426847190 , $ timeslice3 ));
81
- $ this ->assertEquals (47561572 , $ timeslice3 );
81
+ $ this ->assertSame (47561572 , $ timeslice3 );
82
82
$ this ->assertTrue ($ tfa ->verifyCode ('VMR466AB62ZBOKHE ' , '543160 ' , 3 , 1426847190 , $ timeslice4 ));
83
- $ this ->assertEquals (47561573 , $ timeslice4 );
83
+ $ this ->assertSame (47561573 , $ timeslice4 );
84
84
$ this ->assertTrue ($ tfa ->verifyCode ('VMR466AB62ZBOKHE ' , '348401 ' , 3 , 1426847190 , $ timeslice5 ));
85
- $ this ->assertEquals (47561574 , $ timeslice5 );
85
+ $ this ->assertSame (47561574 , $ timeslice5 );
86
86
$ this ->assertTrue ($ tfa ->verifyCode ('VMR466AB62ZBOKHE ' , '648525 ' , 3 , 1426847190 , $ timeslice6 ));
87
- $ this ->assertEquals (47561575 , $ timeslice6 );
87
+ $ this ->assertSame (47561575 , $ timeslice6 );
88
88
$ this ->assertTrue ($ tfa ->verifyCode ('VMR466AB62ZBOKHE ' , '170645 ' , 3 , 1426847190 , $ timeslice7 ));
89
- $ this ->assertEquals (47561576 , $ timeslice7 );
89
+ $ this ->assertSame (47561576 , $ timeslice7 );
90
90
91
91
// Incorrect code should return false and a 0 timeslice
92
92
$ this ->assertFalse ($ tfa ->verifyCode ('VMR466AB62ZBOKHE ' , '111111 ' , 3 , 1426847190 , $ timeslice8 ));
93
- $ this ->assertEquals (0 , $ timeslice8 );
93
+ $ this ->assertSame (0 , $ timeslice8 );
94
94
}
95
95
96
96
public function testGetCodeThrowsOnInvalidBase32String1 (): void
@@ -130,13 +130,13 @@ public function testKnownBase32DecodeTestVectors(): void
130
130
$ method ->setAccessible (true );
131
131
132
132
// Test vectors from: https://tools.ietf.org/html/rfc4648#page-12
133
- $ this ->assertEquals ('' , $ method ->invoke ($ tfa , '' ));
134
- $ this ->assertEquals ('f ' , $ method ->invoke ($ tfa , 'MY====== ' ));
135
- $ this ->assertEquals ('fo ' , $ method ->invoke ($ tfa , 'MZXQ==== ' ));
136
- $ this ->assertEquals ('foo ' , $ method ->invoke ($ tfa , 'MZXW6=== ' ));
137
- $ this ->assertEquals ('foob ' , $ method ->invoke ($ tfa , 'MZXW6YQ= ' ));
138
- $ this ->assertEquals ('fooba ' , $ method ->invoke ($ tfa , 'MZXW6YTB ' ));
139
- $ this ->assertEquals ('foobar ' , $ method ->invoke ($ tfa , 'MZXW6YTBOI====== ' ));
133
+ $ this ->assertSame ('' , $ method ->invoke ($ tfa , '' ));
134
+ $ this ->assertSame ('f ' , $ method ->invoke ($ tfa , 'MY====== ' ));
135
+ $ this ->assertSame ('fo ' , $ method ->invoke ($ tfa , 'MZXQ==== ' ));
136
+ $ this ->assertSame ('foo ' , $ method ->invoke ($ tfa , 'MZXW6=== ' ));
137
+ $ this ->assertSame ('foob ' , $ method ->invoke ($ tfa , 'MZXW6YQ= ' ));
138
+ $ this ->assertSame ('fooba ' , $ method ->invoke ($ tfa , 'MZXW6YTB ' ));
139
+ $ this ->assertSame ('foobar ' , $ method ->invoke ($ tfa , 'MZXW6YTBOI====== ' ));
140
140
}
141
141
142
142
public function testKnownBase32DecodeUnpaddedTestVectors (): void
@@ -151,51 +151,51 @@ public function testKnownBase32DecodeUnpaddedTestVectors(): void
151
151
$ method ->setAccessible (true );
152
152
153
153
// Test vectors from: https://tools.ietf.org/html/rfc4648#page-12
154
- $ this ->assertEquals ('' , $ method ->invoke ($ tfa , '' ));
155
- $ this ->assertEquals ('f ' , $ method ->invoke ($ tfa , 'MY ' ));
156
- $ this ->assertEquals ('fo ' , $ method ->invoke ($ tfa , 'MZXQ ' ));
157
- $ this ->assertEquals ('foo ' , $ method ->invoke ($ tfa , 'MZXW6 ' ));
158
- $ this ->assertEquals ('foob ' , $ method ->invoke ($ tfa , 'MZXW6YQ ' ));
159
- $ this ->assertEquals ('fooba ' , $ method ->invoke ($ tfa , 'MZXW6YTB ' ));
160
- $ this ->assertEquals ('foobar ' , $ method ->invoke ($ tfa , 'MZXW6YTBOI ' ));
154
+ $ this ->assertSame ('' , $ method ->invoke ($ tfa , '' ));
155
+ $ this ->assertSame ('f ' , $ method ->invoke ($ tfa , 'MY ' ));
156
+ $ this ->assertSame ('fo ' , $ method ->invoke ($ tfa , 'MZXQ ' ));
157
+ $ this ->assertSame ('foo ' , $ method ->invoke ($ tfa , 'MZXW6 ' ));
158
+ $ this ->assertSame ('foob ' , $ method ->invoke ($ tfa , 'MZXW6YQ ' ));
159
+ $ this ->assertSame ('fooba ' , $ method ->invoke ($ tfa , 'MZXW6YTB ' ));
160
+ $ this ->assertSame ('foobar ' , $ method ->invoke ($ tfa , 'MZXW6YTBOI ' ));
161
161
}
162
162
163
163
public function testKnownTestVectors_sha1 (): void
164
164
{
165
165
//Known test vectors for SHA1: https://tools.ietf.org/html/rfc6238#page-15
166
166
$ secret = 'GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ ' ; //== base32encode('12345678901234567890')
167
167
$ tfa = new TwoFactorAuth ('Test ' , 8 , 30 , Algorithm::Sha1);
168
- $ this ->assertEquals ('94287082 ' , $ tfa ->getCode ($ secret , 59 ));
169
- $ this ->assertEquals ('07081804 ' , $ tfa ->getCode ($ secret , 1111111109 ));
170
- $ this ->assertEquals ('14050471 ' , $ tfa ->getCode ($ secret , 1111111111 ));
171
- $ this ->assertEquals ('89005924 ' , $ tfa ->getCode ($ secret , 1234567890 ));
172
- $ this ->assertEquals ('69279037 ' , $ tfa ->getCode ($ secret , 2000000000 ));
173
- $ this ->assertEquals ('65353130 ' , $ tfa ->getCode ($ secret , 20000000000 ));
168
+ $ this ->assertSame ('94287082 ' , $ tfa ->getCode ($ secret , 59 ));
169
+ $ this ->assertSame ('07081804 ' , $ tfa ->getCode ($ secret , 1111111109 ));
170
+ $ this ->assertSame ('14050471 ' , $ tfa ->getCode ($ secret , 1111111111 ));
171
+ $ this ->assertSame ('89005924 ' , $ tfa ->getCode ($ secret , 1234567890 ));
172
+ $ this ->assertSame ('69279037 ' , $ tfa ->getCode ($ secret , 2000000000 ));
173
+ $ this ->assertSame ('65353130 ' , $ tfa ->getCode ($ secret , 20000000000 ));
174
174
}
175
175
176
176
public function testKnownTestVectors_sha256 (): void
177
177
{
178
178
//Known test vectors for SHA256: https://tools.ietf.org/html/rfc6238#page-15
179
179
$ secret = 'GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQGEZA ' ; //== base32encode('12345678901234567890123456789012')
180
180
$ tfa = new TwoFactorAuth ('Test ' , 8 , 30 , Algorithm::Sha256);
181
- $ this ->assertEquals ('46119246 ' , $ tfa ->getCode ($ secret , 59 ));
182
- $ this ->assertEquals ('68084774 ' , $ tfa ->getCode ($ secret , 1111111109 ));
183
- $ this ->assertEquals ('67062674 ' , $ tfa ->getCode ($ secret , 1111111111 ));
184
- $ this ->assertEquals ('91819424 ' , $ tfa ->getCode ($ secret , 1234567890 ));
185
- $ this ->assertEquals ('90698825 ' , $ tfa ->getCode ($ secret , 2000000000 ));
186
- $ this ->assertEquals ('77737706 ' , $ tfa ->getCode ($ secret , 20000000000 ));
181
+ $ this ->assertSame ('46119246 ' , $ tfa ->getCode ($ secret , 59 ));
182
+ $ this ->assertSame ('68084774 ' , $ tfa ->getCode ($ secret , 1111111109 ));
183
+ $ this ->assertSame ('67062674 ' , $ tfa ->getCode ($ secret , 1111111111 ));
184
+ $ this ->assertSame ('91819424 ' , $ tfa ->getCode ($ secret , 1234567890 ));
185
+ $ this ->assertSame ('90698825 ' , $ tfa ->getCode ($ secret , 2000000000 ));
186
+ $ this ->assertSame ('77737706 ' , $ tfa ->getCode ($ secret , 20000000000 ));
187
187
}
188
188
189
189
public function testKnownTestVectors_sha512 (): void
190
190
{
191
191
//Known test vectors for SHA512: https://tools.ietf.org/html/rfc6238#page-15
192
192
$ secret = 'GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQGEZDGNA ' ; //== base32encode('1234567890123456789012345678901234567890123456789012345678901234')
193
193
$ tfa = new TwoFactorAuth ('Test ' , 8 , 30 , Algorithm::Sha512);
194
- $ this ->assertEquals ('90693936 ' , $ tfa ->getCode ($ secret , 59 ));
195
- $ this ->assertEquals ('25091201 ' , $ tfa ->getCode ($ secret , 1111111109 ));
196
- $ this ->assertEquals ('99943326 ' , $ tfa ->getCode ($ secret , 1111111111 ));
197
- $ this ->assertEquals ('93441116 ' , $ tfa ->getCode ($ secret , 1234567890 ));
198
- $ this ->assertEquals ('38618901 ' , $ tfa ->getCode ($ secret , 2000000000 ));
199
- $ this ->assertEquals ('47863826 ' , $ tfa ->getCode ($ secret , 20000000000 ));
194
+ $ this ->assertSame ('90693936 ' , $ tfa ->getCode ($ secret , 59 ));
195
+ $ this ->assertSame ('25091201 ' , $ tfa ->getCode ($ secret , 1111111109 ));
196
+ $ this ->assertSame ('99943326 ' , $ tfa ->getCode ($ secret , 1111111111 ));
197
+ $ this ->assertSame ('93441116 ' , $ tfa ->getCode ($ secret , 1234567890 ));
198
+ $ this ->assertSame ('38618901 ' , $ tfa ->getCode ($ secret , 2000000000 ));
199
+ $ this ->assertSame ('47863826 ' , $ tfa ->getCode ($ secret , 20000000000 ));
200
200
}
201
201
}
0 commit comments