Skip to content

Commit

Permalink
[ES-1033] added test cases (#738)
Browse files Browse the repository at this point in the history
* [ES-1033] added test cases

Signed-off-by: Venkata Saidurga Polamraju <saidurgacsea@gmail.com>

* reviewed changes

Signed-off-by: Venkata Saidurga Polamraju <saidurgacsea@gmail.com>

---------

Signed-off-by: Venkata Saidurga Polamraju <saidurgacsea@gmail.com>
  • Loading branch information
pvsaidurga authored Jun 1, 2024
1 parent 9e47991 commit f026a2b
Showing 1 changed file with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@

import java.util.*;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import static io.mosip.esignet.core.spi.TokenService.ACR;
Expand Down Expand Up @@ -75,6 +77,9 @@ public class AuthorizationServiceTest {
@Mock
HttpServletResponse httpServletResponse;

@Mock
HttpServletRequest httpServletRequest;


@Before
public void setUp() {
Expand Down Expand Up @@ -465,6 +470,31 @@ public void getOauthDetailsV2_withInvalidRedirectUri_throwsException() throws Es
}
}

@Test
public void testGetOauthDetailsV3_WithInvalidIdTokenHint_ShouldThrowEsignetException() {
OAuthDetailRequestV3 oauthDetailReqDto = new OAuthDetailRequestV3();
oauthDetailReqDto.setIdTokenHint("invalid_id_token_hint");
try {
authorizationServiceImpl.getOauthDetailsV3(oauthDetailReqDto, httpServletRequest);
Assert.fail();
}catch (EsignetException e){
Assert.assertTrue(e.getErrorCode().equals(ErrorConstants.INVALID_ID_TOKEN_HINT));
}
}

@Test
public void getOauthDetailsV3_WithCookieNotPresent_ThrowsEsignetException() {
OAuthDetailRequestV3 oauthDetailReqDto = new OAuthDetailRequestV3();
oauthDetailReqDto.setIdTokenHint("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.3RJf1g9bKzRC-dEj4b2Jx2yCk7Mz4oG1bZbDqGt8QxE");
Mockito.when(httpServletRequest.getCookies()).thenReturn(new Cookie[]{});
try {
authorizationServiceImpl.getOauthDetailsV3(oauthDetailReqDto, httpServletRequest);
Assert.fail();
}catch (EsignetException e){
Assert.assertTrue(e.getErrorCode().equals(ErrorConstants.INVALID_ID_TOKEN_HINT));
}
}

@Test
public void getOauthDetailsV2_withNullClaimsInDbAndNullClaimsInReq_thenPass() throws EsignetException {
ClientDetail clientDetail = new ClientDetail();
Expand Down

0 comments on commit f026a2b

Please sign in to comment.