Search in sources :

Example 6 with VirtualHost

use of io.gravitee.definition.model.VirtualHost in project gravitee-management-rest-api by gravitee-io.

the class VirtualHostServiceTest method shouldFail_create_sameBasePath2.

@Test
public void shouldFail_create_sameBasePath2() {
    Api api1 = createMock("mock1", "/context");
    when(apiRepository.search(null)).thenReturn(Collections.singletonList(api1));
    virtualHostService.sanitizeAndValidate(Collections.singletonList(new VirtualHost("/context2")));
}
Also used : Api(io.gravitee.repository.management.model.Api) VirtualHost(io.gravitee.definition.model.VirtualHost) Test(org.junit.Test)

Example 7 with VirtualHost

use of io.gravitee.definition.model.VirtualHost in project gravitee-management-rest-api by gravitee-io.

the class VirtualHostServiceTest method shouldFail_create_sameBasePath.

@Test
public void shouldFail_create_sameBasePath() {
    Api api1 = createMock("mock1", "/context2");
    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 8 with VirtualHost

use of io.gravitee.definition.model.VirtualHost in project gravitee-management-rest-api by gravitee-io.

the class VirtualHostServiceTest method validate_hostSubDomainOfOneOfDomainConstraints.

@Test
public void validate_hostSubDomainOfOneOfDomainConstraints() {
    VirtualHost vhost = getValidVirtualHost();
    String domainConstraint = vhost.getHost();
    vhost.setHost("level2.level1." + domainConstraint);
    EnvironmentEntity environmentEntity = new EnvironmentEntity();
    environmentEntity.setDomainRestrictions(Arrays.asList("test.gravitee.io", "other.gravitee.io", domainConstraint));
    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 9 with VirtualHost

use of io.gravitee.definition.model.VirtualHost in project gravitee-management-rest-api by gravitee-io.

the class VirtualHostServiceTest method validate_hostEqualsToDomainConstraint.

@Test
public void validate_hostEqualsToDomainConstraint() {
    VirtualHost vhost = getValidVirtualHost();
    EnvironmentEntity environmentEntity = new EnvironmentEntity();
    environmentEntity.setDomainRestrictions(Collections.singletonList(vhost.getHost()));
    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 10 with VirtualHost

use of io.gravitee.definition.model.VirtualHost in project gravitee-management-rest-api by gravitee-io.

the class VirtualHostServiceTest method shouldSucceed_create_noMatchingPath.

@Test
public void shouldSucceed_create_noMatchingPath() {
    Api api1 = createMock("mock1", "/existing");
    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)

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