Fix OfflineServletsAdapterTest

This commit is contained in:
Martin Bartoš 2023-04-18 13:24:51 +02:00 committed by Václav Muzikář
parent 8d5a4f2677
commit 60fd7e63d9
2 changed files with 13 additions and 8 deletions

View file

@ -13,6 +13,7 @@ import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
import org.keycloak.OAuth2Constants;
import org.keycloak.representations.RefreshToken;
import org.keycloak.representations.idm.RealmRepresentation;
import org.keycloak.testsuite.AssertEvents;
import org.keycloak.testsuite.adapter.AbstractServletsAdapterTest;
@ -91,7 +92,8 @@ public class OfflineServletsAdapterTest extends AbstractServletsAdapterTest {
@Override
protected boolean isImportAfterEachMethod() {
return false;
// For proper cleanup of test methods
return true;
}
@Test
@ -111,12 +113,13 @@ public class OfflineServletsAdapterTest extends AbstractServletsAdapterTest {
assertCurrentUrlStartsWith(offlineTokenPage);
assertThat(offlineTokenPage.getRefreshToken(), notNullValue());
assertThat(TokenUtil.TOKEN_TYPE_OFFLINE, is(offlineTokenPage.getRefreshToken().getType()));
assertThat(offlineTokenPage.getRefreshToken().getExp(), nullValue());
RefreshToken refreshToken = offlineTokenPage.getRefreshToken();
assertThat(refreshToken, notNullValue());
assertThat(TokenUtil.TOKEN_TYPE_OFFLINE, is(refreshToken.getType()));
assertThat(refreshToken.getExp(), nullValue());
String accessTokenId = offlineTokenPage.getAccessToken().getId();
String refreshTokenId = offlineTokenPage.getRefreshToken().getId();
String refreshTokenId = refreshToken.getId();
// online user session will be expired and removed
setAdapterAndServerTimeOffset(9999);
@ -166,8 +169,9 @@ public class OfflineServletsAdapterTest extends AbstractServletsAdapterTest {
loginPage.login(DEFAULT_USERNAME, DEFAULT_PASSWORD);
assertCurrentUrlStartsWith(offlineTokenPage);
assertThat(offlineTokenPage.getRefreshToken(), notNullValue());
assertThat(offlineTokenPage.getRefreshToken().getType(), is(TokenUtil.TOKEN_TYPE_OFFLINE));
final RefreshToken refreshToken = offlineTokenPage.getRefreshToken();
assertThat(refreshToken, notNullValue());
assertThat(refreshToken.getType(), is(TokenUtil.TOKEN_TYPE_OFFLINE));
// Assert refresh works with increased time
setAdapterAndServerTimeOffset(9999);

View file

@ -5,5 +5,6 @@
"ssl-required" : "external",
"credentials": {
"secret": "secret1"
}
},
"min-time-between-jwks-requests": 1
}