aboutsummaryrefslogtreecommitdiffstats
path: root/security-utils/src/test/java/com/yahoo/security/tls/AuthorizedPeersTest.java
blob: e4c530dbb0b018286e62d9802772bd2e2fd46a56 (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
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.security.tls;

import com.yahoo.security.tls.PeerPolicy;
import com.yahoo.security.tls.RequiredPeerCredential;
import org.junit.Test;

import java.util.HashSet;

import static com.yahoo.security.tls.RequiredPeerCredential.Field.CN;
import static java.util.Arrays.asList;
import static java.util.Collections.singletonList;

/**
 * @author bjorncs
 */
public class AuthorizedPeersTest {

    @Test(expected = IllegalArgumentException.class)
    public void throws_exception_on_peer_policies_with_duplicate_names() {
        PeerPolicy peerPolicy1 = new PeerPolicy("duplicate-name", singletonList(RequiredPeerCredential.of(CN, "mycfgserver")));
        PeerPolicy peerPolicy2 = new PeerPolicy("duplicate-name", singletonList(RequiredPeerCredential.of(CN, "myclient")));
        new AuthorizedPeers(new HashSet<>(asList(peerPolicy1, peerPolicy2)));
    }

}