use of org.springframework.test.annotation.Rollback in project cas by apereo.
the class SessionHealthIndicatorJpaTests method verifyObserveOkJpaTicketRegistry.
@Test
@Rollback(false)
public void verifyObserveOkJpaTicketRegistry() {
addTicketsToRegistry(jpaRegistry, 5, 5);
assertEquals(10, jpaRegistry.getTickets().size());
final SessionMonitor monitor = new SessionMonitor(jpaRegistry, -1, -1);
final Health status = monitor.health();
assertEquals(Status.UP, status.getStatus());
}
use of org.springframework.test.annotation.Rollback in project ORCID-Source by ORCID.
the class IdentifierTypeManagerTest method test2CreateAndUpdateIdentifier.
@Test
@Transactional
@Rollback
public void test2CreateAndUpdateIdentifier() {
IdentifierType id = idTypeMan.createIdentifierType(createIdentifierType(1));
assertNotNull(id);
assertNotNull(id.getPutCode());
assertTrue(new Date().after(id.getDateCreated()));
id = idTypeMan.fetchIdentifierTypeByDatabaseName("TEST1", null);
assertNotNull(id);
id = idTypeMan.fetchIdentifierTypeByDatabaseName("TEST1", null);
Date last = id.getLastModified();
id.setValidationRegex("test");
id = idTypeMan.updateIdentifierType(id);
assertTrue(last.before(id.getLastModified()));
id = idTypeMan.fetchIdentifierTypeByDatabaseName("TEST1", null);
assertEquals("test1", id.getName());
assertEquals("test", id.getValidationRegex());
assertTrue(last.getTime() < id.getLastModified().getTime());
}
use of org.springframework.test.annotation.Rollback in project ORCID-Source by ORCID.
the class OrcidIndexManagerImplTest method checkGrantsPersisted.
@Test
@Rollback
public void checkGrantsPersisted() throws Exception {
OrcidProfile grantsProfileListing = getOrcidWithGrants();
OrcidSolrDocument grantsListing = solrDocWithFundingTitles();
orcidIndexManager.persistProfileInformationForIndexing(grantsProfileListing);
verify(solrDao).persist(eq(grantsListing));
}
use of org.springframework.test.annotation.Rollback in project ORCID-Source by ORCID.
the class OrcidOauth2TokenDetailServiceTest method removeAllTokensWithSameScopesTest.
@Test
@Transactional
@Rollback
public void removeAllTokensWithSameScopesTest() {
//We will test deleting this token
//Delete
Long token1Id = createToken(CLIENT_ID_1, "token-1", USER_ORCID, new Date(System.currentTimeMillis() + 100000), "/activities/update /read-limited", false).getId();
//Should not delete this
Long token2Id = createToken(CLIENT_ID_1, "token-2", USER_ORCID, new Date(System.currentTimeMillis() + 100000), "/activities/update", false).getId();
//Should not delete this
Long token3Id = createToken(CLIENT_ID_1, "token-3", USER_ORCID, new Date(System.currentTimeMillis() + 100000), "/read-limited", false).getId();
//Should delete this one since it have the same scopes but in different order
//Delete
Long token4Id = createToken(CLIENT_ID_1, "token-4", USER_ORCID, new Date(System.currentTimeMillis() + 100000), "/read-limited /activities/update", false).getId();
//Should not delete this since it have one scope more /orcid-profile/read-limited
Long token5Id = createToken(CLIENT_ID_1, "token-5", USER_ORCID, new Date(System.currentTimeMillis() + 100000), "/orcid-profile/read-limited /activities/update /read-limited", false).getId();
//Should not delete this since it have one scope more /activities/read-limited
Long token6Id = createToken(CLIENT_ID_1, "token-6", USER_ORCID, new Date(System.currentTimeMillis() + 100000), "/read-limited /activities/update /activities/read-limited", false).getId();
//Should not delete this
Long token7Id = createToken(CLIENT_ID_1, "token-7", USER_ORCID, new Date(System.currentTimeMillis() + 100000), "/person/read-limited", false).getId();
//Should not delete this since it have several more scopes
Long token8Id = createToken(CLIENT_ID_1, "token-8", USER_ORCID, new Date(System.currentTimeMillis() + 100000), "/funding/read-limited /read-limited /activities/read-limited /orcid-works/create /affiliations/update /activities/update", false).getId();
//Should remove this since it contains the same scopes
//Delete
Long token9Id = createToken(CLIENT_ID_1, "token-9", USER_ORCID, new Date(System.currentTimeMillis() + 100000), "/activities/update /read-limited", false).getId();
List<OrcidOauth2TokenDetail> activeTokens = orcidOauth2TokenDetailService.findByUserName(USER_ORCID);
assertNotNull(activeTokens);
assertEquals(9, activeTokens.size());
orcidOauth2TokenDetailService.disableAccessToken(token1Id, USER_ORCID);
activeTokens = orcidOauth2TokenDetailService.findByUserName(USER_ORCID);
assertEquals(6, activeTokens.size());
for (OrcidOauth2TokenDetail token : activeTokens) {
assertThat(token.getId(), allOf(not(token1Id), not(token4Id), not(token9Id)));
assertThat(token.getId(), anyOf(is(token2Id), is(token3Id), is(token5Id), is(token6Id), is(token7Id), is(token8Id)));
}
}
use of org.springframework.test.annotation.Rollback in project ORCID-Source by ORCID.
the class OrcidOauth2TokenDetailServiceTest method dontGetExpiredTokensTest.
@Test
@Transactional
@Rollback
public void dontGetExpiredTokensTest() {
//Token # 1: expired
createToken(CLIENT_ID_1, "expired-1", USER_ORCID, new Date(System.currentTimeMillis() - 1000), "/read-limited", false);
//Token # 2: /activities/update
createToken(CLIENT_ID_1, "active-1", USER_ORCID, new Date(System.currentTimeMillis() + 100000), "/activities/update", false);
//Token # 3: disabled
createToken(CLIENT_ID_1, "disabled-1", USER_ORCID, new Date(System.currentTimeMillis() + 100000), "/activities/update", true);
//Token # 4: /read-limited
createToken(CLIENT_ID_1, "active-2", USER_ORCID, new Date(System.currentTimeMillis() + 100000), "/read-limited", false);
//Fetch all active tokens
List<OrcidOauth2TokenDetail> activeTokens = orcidOauth2TokenDetailService.findByUserName(USER_ORCID);
assertNotNull(activeTokens);
assertEquals(2, activeTokens.size());
assertThat(activeTokens.get(0).getScope(), anyOf(is("/activities/update"), is("/read-limited")));
assertThat(activeTokens.get(1).getScope(), anyOf(is("/activities/update"), is("/read-limited")));
//Find the id of the token with scope '/activities/update' and disable that token
Long tokenToDisableId = null;
for (OrcidOauth2TokenDetail token : activeTokens) {
if ("/activities/update".equals(token.getScope())) {
tokenToDisableId = token.getId();
break;
}
}
assertNotNull(tokenToDisableId);
//Disable that access token
orcidOauth2TokenDetailService.disableAccessToken(tokenToDisableId, USER_ORCID);
//Fetch the active tokens again, it should contain just one
activeTokens = orcidOauth2TokenDetailService.findByUserName(USER_ORCID);
assertNotNull(activeTokens);
assertEquals(1, activeTokens.size());
assertEquals("/read-limited", activeTokens.get(0).getScope());
assertEquals("active-2", activeTokens.get(0).getTokenValue());
}
Aggregations