@@ -113,11 +113,98 @@ public function testWillIssueIntentWithValidCredentials(): void
113
113
114
114
public function testWillNotIssueIntentIfAuthorizerDoesNotSupportSecondFactor (): void
115
115
{
116
- $ this ->markTestSkipped ();
116
+ $ credentials = [
117
+ 'username ' => 'user ' ,
118
+ 'password ' => 'pass ' ,
119
+ ];
120
+
121
+ $ user = $ this ->createMock (AuthenticatedUserInterface::class);
122
+ $ user
123
+ ->expects ($ this ->never ())
124
+ ->method ('requiresSecondFactor ' );
125
+
126
+ $ authorizer = $ this ->createMock (AuthorizerInterface::class);
127
+ $ authorizer
128
+ ->expects ($ this ->once ())
129
+ ->method ('verifyCredentials ' )
130
+ ->with ($ credentials )
131
+ ->willReturn ($ user );
132
+ $ authorizer
133
+ ->expects ($ this ->once ())
134
+ ->method ('supportsSecondFactor ' )
135
+ ->willReturn (false );
136
+
137
+ $ session = $ this ->createMock (SessionInterface::class);
138
+
139
+ $ adapter = $ this ->createMock (AdapterInterface::class);
140
+ $ adapter
141
+ ->expects ($ this ->once ())
142
+ ->method ('authenticate ' )
143
+ ->willReturn ($ session );
144
+
145
+ $ transport = (new Authentication (
146
+ $ this ->createMock (IntentRepositoryInterface::class)
147
+ ))->authorize (
148
+ $ authorizer ,
149
+ $ adapter ,
150
+ $ credentials ,
151
+ );
152
+
153
+ $ this ->assertInstanceOf (
154
+ AuthorizationTransportInterface::class,
155
+ $ transport ,
156
+ );
157
+
158
+ $ this ->assertInstanceOf (AuthenticatedUserInterface::class, $ transport ->getAuthenticatedUser ());
159
+ $ this ->assertInstanceOf (SessionInterface::class, $ transport ->getAuthenticatedWith ());
117
160
}
118
161
119
162
public function testWillNotIssueIntentIfUserDoesNotRequireSecondFactor (): void
120
163
{
121
- $ this ->markTestSkipped ();
164
+ $ credentials = [
165
+ 'username ' => 'user ' ,
166
+ 'password ' => 'pass ' ,
167
+ ];
168
+
169
+ $ user = $ this ->createMock (AuthenticatedUserInterface::class);
170
+ $ user
171
+ ->expects ($ this ->once ())
172
+ ->method ('requiresSecondFactor ' )
173
+ ->willReturn (false );
174
+
175
+ $ authorizer = $ this ->createMock (AuthorizerInterface::class);
176
+ $ authorizer
177
+ ->expects ($ this ->once ())
178
+ ->method ('verifyCredentials ' )
179
+ ->with ($ credentials )
180
+ ->willReturn ($ user );
181
+ $ authorizer
182
+ ->expects ($ this ->once ())
183
+ ->method ('supportsSecondFactor ' )
184
+ ->willReturn (true );
185
+
186
+ $ session = $ this ->createMock (SessionInterface::class);
187
+
188
+ $ adapter = $ this ->createMock (AdapterInterface::class);
189
+ $ adapter
190
+ ->expects ($ this ->once ())
191
+ ->method ('authenticate ' )
192
+ ->willReturn ($ session );
193
+
194
+ $ transport = (new Authentication (
195
+ $ this ->createMock (IntentRepositoryInterface::class)
196
+ ))->authorize (
197
+ $ authorizer ,
198
+ $ adapter ,
199
+ $ credentials ,
200
+ );
201
+
202
+ $ this ->assertInstanceOf (
203
+ AuthorizationTransportInterface::class,
204
+ $ transport ,
205
+ );
206
+
207
+ $ this ->assertInstanceOf (AuthenticatedUserInterface::class, $ transport ->getAuthenticatedUser ());
208
+ $ this ->assertInstanceOf (SessionInterface::class, $ transport ->getAuthenticatedWith ());
122
209
}
123
210
}
0 commit comments