@Test
public void testValidateWithUriHostname() throws IOException {

    Path path = Paths.get("src/test/resources/athenz.examples.uri-instanceid-hostname.csr");
    String csr = new String(Files.readAllBytes(path));
    X509ServiceCertRequest certReq = new X509ServiceCertRequest(csr);
    assertNotNull(certReq);
    StringBuilder errorMsg = new StringBuilder(256);
    List<String> providerDnsSuffixList = Collections.singletonList("ostk.athenz.cloud");
    List<String> providerHostnameAllowSuffixList = Collections.singletonList("athenz.com");
    DataCache athenzSysDomainCache = Mockito.mock(DataCache.class);
    Mockito.when(athenzSysDomainCache.getProviderDnsSuffixList("ostk.provider")).thenReturn(providerDnsSuffixList);
    Mockito.when(athenzSysDomainCache.getProviderHostnameAllowedSuffixList("ostk.provider")).thenReturn(providerHostnameAllowSuffixList);
    assertFalse(certReq.validate("athenz.examples", "httpd", "ostk.provider",
            null, athenzSysDomainCache, null, "def.athenz.com", null, null, errorMsg));
    assertFalse(certReq.validate("athenz.examples", "httpd", "ostk.provider",
            null, athenzSysDomainCache, null, null, null, null, errorMsg));
    assertTrue(certReq.validate("athenz.examples", "httpd", "ostk.provider",
            null, athenzSysDomainCache, null, "abc.athenz.com", null, null, errorMsg));
    HashSet<String> validOrgs = new HashSet<>();
    validOrgs.add("Athenz");
    assertTrue(certReq.validate("athenz.examples", "httpd", "ostk.provider",
            validOrgs, athenzSysDomainCache, null, "abc.athenz.com", null, null, errorMsg));
}