Search in sources :

Example 6 with IdentityUser

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

the class ClusterProxyDecoratorTest method testProxyNameProvided.

@Test
public void testProxyNameProvided() {
    Cluster result = clusterProxyDecorator.prepareProxyConfig(cluster, identityUser, "test", stack);
    assertNotNull(result.getProxyConfig());
    Mockito.verify(service, Mockito.times(1)).getPublicProxyConfig(anyString(), eq(identityUser));
    Mockito.verify(service, Mockito.times(0)).create(any(IdentityUser.class), any(ProxyConfig.class));
}
Also used : IdentityUser(com.sequenceiq.cloudbreak.common.model.user.IdentityUser) Cluster(com.sequenceiq.cloudbreak.domain.Cluster) ProxyConfig(com.sequenceiq.cloudbreak.domain.ProxyConfig) Test(org.junit.Test)

Example 7 with IdentityUser

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

the class ImageCatalogServiceDefaultTest method beforeTest.

@Before
public void beforeTest() throws Exception {
    MockitoAnnotations.initMocks(this);
    String catalogJson = FileReaderUtils.readFileFromClasspath(catalogFile);
    CloudbreakImageCatalogV2 catalog = JsonUtil.readValue(catalogJson, CloudbreakImageCatalogV2.class);
    when(imageCatalogProvider.getImageCatalogV2("")).thenReturn(catalog);
    IdentityUser user = getIdentityUser();
    when(authenticatedUserService.getCbUser()).thenReturn(user);
    when(userProfileService.get(user.getAccount(), user.getUserId(), user.getUsername())).thenReturn(new UserProfile());
}
Also used : IdentityUser(com.sequenceiq.cloudbreak.common.model.user.IdentityUser) UserProfile(com.sequenceiq.cloudbreak.domain.UserProfile) CloudbreakImageCatalogV2(com.sequenceiq.cloudbreak.cloud.model.catalog.CloudbreakImageCatalogV2) Before(org.junit.Before)

Example 8 with IdentityUser

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

the class ImageCatalogServiceTest method beforeTest.

@Before
public void beforeTest() throws Exception {
    String catalogJson = FileReaderUtils.readFileFromClasspath("com/sequenceiq/cloudbreak/service/image/cb-image-catalog-v2.json");
    CloudbreakImageCatalogV2 catalog = JsonUtil.readValue(catalogJson, CloudbreakImageCatalogV2.class);
    when(imageCatalogProvider.getImageCatalogV2("")).thenReturn(catalog);
    IdentityUser user = getIdentityUser();
    when(authenticatedUserService.getCbUser()).thenReturn(user);
    constants.addAll(Collections.singletonList(new CloudConstant() {

        @Override
        public Platform platform() {
            return Platform.platform("AWS");
        }

        @Override
        public Variant variant() {
            return Variant.variant("AWS");
        }
    }));
    ReflectionTestUtils.setField(underTest, ImageCatalogService.class, "defaultCatalogUrl", "http://localhost/imagecatalog-url", null);
    ReflectionTestUtils.setField(underTest, ImageCatalogService.class, "cbVersion", "unspecified", null);
}
Also used : IdentityUser(com.sequenceiq.cloudbreak.common.model.user.IdentityUser) CloudbreakImageCatalogV2(com.sequenceiq.cloudbreak.cloud.model.catalog.CloudbreakImageCatalogV2) CloudConstant(com.sequenceiq.cloudbreak.cloud.CloudConstant) Before(org.junit.Before)

Example 9 with IdentityUser

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

the class ImageCatalogServiceTest method testDeleteImageCatalog.

@Test
public void testDeleteImageCatalog() {
    String name = "img-name";
    IdentityUser user = getIdentityUser();
    UserProfile userProfile = new UserProfile();
    ImageCatalog imageCatalog = new ImageCatalog();
    imageCatalog.setImageCatalogName(name);
    imageCatalog.setArchived(false);
    when(authenticatedUserService.getCbUser()).thenReturn(user);
    when(imageCatalogRepository.findByName(name, user.getUserId(), user.getAccount())).thenReturn(imageCatalog);
    when(userProfileService.get(user.getAccount(), user.getUserId(), user.getUsername())).thenReturn(userProfile);
    underTest.delete(name);
    verify(imageCatalogRepository, times(1)).save(imageCatalog);
    Assert.assertTrue(imageCatalog.isArchived());
    Assert.assertTrue(imageCatalog.getImageCatalogName().startsWith(name) && imageCatalog.getImageCatalogName().indexOf("_") == name.length());
}
Also used : IdentityUser(com.sequenceiq.cloudbreak.common.model.user.IdentityUser) UserProfile(com.sequenceiq.cloudbreak.domain.UserProfile) ImageCatalog(com.sequenceiq.cloudbreak.domain.ImageCatalog) Test(org.junit.Test)

Example 10 with IdentityUser

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

the class ControllerLogContextAspects method getMDCParams.

private Map<String, String> getMDCParams(Object target, String[] paramNames, Object[] args) {
    Map<String, String> result = Maps.newHashMap();
    for (int i = 0; i < paramNames.length; i++) {
        String paramName = paramNames[i].toLowerCase();
        Object paramValue = args[i];
        String paramString = paramValue != null ? paramValue.toString() : "";
        if (paramName.contains("name")) {
            result.put(LoggerContextKey.RESOURCE_NAME.toString(), paramString);
        } else if (paramName.contains("id")) {
            result.put(LoggerContextKey.RESOURCE_ID.toString(), paramString);
        } else if (paramName.contains("request")) {
            result.put(LoggerContextKey.RESOURCE_NAME.toString(), MDCBuilder.getFieldValue(paramValue, "name"));
        }
    }
    String controllerClassName = target.getClass().getSimpleName();
    String resourceType = controllerClassName.substring(0, controllerClassName.indexOf("Controller"));
    result.put(LoggerContextKey.RESOURCE_TYPE.toString(), resourceType);
    IdentityUser cbUser = authenticatedUserService.getCbUser();
    result.put(LoggerContextKey.OWNER_ID.toString(), cbUser != null ? cbUser.getUserId() : "undefined");
    return result;
}
Also used : IdentityUser(com.sequenceiq.cloudbreak.common.model.user.IdentityUser) JoinPoint(org.aspectj.lang.JoinPoint)

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