@Test
public void testUpdateSSHHostPrincipals() {

    InstanceCertManager instance = new InstanceCertManager(null, null, null, true);
    SSHCertRecord record = new SSHCertRecord();
    instance.updateSSHHostPrincipals(null, record);
    assertEquals(record.getPrincipals(), "127.0.0.1");
    // reset and test csr with no principals
    record.setPrincipals(null);
    SshHostCsr csr = new SshHostCsr();
    instance.updateSSHHostPrincipals(csr, record);
    assertEquals(record.getPrincipals(), "127.0.0.1");
    // reset and test csr with principals and xprincipals
    record.setPrincipals(null);
    String[] principals = new String[1];
    principals[0] = "principal1";
    csr.setPrincipals(principals);
    String[] xprincipals = new String[2];
    xprincipals[0] = "xprincipal1";
    xprincipals[1] = "xprincipal2";
    csr.setXPrincipals(xprincipals);
    instance.updateSSHHostPrincipals(csr, record);
    Set<String> result = new HashSet<>(Arrays.asList(record.getPrincipals().split(",")));
    assertEquals(result.size(), 3);
    assertTrue(result.contains("principal1"));
    assertTrue(result.contains("xprincipal1"));
    assertTrue(result.contains("xprincipal2"));
}