28
28
public class TokenRequestTest extends AbstractMsalTests {
29
29
30
30
@ Test
31
- public void executeOAuthRequest_SCBadRequestErrorInteractionRequired_AuthenticationServiceException ()
31
+ public void executeOAuthRequest_SCBadRequestErrorInvalidGrant_InteractionRequiredException ()
32
32
throws SerializeException , ParseException , MsalException ,
33
33
IOException , URISyntaxException {
34
34
35
35
TokenRequest request = createMockedTokenRequest ();
36
36
37
- OAuthHttpRequest msalOAuthHttpRequest = PowerMock
38
- .createMock (OAuthHttpRequest .class );
37
+ OAuthHttpRequest msalOAuthHttpRequest = PowerMock .createMock (OAuthHttpRequest .class );
39
38
40
39
HTTPResponse httpResponse = new HTTPResponse (HTTPResponse .SC_BAD_REQUEST );
41
40
42
41
String claims = "{\\ \" access_token\\ \" :{\\ \" polids\\ \" :{\\ \" essential\\ \" :true,\\ \" values\\ \" :[\\ \" 5ce770ea-8690-4747-aa73-c5b3cd509cd4\\ \" ]}}}" ;
43
42
44
- String content = "{\" error\" :\" interaction_required \" ," +
45
- "\" error_description\" :\" AADSTS50076 : description\\ r\\ nCorrelation ID: 3a...5a\\ r\\ nTimestamp:2017-07-15 02:35:05Z\" ," +
43
+ String content = "{\" error\" :\" invalid_grant \" ," +
44
+ "\" error_description\" :\" AADSTS65001 : description\\ r\\ nCorrelation ID: 3a...5a\\ r\\ nTimestamp:2017-07-15 02:35:05Z\" ," +
46
45
"\" error_codes\" :[50076]," +
47
46
"\" timestamp\" :\" 2017-07-15 02:35:05Z\" ," +
48
47
"\" trace_id\" :\" 0788...000\" ," +
49
48
"\" correlation_id\" :\" 3a...95a\" ," +
49
+ "\" suberror\" :\" basic_action\" ," +
50
50
"\" claims\" :\" " + claims + "\" }" ;
51
51
httpResponse .setContent (content );
52
52
httpResponse .setContentType (CommonContentTypes .APPLICATION_JSON );
@@ -59,20 +59,22 @@ public void executeOAuthRequest_SCBadRequestErrorInteractionRequired_Authenticat
59
59
try {
60
60
request .executeOauthRequestAndProcessResponse ();
61
61
Assert .fail ("Expected MsalServiceException was not thrown" );
62
- } catch (MsalServiceException ex ) {
62
+ } catch (MsalInteractionRequiredException ex ) {
63
63
Assert .assertEquals (claims .replace ("\\ " , "" ), ex .claims ());
64
+ Assert .assertEquals (ex .reason (), InteractionRequiredExceptionReason .BASIC_ACTION );
64
65
}
65
66
PowerMock .verifyAll ();
66
67
}
67
68
68
69
@ Test
69
- public void executeOAuthRequest_SCBadRequestErrorInvalidGrant_InteractionRequiredException ()
70
+ public void executeOAuthRequest_SCBadRequestErrorInvalidGrant_SubErrorFilteredServiceExceptionThrown ()
70
71
throws SerializeException , ParseException , MsalException ,
71
72
IOException , URISyntaxException {
72
73
73
74
TokenRequest request = createMockedTokenRequest ();
74
75
75
- OAuthHttpRequest msalOAuthHttpRequest = PowerMock .createMock (OAuthHttpRequest .class );
76
+ OAuthHttpRequest msalOAuthHttpRequest = PowerMock
77
+ .createMock (OAuthHttpRequest .class );
76
78
77
79
HTTPResponse httpResponse = new HTTPResponse (HTTPResponse .SC_BAD_REQUEST );
78
80
@@ -84,7 +86,7 @@ public void executeOAuthRequest_SCBadRequestErrorInvalidGrant_InteractionRequire
84
86
"\" timestamp\" :\" 2017-07-15 02:35:05Z\" ," +
85
87
"\" trace_id\" :\" 0788...000\" ," +
86
88
"\" correlation_id\" :\" 3a...95a\" ," +
87
- "\" suberror\" :\" basic_action \" ," +
89
+ "\" suberror\" :\" client_mismatch \" ," +
88
90
"\" claims\" :\" " + claims + "\" }" ;
89
91
httpResponse .setContent (content );
90
92
httpResponse .setContentType (CommonContentTypes .APPLICATION_JSON );
@@ -97,9 +99,9 @@ public void executeOAuthRequest_SCBadRequestErrorInvalidGrant_InteractionRequire
97
99
try {
98
100
request .executeOauthRequestAndProcessResponse ();
99
101
Assert .fail ("Expected MsalServiceException was not thrown" );
100
- } catch (MsalInteractionRequiredException ex ) {
102
+ } catch (MsalServiceException ex ) {
101
103
Assert .assertEquals (claims .replace ("\\ " , "" ), ex .claims ());
102
- Assert .assertEquals ( ex . classification (), ServiceExceptionClassification . BASIC_ACTION );
104
+ Assert .assertTrue (!( ex instanceof MsalInteractionRequiredException ) );
103
105
}
104
106
PowerMock .verifyAll ();
105
107
}
@@ -127,7 +129,7 @@ private TokenRequest createMockedTokenRequest() throws URISyntaxException, Malfo
127
129
128
130
return PowerMock .createPartialMock (
129
131
TokenRequest .class , new String []{"toOauthHttpRequest" },
130
- new URL ("http://login.windows.net" ),
132
+ new AADAuthority ( new URL (TestConstants . ORGANIZATIONS_AUTHORITY ) ),
131
133
acr ,
132
134
serviceBundle );
133
135
}
0 commit comments