use of com.sequenceiq.cloudbreak.common.model.user.IdentityUser in project cloudbreak by hortonworks.
the class CachedUserDetailsService method createIdentityUser.
private IdentityUser createIdentityUser(List<IdentityUserRole> roles, String account, JsonNode userNode) {
String userId = userNode.get("id").asText();
String email = userNode.get("userName").asText();
String givenName = getGivenName(userNode);
String familyName = getFamilyName(userNode);
String dateOfCreation = userNode.get("meta").get("created").asText();
Date created = parseUserCreated(dateOfCreation);
account = StringUtils.isEmpty(account) ? userId : account;
return new IdentityUser(userId, email, account, roles, givenName, familyName, created);
}
use of com.sequenceiq.cloudbreak.common.model.user.IdentityUser in project cloudbreak by hortonworks.
the class AccountPreferencesValidatorTest method testValidateShouldThrowExceptionWhenTheUserDemoTimeExpired.
@Test
public void testValidateShouldThrowExceptionWhenTheUserDemoTimeExpired() throws AccountPreferencesValidationException {
Calendar calendar = Calendar.getInstance();
calendar.roll(Calendar.HOUR_OF_DAY, -1);
when(preferences.getUserTimeToLive()).thenReturn(40000L);
IdentityUser identityUser = Mockito.mock(IdentityUser.class);
when(userDetailsService.getDetails(anyString(), any(UserFilterField.class))).thenReturn(identityUser);
when(identityUser.getCreated()).thenReturn(calendar.getTime());
thrown.expect(AccountPreferencesValidationException.class);
thrown.expectMessage("The user demo time is expired!");
underTest.validate(stack, EMPTY_STRING, EMPTY_STRING);
}
use of com.sequenceiq.cloudbreak.common.model.user.IdentityUser in project cloudbreak by hortonworks.
the class CredentialServiceTest method testRetrieveAccountCredentialsWhenUserIsNotAdmin.
@Test
public void testRetrieveAccountCredentialsWhenUserIsNotAdmin() {
IdentityUser user = mock(IdentityUser.class);
Set<String> platforms = Sets.newHashSet("AWS");
Credential credential = new Credential();
credential.setCloudPlatform("AWS");
when(user.getRoles()).thenReturn(Collections.singletonList(IdentityUserRole.fromString("USER")));
when(user.getAccount()).thenReturn("account");
when(user.getUserId()).thenReturn("userId");
when(accountPreferencesService.enabledPlatforms()).thenReturn(platforms);
when(credentialRepository.findPublicInAccountForUserFilterByPlatforms("userId", "account", platforms)).thenReturn(Sets.newHashSet(credential));
Set<Credential> actual = credentialService.retrieveAccountCredentials(user);
assertEquals("AWS", actual.stream().findFirst().get().cloudPlatform());
verify(credentialRepository, times(1)).findPublicInAccountForUserFilterByPlatforms("userId", "account", platforms);
}
use of com.sequenceiq.cloudbreak.common.model.user.IdentityUser in project cloudbreak by hortonworks.
the class ClusterProxyDecoratorTest method setUp.
@Before
public void setUp() {
when(mapper.mapRequestToEntity(any(ProxyConfigRequest.class), anyBoolean())).thenReturn(new ProxyConfig());
when(service.create(any(IdentityUser.class), any(ProxyConfig.class))).thenReturn(new ProxyConfig());
when(service.getPublicProxyConfig(anyString(), eq(identityUser))).thenReturn(new ProxyConfig());
cluster = new Cluster();
stack.setPublicInAccount(true);
}
use of com.sequenceiq.cloudbreak.common.model.user.IdentityUser in project cloudbreak by hortonworks.
the class ClusterProxyDecoratorTest method testNothingProvided.
@Test
public void testNothingProvided() {
Cluster result = clusterProxyDecorator.prepareProxyConfig(cluster, identityUser, null, stack);
assertNull(result.getProxyConfig());
Mockito.verify(service, Mockito.times(0)).create(any(IdentityUser.class), any(ProxyConfig.class));
Mockito.verify(service, Mockito.times(0)).getPublicProxyConfig(anyString(), eq(identityUser));
}
Aggregations