Search in sources :

Example 21 with VirtualHost

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")));
}
Also used : Api(io.gravitee.repository.management.model.Api) VirtualHost(io.gravitee.definition.model.VirtualHost) Test(org.junit.Test)

Example 22 with VirtualHost

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")));
}
Also used : Api(io.gravitee.repository.management.model.Api) VirtualHost(io.gravitee.definition.model.VirtualHost) Test(org.junit.Test)

Example 23 with VirtualHost

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")));
}
Also used : Api(io.gravitee.repository.management.model.Api) VirtualHost(io.gravitee.definition.model.VirtualHost) Test(org.junit.Test)

Example 24 with VirtualHost

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));
}
Also used : EnvironmentEntity(io.gravitee.rest.api.model.EnvironmentEntity) VirtualHost(io.gravitee.definition.model.VirtualHost) Test(org.junit.Test)

Example 25 with VirtualHost

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());
}
Also used : VirtualHost(io.gravitee.definition.model.VirtualHost) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString)

Aggregations

VirtualHost (io.gravitee.definition.model.VirtualHost)25 Test (org.junit.Test)17 Api (io.gravitee.repository.management.model.Api)10 Proxy (io.gravitee.definition.model.Proxy)7 EnvironmentEntity (io.gravitee.rest.api.model.EnvironmentEntity)6 ApiEntity (io.gravitee.rest.api.model.api.ApiEntity)6 UpdateApiEntity (io.gravitee.rest.api.model.api.UpdateApiEntity)3 Date (java.util.Date)3 PrimaryOwnerEntity (io.gravitee.rest.api.model.PrimaryOwnerEntity)2 UserEntity (io.gravitee.rest.api.model.UserEntity)2 Api (io.gravitee.rest.api.portal.rest.model.Api)2 RatingSummary (io.gravitee.rest.api.portal.rest.model.RatingSummary)2 Before (org.junit.Before)2 RatingSummaryEntity (io.gravitee.rest.api.model.RatingSummaryEntity)1 ApiEntrypointEntity (io.gravitee.rest.api.model.api.ApiEntrypointEntity)1 DuplicateApiEntity (io.gravitee.rest.api.model.api.DuplicateApiEntity)1 PageQuery (io.gravitee.rest.api.model.documentation.PageQuery)1 User (io.gravitee.rest.api.portal.rest.model.User)1 UuidString (io.gravitee.rest.api.service.common.UuidString)1 InvalidVirtualHostException (io.gravitee.rest.api.service.exceptions.InvalidVirtualHostException)1