use of io.gravitee.definition.model.VirtualHost in project gravitee-management-rest-api by gravitee-io.
the class VirtualHostServiceTest method shouldSucceed_create_sameVirtualHostAndSamePath.
@Test(expected = ApiContextPathAlreadyExistsException.class)
public void shouldSucceed_create_sameVirtualHostAndSamePath() {
Api api1 = createMock("mock1", "/context", "api.gravitee.io");
when(apiRepository.search(null)).thenReturn(Collections.singletonList(api1));
virtualHostService.sanitizeAndValidate(Collections.singletonList(new VirtualHost("api.gravitee.io", "/context")));
}
use of io.gravitee.definition.model.VirtualHost in project gravitee-management-rest-api by gravitee-io.
the class VirtualHostServiceTest method shouldSucceed_create_sameVirtualHostAndSameSubPath.
@Test(expected = ApiContextPathAlreadyExistsException.class)
public void shouldSucceed_create_sameVirtualHostAndSameSubPath() {
Api api1 = createMock("mock1", "/context", "api.gravitee.io");
when(apiRepository.search(null)).thenReturn(Collections.singletonList(api1));
virtualHostService.sanitizeAndValidate(Collections.singletonList(new VirtualHost("api.gravitee.io", "/context/subpath")));
}
use of io.gravitee.definition.model.VirtualHost in project gravitee-management-rest-api by gravitee-io.
the class VirtualHostServiceTest method shouldFail_create_existingPath_trailingSlash2.
@Test(expected = ApiContextPathAlreadyExistsException.class)
public void shouldFail_create_existingPath_trailingSlash2() {
Api api1 = createMock("mock1", "/context/");
when(apiRepository.search(null)).thenReturn(Collections.singletonList(api1));
virtualHostService.sanitizeAndValidate(Collections.singletonList(new VirtualHost("/context")));
}
use of io.gravitee.definition.model.VirtualHost in project gravitee-management-rest-api by gravitee-io.
the class VirtualHostServiceTest method validate_notASubDomain.
@Test(expected = InvalidVirtualHostException.class)
public void validate_notASubDomain() {
VirtualHost vhost = getValidVirtualHost();
EnvironmentEntity environmentEntity = new EnvironmentEntity();
environmentEntity.setDomainRestrictions(Arrays.asList("test.gravitee.io", "other.gravitee.io"));
when(environmentService.findById(any())).thenReturn(environmentEntity);
virtualHostService.sanitizeAndValidate(Collections.singletonList(vhost));
}
use of io.gravitee.definition.model.VirtualHost in project gravitee-management-rest-api by gravitee-io.
the class SwaggerService_CreateAPITest method validateExtensions.
private void validateExtensions(UpdateApiEntity updateApiEntity) {
final List<VirtualHost> virtualHosts = updateApiEntity.getProxy().getVirtualHosts();
assertEquals(1, virtualHosts.size());
VirtualHost vHost = virtualHosts.get(0);
assertEquals("myHost", vHost.getHost());
assertEquals("myPath", vHost.getPath());
assertEquals(false, vHost.isOverrideEntrypoint());
final Set<String> categories = updateApiEntity.getCategories();
assertEquals(2, categories.size());
assertTrue(categories.containsAll(asList("cat1", "cat2")));
final Set<String> groups = updateApiEntity.getGroups();
assertEquals(2, groups.size());
assertTrue(groups.containsAll(asList("group1", "group2")));
final List<String> labels = updateApiEntity.getLabels();
assertEquals(2, labels.size());
assertTrue(labels.containsAll(asList("label1", "label2")));
final Set<String> tags = updateApiEntity.getTags();
assertEquals(2, tags.size());
assertTrue(tags.containsAll(asList("tagId1", "tagId2")));
final Map<String, String> properties = updateApiEntity.getProperties().getValues();
assertEquals(2, properties.size());
assertTrue(properties.keySet().containsAll(asList("prop1", "prop2")));
assertTrue(properties.values().containsAll(asList("propValue1", "propValue2")));
final Map<String, String> metadata = updateApiEntity.getMetadata().stream().collect(Collectors.toMap(ApiMetadataEntity::getName, ApiMetadataEntity::getValue));
assertEquals(2, metadata.size());
assertTrue(metadata.keySet().containsAll(asList("meta1", "meta2")));
assertTrue(metadata.values().containsAll(asList("1234", "metaValue2")));
assertEquals(Visibility.PRIVATE, updateApiEntity.getVisibility());
assertEquals("data:image/png;base64,XXXXXXX", updateApiEntity.getPicture());
}
Aggregations