use of com.yahoo.vespa.hosted.controller.ControllerTester in project vespa by vespa-engine.
the class ControllerAuthorizationFilterTest method white_listed_operations_are_allowed.
@Test
public void white_listed_operations_are_allowed() {
ControllerAuthorizationFilter filter = createFilter(new ControllerTester());
assertIsAllowed(invokeFilter(filter, createRequest(PUT, "/application/v4/user", USER)));
assertIsAllowed(invokeFilter(filter, createRequest(POST, "/application/v4/tenant/john", USER)));
}
use of com.yahoo.vespa.hosted.controller.ControllerTester in project vespa by vespa-engine.
the class ControllerAuthorizationFilterTest method only_hosted_operator_and_screwdriver_project_with_deploy_role_can_access_tenant_pipeline_apis.
@Test
public void only_hosted_operator_and_screwdriver_project_with_deploy_role_can_access_tenant_pipeline_apis() {
ControllerTester controllerTester = new ControllerTester();
controllerTester.athenzDb().hostedOperators.add(HOSTED_OPERATOR);
controllerTester.createTenant(TENANT.id(), TENANT_DOMAIN.getName(), null);
controllerTester.createApplication(TENANT, APPLICATION.id(), "default", 12345);
AthenzDbMock.Domain domainMock = controllerTester.athenzDb().domains.get(TENANT_DOMAIN);
domainMock.admins.add(TENANT_ADMIN);
domainMock.applications.get(APPLICATION).addRoleMember(ApplicationAction.deploy, TENANT_PIPELINE);
ControllerAuthorizationFilter filter = createFilter(controllerTester);
List<AthenzIdentity> allowed = asList(HOSTED_OPERATOR, TENANT_PIPELINE);
List<AthenzIdentity> forbidden = asList(TENANT_ADMIN, USER);
testApiAccess(POST, "/application/v4/tenant/mytenant/application/myapp/environment/prod/region/myregion/instance/default/deploy", allowed, forbidden, filter);
testApiAccess(POST, "/application/v4/tenant/mytenant/application/myapp/jobreport", allowed, forbidden, filter);
testApiAccess(POST, "/application/v4/tenant/mytenant/application/myapp/promote", allowed, forbidden, filter);
}
use of com.yahoo.vespa.hosted.controller.ControllerTester in project vespa by vespa-engine.
the class ControllerAuthorizationFilterTest method only_hosted_operator_can_access_operator_apis.
@Test
public void only_hosted_operator_can_access_operator_apis() {
ControllerTester controllerTester = new ControllerTester();
controllerTester.athenzDb().hostedOperators.add(HOSTED_OPERATOR);
ControllerAuthorizationFilter filter = createFilter(controllerTester);
List<AthenzIdentity> allowed = singletonList(HOSTED_OPERATOR);
List<AthenzIdentity> forbidden = singletonList(USER);
testApiAccess(PUT, "/application/v4/tenant/mytenant/application/myapp/deploying", allowed, forbidden, filter);
testApiAccess(POST, "/screwdriver/v1/trigger/tenant/mytenant/application/myapp/", allowed, forbidden, filter);
testApiAccess(DELETE, "/provision/v2/provision/enqueue", allowed, forbidden, filter);
}
use of com.yahoo.vespa.hosted.controller.ControllerTester in project vespa by vespa-engine.
the class MetricsReporterTest method test_chef_metrics.
@Test
public void test_chef_metrics() {
Clock clock = Clock.fixed(Instant.ofEpochSecond(1475497913), ZoneId.systemDefault());
;
ControllerTester tester = new ControllerTester();
MetricsReporter metricsReporter = createReporter(clock, tester.controller(), metrics, SystemName.cd);
metricsReporter.maintain();
assertEquals(2, metrics.getMetrics().size());
Map<MapContext, Map<String, Number>> hostMetrics = getMetricsByHost("fake-node.test");
assertEquals(1, hostMetrics.size());
Map.Entry<MapContext, Map<String, Number>> metricEntry = hostMetrics.entrySet().iterator().next();
MapContext metricContext = metricEntry.getKey();
assertDimension(metricContext, "tenantName", "ciintegrationtests");
assertDimension(metricContext, "app", "restart.default");
assertDimension(metricContext, "zone", "prod.cd-us-east-1");
assertEquals(727, metricEntry.getValue().get(MetricsReporter.convergeMetric).longValue());
}
use of com.yahoo.vespa.hosted.controller.ControllerTester in project vespa by vespa-engine.
the class MetricsReporterTest method it_omits_zone_when_unknown.
@Test
public void it_omits_zone_when_unknown() {
ControllerTester tester = new ControllerTester();
String hostname = "fake-node2.test";
MapContext metricContext = getMetricContextByHost(tester.controller(), hostname);
assertNull(metricContext.getDimensions().get("zone"));
}
Aggregations