@Test
public void testPostInstanceRefreshRequestSubjectOU() throws IOException {

    Path path = Paths.get("src/test/resources/athenz.cert_ou.csr");
    String certCsr = new String(Files.readAllBytes(path));
    InstanceRefreshRequest req = new InstanceRefreshRequest().setCsr(certCsr);
    SimplePrincipal principal = (SimplePrincipal) SimplePrincipal.create("athenz",
            "production", "v=S1,d=athenz;n=production;s=sig", 0, new PrincipalAuthority());
    principal.setKeyId("0");
    String publicKeyName = "athenz.production_0";
    final String ztsPublicKey = "-----BEGIN PUBLIC KEY-----\n"
            + "MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBALaJDb8CSq9tuzwSbe5bJurHLLvfkQ3a\n"
            + "jFGGJU4M8cz5+CbkJXRl/Cx1R0zOA+fdX5cGxYxL0Td31YDVw3tECWUCAwEAAQ==\n"
            + "-----END PUBLIC KEY-----";
    zts.dataStore.getPublicKeyCache().put(publicKeyName, ztsPublicKey);
    HttpServletRequest servletRequest = Mockito.mock(HttpServletRequest.class);
    Mockito.when(servletRequest.isSecure()).thenReturn(true);
    ResourceContext context = createResourceContext(principal, servletRequest);
    zts.verifyCertSubjectOU = true;
    zts.verifyCertRequestIP = false;
    try {
        zts.postInstanceRefreshRequest(context, "athenz", "production", req);
        fail();
    } catch (ResourceException ex) {
        assertEquals(ex.getCode(), 400);
    }
    Set<String> ouValues = new HashSet<>();
    ouValues.add("Athenz");
    zts.validCertSubjectOrgUnitValues = ouValues;
    Identity identity = zts.postInstanceRefreshRequest(context, "athenz", "production", req);
    assertNotNull(identity);
}