Check that tenant and/or application exists in UserApi
@@ -35,6 +35,7 @@ import com.yahoo.vespa.hosted.controller.api.role.RoleDefinition;
import com.yahoo.vespa.hosted.controller.api.role.SecurityContext;
import com.yahoo.vespa.hosted.controller.api.role.SimplePrincipal;
import com.yahoo.vespa.hosted.controller.api.role.TenantRole;
+import com.yahoo.vespa.hosted.controller.application.TenantAndApplicationId;
import com.yahoo.vespa.hosted.controller.restapi.ErrorResponses;
import com.yahoo.vespa.hosted.controller.restapi.application.EmptyResponse;
import com.yahoo.vespa.hosted.controller.tenant.Tenant;
@@ -231,6 +232,7 @@ public class UserApiHandler extends ThreadedHttpRequestHandler {
}
private HttpResponse listTenantRoleMembers(String tenantName) {
+ if (controller.tenants().get(tenantName).isPresent()) {
Slime slime = new Slime();
Cursor root = slime.setObject();
root.setString("tenant", tenantName);
@@ -239,8 +241,12 @@ public class UserApiHandler extends ThreadedHttpRequestHandler {
Collections.emptyList());
return new SlimeJsonResponse(slime);
}
+ return ErrorResponse.notFoundError("Tenant '" + tenantName + "' does not exist");
+ }
private HttpResponse listApplicationRoleMembers(String tenantName, String applicationName) {
+ var id = TenantAndApplicationId.from(tenantName, applicationName);
+ if (controller.applications().getApplication(id).isPresent()) {
Slime slime = new Slime();
Cursor root = slime.setObject();
root.setString("tenant", tenantName);
@@ -250,6 +256,8 @@ public class UserApiHandler extends ThreadedHttpRequestHandler {
Roles.tenantRoles(TenantName.from(tenantName)));
return new SlimeJsonResponse(slime);
}
+ return ErrorResponse.notFoundError("Application '" + id + "' does not exist");
+ }
private void fillRoles(Cursor root, List<? extends Role> roles, List<? extends Role> superRoles) {
Cursor rolesArray = root.setArray("roleNames");
