aboutsummaryrefslogtreecommitdiffstats
path: root/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/EnclaveAccessMaintainerTest.java
blob: 1e1079a33140b3f908ec215604d09acca55612b6 (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
package com.yahoo.vespa.hosted.controller.maintenance;

import com.yahoo.config.provision.CloudAccount;
import com.yahoo.vespa.flags.PermanentFlags;
import com.yahoo.vespa.hosted.controller.ControllerTester;
import com.yahoo.vespa.hosted.controller.api.integration.aws.MockEnclaveAccessService;
import org.junit.jupiter.api.Test;

import java.time.Duration;
import java.util.List;
import java.util.Set;

import static org.junit.jupiter.api.Assertions.assertEquals;

/**
 * @author jonmv
 */
class EnclaveAccessMaintainerTest {

    @Test
    void test() {
        ControllerTester tester = new ControllerTester();
        MockEnclaveAccessService amis = tester.serviceRegistry().enclaveAccessService();
        EnclaveAccessMaintainer sharer = new EnclaveAccessMaintainer(tester.controller(), Duration.ofHours(1));
        CloudAccountVerifier accountVerifier = new CloudAccountVerifier(tester.controller(), Duration.ofHours(1));
        assertEquals(Set.of(), amis.currentAccounts());

        assertEquals(1, sharer.maintain());
        assertEquals(Set.of(), amis.currentAccounts());

        tester.createTenant("tanten");
        accountVerifier.maintain();
        assertEquals(1, sharer.maintain());
        assertEquals(Set.of(), amis.currentAccounts());

        tester.flagSource().withListFlag(PermanentFlags.CLOUD_ACCOUNTS.id(), List.of("123123123123", "321321321321"), String.class);
        accountVerifier.maintain();
        assertEquals(1, sharer.maintain());
        assertEquals(Set.of(CloudAccount.from("aws:123123123123"), CloudAccount.from("aws:321321321321")), amis.currentAccounts());
    }

}