blob: 62c187b8c2ced2eb94a3d39faa79d9aa1813f623 (
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
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.athenz.utils;
import com.yahoo.vespa.athenz.api.AthenzIdentity;
import com.yahoo.vespa.athenz.api.AthenzService;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
/**
* @author bjorncs
*/
public class SiaUtilsTest {
@Rule
public TemporaryFolder tempDirectory = new TemporaryFolder();
@Test
public void it_finds_all_identity_names_from_files_in_sia_keys_directory() throws IOException {
Path siaRoot = tempDirectory.getRoot().toPath();
assertTrue(SiaUtils.findSiaServices(siaRoot).isEmpty());
Files.createDirectory(siaRoot.resolve("keys"));
AthenzService fooService = new AthenzService("my.domain.foo");
Files.createFile(SiaUtils.getPrivateKeyFile(siaRoot, fooService));
AthenzService barService = new AthenzService("my.domain.bar");
Files.createFile(SiaUtils.getPrivateKeyFile(siaRoot, barService));
List<AthenzIdentity> siaIdentities = SiaUtils.findSiaServices(siaRoot);
assertEquals(2, siaIdentities.size());
assertTrue(siaIdentities.contains(fooService));
assertTrue(siaIdentities.contains(barService));
}
}
|