use of org.springframework.test.annotation.Rollback in project ORCID-Source by ORCID.
the class DefaultPermissionCheckerTest method testCheckUserPermissionsAuthenticationScopesOrcidAndOrcidMessageWhenWrongUser.
@Test(expected = AccessControlException.class)
@Transactional
@Rollback
public void testCheckUserPermissionsAuthenticationScopesOrcidAndOrcidMessageWhenWrongUser() throws Exception {
Set<String> resourceIds = new HashSet<String>(Arrays.asList("orcid"));
HashSet<GrantedAuthority> grantedAuthorities = new HashSet<GrantedAuthority>(Arrays.asList(new SimpleGrantedAuthority("ROLE_CLIENT")));
AuthorizationRequest request = new AuthorizationRequest("4444-4444-4444-4441", Arrays.asList("/orcid-bio/external-identifiers/create"));
request.setAuthorities(grantedAuthorities);
request.setResourceIds(resourceIds);
ProfileEntity entity = profileEntityManager.findByOrcid("4444-4444-4444-4445");
OrcidOauth2UserAuthentication oauth2UserAuthentication = new OrcidOauth2UserAuthentication(entity, true);
OAuth2Authentication oAuth2Authentication = new OrcidOAuth2Authentication(request, oauth2UserAuthentication, "made-up-token");
ScopePathType requiredScope = ScopePathType.ORCID_BIO_EXTERNAL_IDENTIFIERS_CREATE;
OrcidMessage orcidMessage = getOrcidMessage();
String messageOrcid = orcidMessage.getOrcidProfile().getOrcidIdentifier().getPath();
defaultPermissionChecker.checkPermissions(oAuth2Authentication, requiredScope, messageOrcid, orcidMessage);
}
use of org.springframework.test.annotation.Rollback in project ORCID-Source by ORCID.
the class DefaultPermissionCheckerTest method checkRemoveUserGrantWriteScopePastValitityForPersistentTokens.
@Test
@Transactional
@Rollback
public void checkRemoveUserGrantWriteScopePastValitityForPersistentTokens() {
OrcidOauth2TokenDetail token = tokenDetailService.findIgnoringDisabledByTokenValue("00000002-d80f-4afc-8f95-9b48d28aaadb");
DefaultPermissionChecker customPermissionChecker = (DefaultPermissionChecker) defaultPermissionChecker;
if (customPermissionChecker.removeUserGrantWriteScopePastValitity(token))
fail();
}
use of org.springframework.test.annotation.Rollback in project ORCID-Source by ORCID.
the class WorkDaoTest method testAddWork.
@Test
@Rollback(true)
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void testAddWork() {
String title = "New Work";
String subtitle = "Subtitle";
String citation = "Test citation";
String description = "Description for new work";
String url = "http://work.com";
WorkEntity work = new WorkEntity();
work.setCitation(citation);
work.setCitationType(CitationType.FORMATTED_UNSPECIFIED);
work.setDescription(description);
work.setTitle(title);
work.setSubtitle(subtitle);
work.setWorkType(WorkType.BOOK);
work.setWorkUrl(url);
ProfileEntity profile = new ProfileEntity(USER_ORCID);
work.setProfile(profile);
work.setSourceId(USER_ORCID);
work.setAddedToProfileDate(new Date());
assertNull(work.getId());
try {
work = workDao.addWork(work);
} catch (Exception e) {
fail();
}
assertNotNull(work.getId());
}
use of org.springframework.test.annotation.Rollback in project ORCID-Source by ORCID.
the class OrcidIndexManagerImplTest method checkSubtitlesPersisted.
@Test
@Rollback
public void checkSubtitlesPersisted() throws Exception {
OrcidProfile subtitledWorksProfile = getOrcidWithSubtitledWork();
OrcidSolrDocument standardWorkListing = solrDocWithAdditionalSubtitles();
orcidIndexManager.persistProfileInformationForIndexing(subtitledWorksProfile);
verify(solrDao).persist(eq(standardWorkListing));
}
use of org.springframework.test.annotation.Rollback in project ORCID-Source by ORCID.
the class AuthenticationManagerTest method testSuccessfullAuthentication.
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW)
@Rollback(true)
public void testSuccessfullAuthentication() {
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken("spike@milligan.com", "password");
Authentication authentication = authenticationManager.authenticate(token);
assertNotNull(authentication);
Collection<? extends GrantedAuthority> authorities = authentication.getAuthorities();
assertEquals(1, authorities.size());
}
Aggregations