aboutsummaryrefslogtreecommitdiffstats
path: root/docker-api/src/test/java/com/yahoo/vespa/hosted/dockerapi/CreateContainerCommandImplTest.java
blob: aa455cfc0f2d11f4c53161d3ec740b764a54c8f6 (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
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.dockerapi;


import org.junit.Test;

import java.util.Optional;
import java.util.stream.Stream;

import static org.junit.Assert.assertEquals;

public class CreateContainerCommandImplTest {

    @Test
    public void generateMacAddressTest() {
        String[][] addresses = {
                {"test123.host.yahoo.com",  null,       "abcd:1234::1", "ee:ae:a9:de:ad:c2"},
                {"test123.host.yahoo.com",  null,       "abcd:1234::2", "fa:81:11:1b:ff:fb"},
                {"unique.host.yahoo.com",   null,       "abcd:1234::1", "96:a4:00:77:90:3b"},
                {"test123.host.yahoo.com",  "10.0.0.1", null,           "7e:de:b3:7c:9e:96"},
                {"test123.host.yahoo.com",  "10.0.0.1", "abcd:1234::1", "6a:06:af:16:25:95"}};

        Stream.of(addresses).forEach(address -> {
            String generatedMac = CreateContainerCommandImpl.generateMACAddress(
                    address[0], Optional.ofNullable(address[1]), Optional.ofNullable(address[2]));
            String expectedMac = address[3];
            assertEquals(expectedMac, generatedMac);
        });
    }
}