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));
}
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());
}
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);
}
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());
}
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;
}
Aggregations