use of io.gravitee.definition.model.VirtualHost in project gravitee-management-rest-api by gravitee-io.
the class VirtualHostServiceTest method shouldFail_create_existingPath_trailingSlash.
@Test(expected = ApiContextPathAlreadyExistsException.class)
public void shouldFail_create_existingPath_trailingSlash() {
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 VirtualHostServiceImpl method validateDomainRestrictions.
private void validateDomainRestrictions(Collection<VirtualHost> virtualHosts) {
final EnvironmentEntity currentEnv = environmentService.findById(GraviteeContext.getCurrentEnvironment());
final List<String> domainRestrictions = currentEnv.getDomainRestrictions();
if (domainRestrictions != null && !domainRestrictions.isEmpty()) {
for (VirtualHost vHost : virtualHosts) {
String host = vHost.getHost();
if (!StringUtils.isEmpty(host)) {
String hostWithoutPort = host.split(":")[0];
if (!isValidDomainOrSubDomain(hostWithoutPort, domainRestrictions)) {
throw new InvalidVirtualHostException(hostWithoutPort, domainRestrictions);
}
} else {
vHost.setHost(domainRestrictions.get(0));
}
}
}
}
use of io.gravitee.definition.model.VirtualHost in project gravitee-management-rest-api by gravitee-io.
the class ApiResource method filterSensitiveData.
private void filterSensitiveData(ApiEntity entity) {
final Proxy filteredProxy = new Proxy();
final VirtualHost virtualHost = entity.getProxy().getVirtualHosts().get(0);
virtualHost.setHost(null);
filteredProxy.setVirtualHosts(singletonList(virtualHost));
entity.setProxy(filteredProxy);
entity.setPaths(null);
entity.setProperties(null);
entity.setServices(null);
entity.setResources(null);
entity.setPathMappings(null);
entity.setResponseTemplates(null);
}
use of io.gravitee.definition.model.VirtualHost in project gravitee-management-rest-api by gravitee-io.
the class ApiResourceNotAdminTest method init.
@Before
public void init() {
mockApi = new ApiEntity();
mockApi.setId(API);
mockApi.setName(API);
Proxy proxy = new Proxy();
proxy.setVirtualHosts(Collections.singletonList(new VirtualHost("/test")));
mockApi.setProxy(proxy);
mockApi.setUpdatedAt(new Date());
doReturn(mockApi).when(apiService).findById(API);
}
use of io.gravitee.definition.model.VirtualHost in project gravitee-management-rest-api by gravitee-io.
the class ApiResourceTest method init.
@Before
public void init() {
reset(apiService);
mockApi = new ApiEntity();
mockApi.setId(API);
mockApi.setName(API);
Proxy proxy = new Proxy();
proxy.setVirtualHosts(Collections.singletonList(new VirtualHost("/test")));
mockApi.setProxy(proxy);
mockApi.setUpdatedAt(new Date());
doReturn(mockApi).when(apiService).findById(API);
doThrow(ApiNotFoundException.class).when(apiService).findById(UNKNOWN_API);
updateApiEntity = new UpdateApiEntity();
updateApiEntity.setDescription("toto");
updateApiEntity.setVisibility(Visibility.PUBLIC);
updateApiEntity.setName(API);
updateApiEntity.setVersion("v1");
proxy = new Proxy();
proxy.setVirtualHosts(Collections.singletonList(new VirtualHost("/test")));
updateApiEntity.setProxy(proxy);
updateApiEntity.setLifecycleState(ApiLifecycleState.CREATED);
doReturn(mockApi).when(apiService).update(eq(API), any(), eq(true));
}
Aggregations