use of org.glassfish.embeddable.CommandResult in project Payara by payara.
the class AutoNameInstancesTest method testInstanceNameConflict.
@Test
public void testInstanceNameConflict() {
String domainName = ServerOperations.getDomainName();
String conflictInstanceName = "Scrumptious-Swordfish";
// Create expected conflict if it doesn't already exist.
CommandResult result = asadmin("list-instances", "-t", "--nostatus");
if (!result.getOutput().contains(conflictInstanceName)) {
asadmin("create-instance", "--node", "localhost-" + domainName, conflictInstanceName);
}
result = asadmin("create-instance", "--autoname", "true", "--node", "localhost-" + domainName, "-T", conflictInstanceName);
try {
assertSuccess(result);
} finally {
// Cleanup
String generatedInstanceName = result.getOutput();
asadmin("delete-instance", conflictInstanceName);
asadmin("delete-instance", generatedInstanceName);
}
}
use of org.glassfish.embeddable.CommandResult in project Payara by payara.
the class RegisterLoginModuleTest method successfulRegistrationUpdatesLoginConf.
@Test
public void successfulRegistrationUpdatesLoginConf() throws IOException {
asadmin("delete-auth-realm", "test1");
CommandResult result = asadmin("create-auth-realm", "--classname", "com.sun.enterprise.security.auth.realm.file.FileRealm", "--login-module", "com.sun.enterprise.security.auth.login.FileLoginModule", "--property", "jaas-context=test1:file=test1", "test1");
System.out.println(result.getOutput());
assertSuccess(result);
String contents = loginConf();
assertContains("test1 {", contents);
result = asadmin("delete-auth-realm", "test1");
System.out.println(result.getOutput());
assertSuccess(result);
// Removes JAAS context test1 from the login.conf file on the domain
// It's expected that this will be the last entry in the login.conf file
// and so we just grab everything up to this final entry as the new file
// contents
String newFileContents = contents.substring(0, contents.indexOf("test1"));
System.out.print(newFileContents);
try (BufferedWriter writer = new BufferedWriter(new FileWriter(System.getProperty("java.security.auth.login.config")))) {
writer.write(newFileContents);
} catch (IOException e) {
System.out.print(e.getMessage());
e.printStackTrace();
}
assertFalse(loginConf().contains("test1 {"));
}
use of org.glassfish.embeddable.CommandResult in project Payara by payara.
the class RegisterLoginModuleTest method undefinedJaasContextGivesWarning.
@Test
public void undefinedJaasContextGivesWarning() {
asadmin("delete-auth-realm", "test3");
CommandResult result = asadmin("create-auth-realm", "--classname", "com.sun.enterprise.security.auth.realm.certificate.CertificateRealm", "--login-module", "com.sun.enterprise.security.auth.login.FileLoginModule", "--property", "file=test3", "test3");
System.out.println(result.getOutput());
assertEquals(CommandResult.ExitStatus.WARNING, result.getExitStatus());
assertContains("No JAAS context is defined", result.getOutput());
result = asadmin("delete-auth-realm", "test3");
System.out.println(result.getOutput());
assertSuccess(result);
}
use of org.glassfish.embeddable.CommandResult in project Payara by payara.
the class RegisterLoginModuleTest method existingJaasContextGivesWarning.
@Test
public void existingJaasContextGivesWarning() {
asadmin("delete-auth-realm", "test2");
CommandResult result = asadmin("create-auth-realm", "--classname", "com.sun.enterprise.security.auth.realm.file.FileRealm", "--login-module", "com.sun.enterprise.security.auth.login.FileLoginModule", "--property", "jaas-context=fileRealm:file=test2", "test2");
System.out.println(result.getOutput());
assertEquals(CommandResult.ExitStatus.WARNING, result.getExitStatus());
assertContains("fileRealm is already configured", result.getOutput());
result = asadmin("delete-auth-realm", "test2");
System.out.println(result.getOutput());
assertSuccess(result);
}
use of org.glassfish.embeddable.CommandResult in project Payara by payara.
the class SetHealthCheckConfigurationTest method historicalTraceStoreTimeoutAffectsConfigButNotService.
@Test
public void historicalTraceStoreTimeoutAffectsConfigButNotService() {
Long historicalTraceStoreTimeout = getHistoricalTraceStoreTimeout();
CommandResult result = asadmin("set-healthcheck-configuration", "--enabled", "true", "--historical-trace-store-timeout", "42");
assertSuccess(result);
assertEquals(42, Integer.parseInt(config.getHistoricalTraceStoreTimeout()));
assertEquals(historicalTraceStoreTimeout, getHistoricalTraceStoreTimeout());
}
Aggregations