@Test
public void testValidateDnsNamesWithValues() throws IOException {

    Path path = Paths.get("src/test/resources/athenz.instanceid.csr");
    String csr = new String(Files.readAllBytes(path));
    X509CertRequest certReq = new X509CertRequest(csr);
    assertNotNull(certReq);
    List<String> providerDnsSuffixList = new ArrayList<>();
    // for the first test we're going to return null
    // and the list for all subsequent tests
    DataCache athenzSysDomainCache = Mockito.mock(DataCache.class);
    Mockito.when(athenzSysDomainCache.getProviderDnsSuffixList("provider"))
            .thenReturn(null)
            .thenReturn(providerDnsSuffixList);
    List<String> providerHostnameAllowedSuffixList = Collections.singletonList("athenz.cloud");
    Mockito.when(athenzSysDomainCache.getProviderHostnameAllowedSuffixList("provider"))
            .thenReturn(providerHostnameAllowedSuffixList);
    Mockito.when(athenzSysDomainCache.getProviderHostnameDeniedSuffixList("provider"))
            .thenReturn(null);
    assertTrue(certReq.validateDnsNames("athenz", "production", "provider", athenzSysDomainCache,
            "ostk.athenz.cloud", null, null, null));
    // empty provider suffix list
    assertTrue(certReq.validateDnsNames("athenz", "production", "provider", athenzSysDomainCache,
            "ostk.athenz.cloud", null, null, null));
    // provider suffix list with no match
    providerDnsSuffixList.add("ostk.myathenz.cloud");
    assertTrue(certReq.validateDnsNames("athenz", "production", "provider", athenzSysDomainCache,
            "ostk.athenz.cloud", null, null, null));
    // no match if service list does not match
    assertFalse(certReq.validateDnsNames("athenz", "production", "provider", athenzSysDomainCache,
            "ostk.athenz2.cloud", null, null, null));
    // add the same domain to the provider suffix list
    providerDnsSuffixList.add("ostk.athenz.cloud");
    assertTrue(certReq.validateDnsNames("athenz", "production", "provider", athenzSysDomainCache,
            "ostk.athenz2.cloud", null, null, null));
    assertTrue(certReq.validateDnsNames("athenz", "production", "provider", athenzSysDomainCache,
            "ostk.athenz.cloud", null, null, null));
    assertTrue(certReq.validateDnsNames("athenz", "production", "provider", athenzSysDomainCache,
            "", null, null, null));
    assertTrue(certReq.validateDnsNames("athenz", "production", "provider", athenzSysDomainCache,
            null, null, null, null));
}