use of org.oxauth.persistence.model.Scope in project oxAuth by GluuFederation.
the class ScopeServiceTest method getClaims_ScopeClaimsEmpty_NotProcessed.
@Test
public void getClaims_ScopeClaimsEmpty_NotProcessed() throws Exception {
User user = new User();
Scope scope = new Scope();
scope.setOxAuthClaims(Lists.newArrayList());
Map<String, Object> result = scopeService.getClaims(user, scope);
assertNotNull(result);
assertEquals(result.size(), 0);
verify(log, never()).trace(startsWith("No claims set for scope:"));
verifyNoMoreInteractions(log);
verifyNoMoreInteractions(attributeService);
}
use of org.oxauth.persistence.model.Scope in project oxAuth by GluuFederation.
the class ScopeServiceTest method getClaims_AllFieldsSet_ClaimsReturned.
@Test
public void getClaims_AllFieldsSet_ClaimsReturned() throws Exception {
final Date createdAndUpdatedAt = new Date();
final String userId = UUID.randomUUID().toString();
User user = buildRegularUser(userId, createdAndUpdatedAt, createdAndUpdatedAt);
Scope scope = new Scope();
scope.setOxAuthClaims(Lists.newArrayList("uid", "updatedAt", "createdAt", "emailVerified", "lastLogon", "metadata"));
mockRegularGluuAttributesMapping();
when(ldapEntryManager.decodeTime(anyString(), anyString())).thenReturn(createdAndUpdatedAt);
Map<String, Object> result = scopeService.getClaims(user, scope);
assertNotNull(result);
assertEquals(result.size(), 6);
assertEquals(result.get("uid"), userId);
assertEquals(result.get("updated_at"), createdAndUpdatedAt);
assertEquals(result.get("created_at"), createdAndUpdatedAt);
assertEquals(result.get("email_verified"), true);
assertEquals(result.get("last_logon"), createdAndUpdatedAt);
assertEquals(result.get("metadata"), "{}");
verifyNoMoreInteractions(log);
verifyNoMoreInteractions(attributeService);
}
use of org.oxauth.persistence.model.Scope in project oxAuth by GluuFederation.
the class ScopeServiceTest method getClaims_GluuAttributeClaimNameBlank_EmptyResult.
@Test
public void getClaims_GluuAttributeClaimNameBlank_EmptyResult() throws Exception {
User user = new User();
Scope scope = new Scope();
scope.setOxAuthClaims(Lists.newArrayList("claim1", "claim2"));
when(attributeService.getAttributeByDn(anyString())).thenReturn(new GluuAttribute());
Map<String, Object> result = scopeService.getClaims(user, scope);
assertNotNull(result);
assertEquals(result.size(), 0);
verify(log, times(2)).error(startsWith("Failed to get claim because claim name is not set for attribute"), (Object) isNull());
verifyNoMoreInteractions(log);
verifyNoMoreInteractions(attributeService);
}
use of org.oxauth.persistence.model.Scope in project oxAuth by GluuFederation.
the class ScopeServiceTest method getClaims_RequestFieldThatDoesntExist_ShouldBeIgnored.
@Test
public void getClaims_RequestFieldThatDoesntExist_ShouldBeIgnored() throws Exception {
final String userId = UUID.randomUUID().toString();
final Date createdAndUpdatedAt = new Date();
User user = buildRegularUser(userId, createdAndUpdatedAt, createdAndUpdatedAt);
Scope scope = new Scope();
scope.setOxAuthClaims(Lists.newArrayList("uid", "updatedAt", "createdAt", "emailVerified", "lastLogon", "metadata", "tmp"));
mockRegularGluuAttributesMapping();
when(ldapEntryManager.decodeTime(anyString(), anyString())).thenReturn(createdAndUpdatedAt);
Map<String, Object> result = scopeService.getClaims(user, scope);
assertNotNull(result);
assertEquals(result.size(), 6);
assertEquals(result.get("uid"), userId);
assertEquals(result.get("updated_at"), createdAndUpdatedAt);
assertEquals(result.get("created_at"), createdAndUpdatedAt);
assertEquals(result.get("email_verified"), true);
assertEquals(result.get("last_logon"), createdAndUpdatedAt);
assertEquals(result.get("metadata"), "{}");
verifyNoMoreInteractions(log);
verifyNoMoreInteractions(attributeService);
}
use of org.oxauth.persistence.model.Scope in project oxAuth by GluuFederation.
the class ScopeServiceTest method getClaims_ScopeClaimsNull_NotProcessed.
@Test
public void getClaims_ScopeClaimsNull_NotProcessed() throws Exception {
User user = new User();
Scope scope = new Scope();
scope.setOxAuthClaims(null);
Map<String, Object> result = scopeService.getClaims(user, scope);
assertNotNull(result);
assertEquals(result.size(), 0);
verify(log).trace(startsWith("No claims set for scope:"), (Object) isNull());
verifyNoMoreInteractions(log);
verifyNoMoreInteractions(attributeService);
}
Aggregations