@@ -65,7 +65,6 @@ public class AuthenticationAPIClientTest {
6565
6666 private static final String CLIENT_ID = "CLIENTID" ;
6767 private static final String DOMAIN = "samples.auth0.com" ;
68- private static final String CONNECTION = "DB" ;
6968 private static final String USERNAME_PASSWORD_AUTHENTICATION = "Username-Password-Authentication" ;
7069 private static final String PASSWORD = "123123123" ;
7170 private static final String SUPPORT_AUTH0_COM = "support@auth0.com" ;
@@ -101,104 +100,6 @@ public void shouldCreateClientWithAccountInfo() throws Exception {
101100 assertThat (client .getBaseURL (), equalTo ("https://samples.auth0.com" ));
102101 }
103102
104- @ Test
105- public void shouldLoginWithResourceOwner () throws Exception {
106- mockAPI .willReturnSuccessfulLogin ();
107- final MockBaseCallback <Credentials > callback = new MockBaseCallback <>();
108-
109- final Map <String , Object > parameters = ParameterBuilder .newAuthenticationBuilder ()
110- .setConnection ("DB" )
111- .setGrantType (ParameterBuilder .GRANT_TYPE_PASSWORD )
112- .set ("username" , SUPPORT_AUTH0_COM )
113- .set ("password" , "notapassword" )
114- .setScope (ParameterBuilder .SCOPE_OPENID )
115- .asDictionary ();
116- client
117- .loginWithResourceOwner (parameters )
118- .start (callback );
119-
120- assertThat (callback , hasPayloadOfType (Credentials .class ));
121-
122- final RecordedRequest request = mockAPI .takeRequest ();
123- assertThat (request .getPath (), equalTo ("/oauth/ro" ));
124-
125- Map <String , String > body = bodyFromRequest (request );
126- assertThat (body , hasEntry ("connection" , "DB" ));
127- assertThat (body , hasEntry ("grant_type" , "password" ));
128- assertThat (body , hasEntry ("username" , SUPPORT_AUTH0_COM ));
129- assertThat (body , hasEntry ("password" , "notapassword" ));
130- assertThat (body , hasEntry ("scope" , OPENID ));
131- }
132-
133- @ Test
134- public void shouldLoginWithResourceOwnerSync () throws Exception {
135- mockAPI .willReturnSuccessfulLogin ();
136-
137- final Map <String , Object > parameters = ParameterBuilder .newAuthenticationBuilder ()
138- .setConnection ("DB" )
139- .setGrantType (ParameterBuilder .GRANT_TYPE_PASSWORD )
140- .set ("username" , SUPPORT_AUTH0_COM )
141- .set ("password" , "notapassword" )
142- .setScope (ParameterBuilder .SCOPE_OPENID )
143- .asDictionary ();
144-
145- final Credentials credentials = client
146- .loginWithResourceOwner (parameters )
147- .execute ();
148-
149- assertThat (credentials , is (notNullValue ()));
150-
151- final RecordedRequest request = mockAPI .takeRequest ();
152- assertThat (request .getPath (), equalTo ("/oauth/ro" ));
153-
154- Map <String , String > body = bodyFromRequest (request );
155- assertThat (body , hasEntry ("connection" , "DB" ));
156- assertThat (body , hasEntry ("grant_type" , "password" ));
157- assertThat (body , hasEntry ("username" , SUPPORT_AUTH0_COM ));
158- assertThat (body , hasEntry ("password" , "notapassword" ));
159- assertThat (body , hasEntry ("scope" , OPENID ));
160- }
161-
162- @ Test
163- public void shouldFailLoginWithResourceOwner () throws Exception {
164- mockAPI .willReturnFailedLogin ();
165- final MockBaseCallback <Credentials > callback = new MockBaseCallback <>();
166-
167- final Map <String , Object > parameters = ParameterBuilder .newAuthenticationBuilder ()
168- .setConnection (CONNECTION )
169- .setGrantType (ParameterBuilder .GRANT_TYPE_PASSWORD )
170- .set ("username" , SUPPORT_AUTH0_COM )
171- .set ("password" , "notapassword" )
172- .asDictionary ();
173- client
174- .loginWithResourceOwner (parameters )
175- .start (callback );
176-
177- assertThat (callback , hasNoPayloadOfType (Credentials .class ));
178- }
179-
180- @ Test
181- public void shouldFailLoginWithResourceOwnerSync () throws Exception {
182- mockAPI .willReturnFailedLogin ();
183- final MockBaseCallback <Credentials > callback = new MockBaseCallback <>();
184-
185- final Map <String , Object > parameters = ParameterBuilder .newAuthenticationBuilder ()
186- .setConnection (CONNECTION )
187- .setGrantType (ParameterBuilder .GRANT_TYPE_PASSWORD )
188- .set ("username" , SUPPORT_AUTH0_COM )
189- .set ("password" , "notapassword" )
190- .asDictionary ();
191-
192- Exception exception = null ;
193- try {
194- client .loginWithResourceOwner (parameters ).execute ();
195- } catch (Auth0Exception e ) {
196- exception = e ;
197- }
198-
199- assertThat (exception , is (notNullValue ()));
200- }
201-
202103 @ Test
203104 public void shouldLoginWithUserAndPassword () throws Exception {
204105 mockAPI
0 commit comments