use of com.yahoo.vespa.hosted.controller.restapi.ContainerControllerTester in project vespa by vespa-engine.
the class ApplicationApiTest method deployment_fails_on_illegal_domain_in_deployment_spec.
@Test
public void deployment_fails_on_illegal_domain_in_deployment_spec() throws IOException {
ContainerControllerTester controllerTester = new ContainerControllerTester(container, responseFiles);
ContainerTester tester = controllerTester.containerTester();
ApplicationPackage applicationPackage = new ApplicationPackageBuilder().upgradePolicy("default").athenzIdentity(com.yahoo.config.provision.AthenzDomain.from("invalid.domain"), com.yahoo.config.provision.AthenzService.from("service")).environment(Environment.prod).region("us-west-1").build();
long screwdriverProjectId = 123;
createAthenzDomainWithAdmin(ATHENZ_TENANT_DOMAIN, USER_ID);
Application application = controllerTester.createApplication(ATHENZ_TENANT_DOMAIN.getName(), "tenant1", "application1");
ScrewdriverId screwdriverId = new ScrewdriverId(Long.toString(screwdriverProjectId));
controllerTester.authorize(ATHENZ_TENANT_DOMAIN, screwdriverId, ApplicationAction.deploy, application);
tester.assertResponse(request("/application/v4/tenant/tenant1/application/application1/environment/test/region/us-east-1/instance/default/", POST).data(createApplicationDeployData(applicationPackage, Optional.of(screwdriverProjectId))).screwdriverIdentity(screwdriverId), "{\"error-code\":\"FORBIDDEN\",\"message\":\"Athenz domain in deployment.xml: [invalid.domain] must match tenant domain: [domain1]\"}", 403);
}
use of com.yahoo.vespa.hosted.controller.restapi.ContainerControllerTester in project vespa by vespa-engine.
the class ApplicationApiTest method testDeployDirectly.
@Test
public void testDeployDirectly() throws Exception {
// Setup
ContainerControllerTester controllerTester = new ContainerControllerTester(container, responseFiles);
ContainerTester tester = controllerTester.containerTester();
tester.updateSystemVersion();
createAthenzDomainWithAdmin(ATHENZ_TENANT_DOMAIN, USER_ID);
// Create tenant
tester.assertResponse(request("/application/v4/tenant/tenant1", POST).userIdentity(USER_ID).data("{\"athensDomain\":\"domain1\", \"property\":\"property1\"}").nToken(N_TOKEN), new File("tenant-without-applications.json"));
// Create application
tester.assertResponse(request("/application/v4/tenant/tenant1/application/application1", POST).userIdentity(USER_ID).nToken(N_TOKEN), new File("application-reference.json"));
// Grant deploy access
addScrewdriverUserToDeployRole(SCREWDRIVER_ID, ATHENZ_TENANT_DOMAIN, new com.yahoo.vespa.hosted.controller.api.identifiers.ApplicationId("application1"));
// POST (deploy) an application to a prod zone - allowed when project ID is not specified
HttpEntity entity = createApplicationDeployData(applicationPackage, Optional.empty());
tester.assertResponse(request("/application/v4/tenant/tenant1/application/application1/environment/prod/region/corp-us-east-1/instance/default/deploy", POST).data(entity).screwdriverIdentity(SCREWDRIVER_ID), new File("deploy-result.json"));
}
use of com.yahoo.vespa.hosted.controller.restapi.ContainerControllerTester in project vespa by vespa-engine.
the class ControllerApiTest method testControllerApi.
@Test
public void testControllerApi() throws Exception {
ContainerControllerTester tester = new ContainerControllerTester(container, responseFiles);
tester.assertResponse(authenticatedRequest("http://localhost:8080/controller/v1/", new byte[0], Request.Method.GET), new File("root.json"));
// POST deactivation of a maintenance job
assertResponse(authenticatedRequest("http://localhost:8080/controller/v1/maintenance/inactive/DeploymentExpirer", new byte[0], Request.Method.POST), 200, "{\"message\":\"Deactivated job 'DeploymentExpirer'\"}");
// GET a list of all maintenance jobs
tester.assertResponse(authenticatedRequest("http://localhost:8080/controller/v1/maintenance/", new byte[0], Request.Method.GET), new File("maintenance.json"));
// DELETE deactivation of a maintenance job
assertResponse(authenticatedRequest("http://localhost:8080/controller/v1/maintenance/inactive/DeploymentExpirer", new byte[0], Request.Method.DELETE), 200, "{\"message\":\"Re-activated job 'DeploymentExpirer'\"}");
}
use of com.yahoo.vespa.hosted.controller.restapi.ContainerControllerTester in project vespa by vespa-engine.
the class ZoneApiTest method before.
@Before
public void before() {
ZoneRegistryMock zoneRegistry = (ZoneRegistryMock) container.components().getComponent(ZoneRegistryMock.class.getName());
zoneRegistry.setDefaultRegionForEnvironment(Environment.dev, RegionName.from("us-north-2")).setZones(zones);
this.tester = new ContainerControllerTester(container, responseFiles);
this.proxy = (ConfigServerProxyMock) container.components().getComponent(ConfigServerProxyMock.class.getName());
addUserToHostedOperatorRole(HOSTED_VESPA_OPERATOR);
}
Aggregations