Search in sources :

Example 46 with IdentityUser

use of com.sequenceiq.cloudbreak.common.model.user.IdentityUser in project cloudbreak by hortonworks.

the class OwnerBasedPermissionEvaluatorTest method testWriteOwner.

@Test
public void testWriteOwner() {
    when(oauth.getUserAuthentication()).thenReturn(new TestingAuthenticationToken("principal", "credential"));
    IdentityUser user = new IdentityUser("userid", "", "", Collections.emptyList(), "", "", null);
    when(userDetailsService.getDetails(anyString(), any(UserFilterField.class))).thenReturn(user);
    boolean result = underTest.hasPermission(oauth, stack, "write");
    Assert.assertTrue(result);
}
Also used : IdentityUser(com.sequenceiq.cloudbreak.common.model.user.IdentityUser) UserFilterField(com.sequenceiq.cloudbreak.common.service.user.UserFilterField) TestingAuthenticationToken(org.springframework.security.authentication.TestingAuthenticationToken) Test(org.junit.Test)

Example 47 with IdentityUser

use of com.sequenceiq.cloudbreak.common.model.user.IdentityUser in project cloudbreak by hortonworks.

the class OwnerBasedPermissionEvaluatorTest method testReadNotOwnerNotAdminNotAccountButPublicInAccount.

@Test
public void testReadNotOwnerNotAdminNotAccountButPublicInAccount() {
    when(oauth.getUserAuthentication()).thenReturn(new TestingAuthenticationToken("principal", "credential"));
    IdentityUser user = new IdentityUser("admin", "", "test-account", Collections.emptyList(), "", "", null);
    when(userDetailsService.getDetails(anyString(), any(UserFilterField.class))).thenReturn(user);
    stack.setPublicInAccount(true);
    boolean result = underTest.hasPermission(oauth, stack, "read");
    Assert.assertFalse(result);
}
Also used : IdentityUser(com.sequenceiq.cloudbreak.common.model.user.IdentityUser) UserFilterField(com.sequenceiq.cloudbreak.common.service.user.UserFilterField) TestingAuthenticationToken(org.springframework.security.authentication.TestingAuthenticationToken) Test(org.junit.Test)

Example 48 with IdentityUser

use of com.sequenceiq.cloudbreak.common.model.user.IdentityUser in project cloudbreak by hortonworks.

the class SmartSenseSubscriptionController method createSmartSenseSubscription.

private SmartSenseSubscriptionJson createSmartSenseSubscription(SmartSenseSubscriptionJson json, boolean publicInAccount) {
    IdentityUser identityUser = authenticatedUserService.getCbUser();
    SmartSenseSubscription subscription = toSmartSenseSubscriptionConverter.convert(json);
    subscription.setAccount(identityUser.getAccount());
    subscription.setOwner(identityUser.getUserId());
    subscription.setPublicInAccount(publicInAccount);
    subscription = smartSenseSubService.create(subscription);
    return toJsonConverter.convert(subscription);
}
Also used : IdentityUser(com.sequenceiq.cloudbreak.common.model.user.IdentityUser) SmartSenseSubscription(com.sequenceiq.cloudbreak.domain.SmartSenseSubscription)

Example 49 with IdentityUser

use of com.sequenceiq.cloudbreak.common.model.user.IdentityUser in project cloudbreak by hortonworks.

the class SmartSenseSubscriptionController method deletePrivate.

@Override
public void deletePrivate(String subscriptionId) {
    IdentityUser cbUser = authenticatedUserService.getCbUser();
    smartSenseSubService.delete(subscriptionId, cbUser);
}
Also used : IdentityUser(com.sequenceiq.cloudbreak.common.model.user.IdentityUser)

Example 50 with IdentityUser

use of com.sequenceiq.cloudbreak.common.model.user.IdentityUser in project cloudbreak by hortonworks.

the class StackCommonService method deletePublic.

@Override
public void deletePublic(String name, Boolean forced, Boolean deleteDependencies) {
    IdentityUser user = authenticatedUserService.getCbUser();
    stackService.delete(name, user, forced, deleteDependencies);
}
Also used : IdentityUser(com.sequenceiq.cloudbreak.common.model.user.IdentityUser)

Aggregations

IdentityUser (com.sequenceiq.cloudbreak.common.model.user.IdentityUser)133 Test (org.junit.Test)14 Stack (com.sequenceiq.cloudbreak.domain.Stack)13 UserFilterField (com.sequenceiq.cloudbreak.common.service.user.UserFilterField)9 Async (org.springframework.scheduling.annotation.Async)9 Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)8 Credential (com.sequenceiq.cloudbreak.domain.Credential)8 FlexSubscription (com.sequenceiq.cloudbreak.domain.FlexSubscription)8 Cluster (com.sequenceiq.cloudbreak.domain.Cluster)7 LdapConfig (com.sequenceiq.cloudbreak.domain.LdapConfig)7 ProxyConfig (com.sequenceiq.cloudbreak.domain.ProxyConfig)7 ImageCatalog (com.sequenceiq.cloudbreak.domain.ImageCatalog)6 RDSConfig (com.sequenceiq.cloudbreak.domain.RDSConfig)6 Before (org.junit.Before)6 TestingAuthenticationToken (org.springframework.security.authentication.TestingAuthenticationToken)6 UpdateStackJson (com.sequenceiq.cloudbreak.api.model.UpdateStackJson)5 Template (com.sequenceiq.cloudbreak.domain.Template)5 ConstraintTemplate (com.sequenceiq.cloudbreak.domain.ConstraintTemplate)4 Network (com.sequenceiq.cloudbreak.domain.Network)4 Recipe (com.sequenceiq.cloudbreak.domain.Recipe)4