use of org.springframework.test.annotation.Rollback in project ORCID-Source by ORCID.
the class OrcidIndexManagerImplTest method onlyDoiPersistedFromOrcidWorks.
@Test
@Rollback
public void onlyDoiPersistedFromOrcidWorks() {
OrcidProfile orcidProfileWithDOI = getStandardOrcidWithDoiInformation();
OrcidSolrDocument doiListings = solrDocumentLimitedtoVisibleDoi();
// check that the limited profiles or non doi identifiers aren't
// included
orcidIndexManager.persistProfileInformationForIndexing(orcidProfileWithDOI);
verify(solrDao).persist(eq(doiListings));
// now check null values aren't persisted when either the type or value
// are missing
OrcidWork orcidWork1 = orcidProfileWithDOI.retrieveOrcidWorks().getOrcidWork().get(0);
orcidWork1.getWorkExternalIdentifiers().getWorkExternalIdentifier().get(0).setWorkExternalIdentifierType(null);
OrcidWork orcidWork2 = orcidProfileWithDOI.retrieveOrcidWorks().getOrcidWork().get(1);
orcidWork2.getWorkExternalIdentifiers().getWorkExternalIdentifier().get(0).setWorkExternalIdentifierId(null);
// so this should leave only the second doi
doiListings.setDigitalObjectIds(Arrays.asList(new String[] { "work2-doi2" }));
OrcidMessage orcidMessage = createFilteredOrcidMessage(orcidProfileWithDOI);
doiListings.setPublicProfileMessage(orcidMessage.toString());
orcidIndexManager.persistProfileInformationForIndexing(orcidProfileWithDOI);
verify(solrDao).persist(eq(doiListings));
}
use of org.springframework.test.annotation.Rollback in project ORCID-Source by ORCID.
the class ClientDetailsManagerTest method testCreateClientDetailsWithNonExistentOrcid.
@Test(expected = IllegalArgumentException.class)
@Rollback
@Transactional
public void testCreateClientDetailsWithNonExistentOrcid() throws Exception {
Set<String> clientScopes = new HashSet<String>();
clientScopes.add("/orcid-profile/create");
Set<String> clientResourceIds = new HashSet<String>();
clientResourceIds.add("orcid-t2-api");
Set<String> clientAuthorizedGrantTypes = new HashSet<String>();
clientAuthorizedGrantTypes.add("client_credentials");
clientAuthorizedGrantTypes.add("authorization_code");
clientAuthorizedGrantTypes.add("refresh_token");
Set<RedirectUri> clientRegisteredRedirectUris = new HashSet<RedirectUri>();
clientRegisteredRedirectUris.add(new RedirectUri("http://www.google.com/"));
List<String> clientGrantedAuthorities = new ArrayList<String>();
clientGrantedAuthorities.add("ROLE_ADMIN");
clientDetailsManager.createClientDetails("8888-9999-9999-9999", CLIENT_NAME, CLIENT_DESCRIPTION, null, CLIENT_WEBSITE, ClientType.CREATOR, clientScopes, clientResourceIds, clientAuthorizedGrantTypes, clientRegisteredRedirectUris, clientGrantedAuthorities, true);
}
use of org.springframework.test.annotation.Rollback in project ORCID-Source by ORCID.
the class OrcidAuthorizationCodeServiceTest method testCreateAuthorizationCodeWithValidClient.
@Test
@Rollback
@Transactional
public void testCreateAuthorizationCodeWithValidClient() {
AuthorizationRequest request = getAuthorizationRequest("4444-4444-4444-4441");
OAuth2Authentication oauth2Authentication = new OAuth2Authentication(oAuth2RequestFactory.createOAuth2Request(request), getUserAuthentication());
String authorizationCode = authorizationCodeServices.createAuthorizationCode(oauth2Authentication);
assertNotNull(authorizationCode);
oauth2Authentication = authorizationCodeServices.consumeAuthorizationCode(authorizationCode);
assertNotNull(oauth2Authentication);
}
use of org.springframework.test.annotation.Rollback in project ORCID-Source by ORCID.
the class OrcidAuthorizationCodeServiceTest method testCreateAuthorizationCodeWithInvalidClient.
@Test(expected = InvalidClientException.class)
@Rollback
@Transactional
public void testCreateAuthorizationCodeWithInvalidClient() {
AuthorizationRequest request = getAuthorizationRequest("6444-4444-4444-4441");
OAuth2Authentication auth = new OAuth2Authentication(oAuth2RequestFactory.createOAuth2Request(request), getUserAuthentication());
authorizationCodeServices.createAuthorizationCode(auth);
}
use of org.springframework.test.annotation.Rollback in project ORCID-Source by ORCID.
the class DefaultOAuthClientVisibilityTest method testCheckClientPermissionsAllowOnlyPublicAndLimitedVisibility.
@Test
@Transactional
@Rollback
public void testCheckClientPermissionsAllowOnlyPublicAndLimitedVisibility() 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-4446", Arrays.asList("/orcid-bio/external-identifiers/create"));
request.setAuthorities(grantedAuthorities);
request.setResourceIds(resourceIds);
ProfileEntity entity = new ProfileEntity("4444-4444-4444-4446");
OrcidOauth2UserAuthentication oauth2UserAuthentication = new OrcidOauth2UserAuthentication(entity, true);
// we care only that an OAuth client request results in the correct
// visibilities
OrcidOAuth2Authentication oAuth2Authentication = new OrcidOAuth2Authentication(request, oauth2UserAuthentication, "made-up-token");
OrcidOauth2TokenDetail tokenDetail = new OrcidOauth2TokenDetail();
tokenDetail.setScope("/orcid-bio/external-identifiers/create");
tokenDetail.setDateCreated(new Date());
when(orcidOauth2TokenDetailService.findNonDisabledByTokenValue(any(String.class))).thenReturn(tokenDetail);
ScopePathType scopePathType = ScopePathType.ORCID_BIO_EXTERNAL_IDENTIFIERS_CREATE;
Set<Visibility> visibilitiesForClient = permissionChecker.obtainVisibilitiesForAuthentication(oAuth2Authentication, scopePathType, getOrcidMessage());
assertTrue(visibilitiesForClient.size() == 3);
assertTrue(visibilitiesForClient.contains(Visibility.LIMITED));
assertTrue(visibilitiesForClient.contains(Visibility.REGISTERED_ONLY));
assertTrue(visibilitiesForClient.contains(Visibility.PUBLIC));
}
Aggregations