aboutsummaryrefslogtreecommitdiffstats
path: root/controller-api/src/test/java/com/yahoo/vespa/hosted/controller/api/integration/certificates/EndpointCertificateTest.java
blob: e165157dac2c16a2dfd7130307fe6b5b1f57b2f4 (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
package com.yahoo.vespa.hosted.controller.api.integration.certificates;

import org.junit.jupiter.api.Test;

import java.util.List;

import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

/**
 * @author mpolden
 */
class EndpointCertificateTest {

    @Test
    public void san_matches() {
        List<String> sans = List.of("*.a.example.com", "b.example.com", "c.example.com");
        assertTrue(EndpointCertificate.sanMatches("b.example.com", sans));
        assertTrue(EndpointCertificate.sanMatches("c.example.com", sans));
        assertTrue(EndpointCertificate.sanMatches("foo.a.example.com", sans));
        assertFalse(EndpointCertificate.sanMatches("", List.of()));
        assertFalse(EndpointCertificate.sanMatches("example.com", List.of()));
        assertFalse(EndpointCertificate.sanMatches("example.com", sans));
        assertFalse(EndpointCertificate.sanMatches("d.example.com", sans));
        assertFalse(EndpointCertificate.sanMatches("a.example.com", sans));
        assertFalse(EndpointCertificate.sanMatches("aa.example.com", sans));
        assertFalse(EndpointCertificate.sanMatches("c.c.example.com", sans));
        assertFalse(EndpointCertificate.sanMatches("a.a.a.example.com", sans));
    }

}