|
17 | 17 | use ParagonIE\ConstantTime\Base64UrlSafe; |
18 | 18 | use Symfony\Component\Uid\NilUuid; |
19 | 19 | use Symfony\Component\Uid\Uuid; |
| 20 | +use Webauthn\AuthenticatorData; |
20 | 21 | use Webauthn\PublicKeyCredentialSource; |
21 | 22 |
|
22 | 23 | class WebauthnTest extends FeatureTestCase |
@@ -93,67 +94,6 @@ public function test_get_authenticate_data() |
93 | 94 | $this->assertCount(0, $publicKey->getExtensions()); |
94 | 95 | } |
95 | 96 |
|
96 | | - /** |
97 | | - * @test |
98 | | - */ |
99 | | - public function test_do_authenticate() |
100 | | - { |
101 | | - $user = $this->signIn(); |
102 | | - $webauthnKey = factory(WebauthnKey::class)->create([ |
103 | | - 'user_id' => $user->getAuthIdentifier(), |
104 | | - 'credentialPublicKey' => (string) new MapObject([ |
105 | | - new MapItem( |
106 | | - new TextStringObject('1'), |
107 | | - new TextStringObject('0') |
108 | | - ), |
109 | | - new MapItem( |
110 | | - new TextStringObject('3'), |
111 | | - new TextStringObject('-7') |
112 | | - ), |
113 | | - ]), |
114 | | - ]); |
115 | | - |
116 | | - $publicKey = $this->app[PrepareAssertionData::class]($user); |
117 | | - $this->assertInstanceOf(\Webauthn\PublicKeyCredentialRequestOptions::class, $publicKey); |
118 | | - |
119 | | - $data = [ |
120 | | - 'id' => Base64UrlSafe::encodeUnpadded($webauthnKey->credentialId), |
121 | | - 'rawId' => Base64UrlSafe::encode($webauthnKey->credentialId), |
122 | | - 'type' => 'public-key', |
123 | | - 'response' => [ |
124 | | - 'clientDataJSON' => Base64UrlSafe::encodeUnpadded(json_encode([ |
125 | | - 'type' => 'webauthn.get', |
126 | | - 'challenge' => Base64UrlSafe::encodeUnpadded($publicKey->getChallenge()), |
127 | | - 'origin' => 'https://localhost', |
128 | | - 'tokenBinding' => [ |
129 | | - 'status' => 'supported', |
130 | | - 'id' => Base64UrlSafe::encodeUnpadded(1), |
131 | | - ], |
132 | | - ])), |
133 | | - 'authenticatorData' => Base64UrlSafe::encodeUnpadded( |
134 | | - hash('sha256', 'localhost', true). // rp_id_hash |
135 | | - pack('C', 65). // flags |
136 | | - pack('N', 1). // signCount |
137 | | - '0000000000000000'. // aaguid |
138 | | - pack('n', 1).'0'. // credentialLength |
139 | | - ((string) new MapObject([ |
140 | | - new MapItem( |
141 | | - new TextStringObject('key'), |
142 | | - new TextStringObject('value') |
143 | | - ), |
144 | | - ])) // credentialPublicKey |
145 | | - ), |
146 | | - 'signature' => Base64UrlSafe::encode(new TextStringObject('00000100000001000000010000000100000001000000010000000100000001')), |
147 | | - 'userHandle' => base64_encode($user->getAuthIdentifier()), |
148 | | - ], |
149 | | - ]; |
150 | | - |
151 | | - $this->expectException(\InvalidArgumentException::class); |
152 | | - $result = Webauthn::validateAssertion($user, $data); |
153 | | - |
154 | | - $this->assertTrue($result); // Not yet ... |
155 | | - } |
156 | | - |
157 | 97 | /** |
158 | 98 | * @test |
159 | 99 | */ |
@@ -194,7 +134,7 @@ private function getAttestationData($publicKey) |
194 | 134 | new TextStringObject('authData'), |
195 | 135 | new TextStringObject( |
196 | 136 | hash('sha256', 'localhost', true). // rp_id_hash |
197 | | - pack('C', 65). // flags |
| 137 | + pack('C', AuthenticatorData::FLAG_AT | AuthenticatorData::FLAG_UP). // flags |
198 | 138 | pack('N', 1). // signCount |
199 | 139 | '0000000000000000'. // aaguid |
200 | 140 | pack('n', 1).'0'. // credentialLength |
|
0 commit comments