blob: 8a02d0dcff5f52797a31e33277ed9af8fcca23bb (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.controller.api.integration.athens.mock;
import com.yahoo.vespa.hosted.controller.api.integration.athens.ApplicationAction;
import com.yahoo.vespa.hosted.controller.api.identifiers.ApplicationId;
import com.yahoo.vespa.hosted.controller.api.identifiers.AthensDomain;
import com.yahoo.vespa.hosted.controller.api.integration.athens.AthensPrincipal;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
/**
* @author bjorncs
*/
public class AthensDbMock {
public final Map<AthensDomain, Domain> domains = new HashMap<>();
public AthensDbMock addDomain(Domain domain) {
domains.put(domain.name, domain);
return this;
}
public static class Domain {
public final AthensDomain name;
public final Set<AthensPrincipal> admins = new HashSet<>();
public final Set<AthensPrincipal> tenantAdmins = new HashSet<>();
public final Map<ApplicationId, Application> applications = new HashMap<>();
public boolean isVespaTenant = false;
public Domain(AthensDomain name) {
this.name = name;
}
public Domain admin(AthensPrincipal user) {
admins.add(user);
return this;
}
public Domain tenantAdmin(AthensPrincipal user) {
tenantAdmins.add(user);
return this;
}
/**
* Simulates establishing Vespa tenancy in Athens.
*/
public void markAsVespaTenant() {
isVespaTenant = true;
}
}
public static class Application {
public final Map<ApplicationAction, Set<AthensPrincipal>> acl = new HashMap<>();
public Application() {
acl.put(ApplicationAction.deploy, new HashSet<>());
acl.put(ApplicationAction.read, new HashSet<>());
acl.put(ApplicationAction.write, new HashSet<>());
}
public Application addRoleMember(ApplicationAction action, AthensPrincipal user) {
acl.get(action).add(user);
return this;
}
}
}
|