blob: 7d377ef6361467eeef60a17cbfde7f0fa3f7a898 (
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
|
package com.yahoo.vespa.hosted.controller.application.pkg;
import com.yahoo.text.XML;
import com.yahoo.vespa.hosted.controller.application.pkg.BasicServicesXml.Container;
import org.junit.jupiter.api.Test;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* @author mpolden
*/
class BasicServicesXmlTest {
@Test
public void parse() {
assertServices(new BasicServicesXml(List.of()), "<services/>");
assertServices(new BasicServicesXml(List.of(new Container("foo", List.of(Container.AuthMethod.mtls)),
new Container("bar", List.of(Container.AuthMethod.mtls)))),
"""
<services>
<container id="foo"/>
<container id="bar"/>
</services>
""");
assertServices(new BasicServicesXml(List.of(
new Container("foo",
List.of(Container.AuthMethod.mtls,
Container.AuthMethod.token)),
new Container("bar", List.of(Container.AuthMethod.mtls)))),
"""
<services>
<container id="foo">
<clients>
<client id="mtls"/>
<client id="token">
<token id="my-token"/>
</client>
<client id="token2">
<token id="other-token"/>
</client>
</clients>
</container>
<container id="bar"/>
</services>
""");
}
private void assertServices(BasicServicesXml expected, String xmlForm) {
assertEquals(expected, BasicServicesXml.parse(XML.getDocument(xmlForm)));
}
}
|