Skip to content

Commit

Permalink
fix(jans-auth-server): added test for npe fix
Browse files Browse the repository at this point in the history
Native SSO

#2518
#2762
  • Loading branch information
yuriyz committed Oct 28, 2022
1 parent e4064a9 commit afaa776
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,19 @@ public class TokenExchangeServiceTest {
@InjectMocks
private TokenExchangeService tokenExchangeService;

@Test
public void putNewDeviceSecret_whenScopeIsNull_shouldNotGenerateDeviceSecretAndShouldNotThrowNPE() {
SessionId sessionId = new SessionId();
Client client = new Client();
client.setGrantTypes(new GrantType[] {GrantType.AUTHORIZATION_CODE, GrantType.TOKEN_EXCHANGE});

final JSONObject jsonObj = new JSONObject();
tokenExchangeService.putNewDeviceSecret(jsonObj, "sessionDn", client, null);

assertTrue(sessionId.getDeviceSecrets().isEmpty());
assertFalse(jsonObj.has("device_token"));
}

@Test
public void putNewDeviceSecret_whenScopeDeviceSSOIsNotPresent_shouldNotGenerateDeviceSecret() {
SessionId sessionId = new SessionId();
Expand All @@ -60,7 +73,6 @@ public void putNewDeviceSecret_whenScopeDeviceSSOIsNotPresent_shouldNotGenerateD
assertFalse(jsonObj.has("device_token"));
}


@Test
public void putNewDeviceSecret_whenTokenExchangeGrantIsNotPresent_shouldNotGenerateDeviceSecret() {
SessionId sessionId = new SessionId();
Expand Down

0 comments on commit afaa776

Please sign in to comment.