Skip to content

Commit

Permalink
resloved bug for acceptedScopes and added testcase for that
Browse files Browse the repository at this point in the history
  • Loading branch information
kaifk468 committed Oct 16, 2023
1 parent 601b7dc commit ec4b48f
Showing 1 changed file with 35 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1004,6 +1004,41 @@ public void getAuthCode_withValidInput_thenPass() {
Assert.assertEquals(authorizationServiceImpl.getAuthCode(authCodeRequest).getState(), "test-state");
}

@Test
public void getAuthCode_withInValidInput_thenFail() {

AuthorizationServiceImpl authService=new AuthorizationServiceImpl();
ReflectionTestUtils.setField(authorizationServiceImpl, "autoPermitCredentialScopes", true);
AuthCodeRequest authCodeRequest = new AuthCodeRequest();
authCodeRequest.setTransactionId("987654321");
List<String> scopeList=new ArrayList<>();
scopeList.add("fullName");
authCodeRequest.setPermittedAuthorizeScopes(scopeList);
OIDCTransaction transaction = new OIDCTransaction();
transaction.setAuthTransactionId("987654321");
List<String> requestedScopeList=new ArrayList<>();
requestedScopeList.add("test-scope");
transaction.setRequestedAuthorizeScopes(requestedScopeList);
transaction.setRedirectUri("http://www.test.com");
transaction.setNonce("test-nonce");
transaction.setState("test-state");
List<String> credentialScopesList=new ArrayList<>();
credentialScopesList.add("teat1");
credentialScopesList.add("tesqt2");
transaction.setRequestedCredentialScopes(credentialScopesList);
Claims requestedClaims = new Claims();
Map<String, ClaimDetail> userinfo = new HashMap<>();
userinfo.put("fullName", new ClaimDetail("test", new String[] {"test"}, true));
Mockito.when(cacheUtilService.getAuthenticatedTransaction(Mockito.anyString())).thenReturn(transaction);
Mockito.when(cacheUtilService.setAuthCodeGeneratedTransaction(Mockito.anyString(), Mockito.any())).thenReturn(transaction);
try {
authorizationServiceImpl.getAuthCode(authCodeRequest);
Assert.fail();
}catch (Exception e) {
Assert.assertTrue(e.getMessage().equals(ErrorConstants.INVALID_PERMITTED_SCOPE));
}
}

private OIDCTransaction createIdpTransaction(String[] acrs) {
OIDCTransaction oidcTransaction = new OIDCTransaction();
Map<String, ClaimDetail> idClaims = new HashMap<>();
Expand Down

0 comments on commit ec4b48f

Please sign in to comment.