-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(jans-auth-server): added online_access scope to issue session bo…
…und refresh token #3012 (#4106) * feat(jans-auth-server): added online_access scope to issue session bound refresh token #3012 * feat(jans-auth-server): added test for online_access scope implementation #3012 * feat(jans-auth-server): added doc about online_access scope #3012
- Loading branch information
Showing
11 changed files
with
177 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 102 additions & 0 deletions
102
jans-auth-server/server/src/test/java/io/jans/as/server/service/GrantServiceTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
package io.jans.as.server.service; | ||
|
||
import io.jans.as.model.config.StaticConfiguration; | ||
import io.jans.as.model.configuration.AppConfiguration; | ||
import io.jans.as.server.model.ldap.TokenEntity; | ||
import io.jans.as.server.model.ldap.TokenType; | ||
import io.jans.orm.PersistenceEntryManager; | ||
import io.jans.service.CacheService; | ||
import io.jans.service.cache.CacheConfiguration; | ||
import org.mockito.InjectMocks; | ||
import org.mockito.Mock; | ||
import org.mockito.Mockito; | ||
import org.mockito.testng.MockitoTestNGListener; | ||
import org.slf4j.Logger; | ||
import org.testng.annotations.Listeners; | ||
import org.testng.annotations.Test; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import static org.testng.Assert.*; | ||
|
||
/** | ||
* @author Yuriy Z | ||
*/ | ||
@Listeners(MockitoTestNGListener.class) | ||
public class GrantServiceTest { | ||
|
||
@InjectMocks | ||
private GrantService grantService; | ||
|
||
@Mock | ||
private Logger log; | ||
|
||
@Mock | ||
private PersistenceEntryManager persistenceEntryManager; | ||
|
||
@Mock | ||
private ClientService clientService; | ||
|
||
@Mock | ||
private CacheService cacheService; | ||
|
||
@Mock | ||
private StaticConfiguration staticConfiguration; | ||
|
||
@Mock | ||
private AppConfiguration appConfiguration; | ||
|
||
@Mock | ||
private CacheConfiguration cacheConfiguration; | ||
|
||
@Test | ||
public void filterOutRefreshTokenFromDeletion_forTokenWithoutOnlineAccess_shouldFilterOut() { | ||
Mockito.doReturn(false).when(appConfiguration).getRemoveRefreshTokensForClientOnLogout(); | ||
|
||
TokenEntity token = new TokenEntity(); | ||
token.setTokenTypeEnum(TokenType.REFRESH_TOKEN); | ||
token.getAttributes().setOnlineAccess(false); | ||
|
||
List<TokenEntity> tokens = new ArrayList<>(); | ||
tokens.add(token); | ||
|
||
grantService.filterOutRefreshTokenFromDeletion(tokens); | ||
assertTrue(tokens.isEmpty()); | ||
} | ||
|
||
@Test | ||
public void filterOutRefreshTokenFromDeletion_forTokenWithOnlineAccess_shouldNotFilterOut() { | ||
Mockito.doReturn(false).when(appConfiguration).getRemoveRefreshTokensForClientOnLogout(); | ||
|
||
TokenEntity token = new TokenEntity(); | ||
token.setTokenTypeEnum(TokenType.REFRESH_TOKEN); | ||
token.getAttributes().setOnlineAccess(true); | ||
|
||
List<TokenEntity> tokens = new ArrayList<>(); | ||
tokens.add(token); | ||
|
||
grantService.filterOutRefreshTokenFromDeletion(tokens); | ||
assertFalse(tokens.isEmpty()); | ||
} | ||
|
||
@Test | ||
public void filterOutRefreshTokenFromDeletion_whenConfigurationRemoveRefreshTokensForClientOnLogoutIsTrue_shouldNotFilterOut() { | ||
Mockito.doReturn(true).when(appConfiguration).getRemoveRefreshTokensForClientOnLogout(); | ||
|
||
TokenEntity token = new TokenEntity(); | ||
token.setTokenTypeEnum(TokenType.REFRESH_TOKEN); | ||
token.getAttributes().setOnlineAccess(false); | ||
|
||
TokenEntity another = new TokenEntity(); | ||
another.setTokenTypeEnum(TokenType.REFRESH_TOKEN); | ||
another.getAttributes().setOnlineAccess(true); | ||
|
||
List<TokenEntity> tokens = new ArrayList<>(); | ||
tokens.add(token); | ||
tokens.add(another); | ||
|
||
grantService.filterOutRefreshTokenFromDeletion(tokens); | ||
assertEquals(tokens.size(), 2); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters