use of org.apache.cloudstack.api.BaseCmd in project cloudstack by apache.
the class SpecificCmdValidationWorkerTest method testHandle.
@Test
public void testHandle() throws ResourceAllocationException {
// Prepare
final BaseCmd cmd = mock(BaseCmd.class);
final Map<String, String> params = new HashMap<String, String>();
// Execute
final SpecificCmdValidationWorker worker = new SpecificCmdValidationWorker();
worker.handle(new DispatchTask(cmd, params));
// Assert
verify(cmd, times(1)).validateSpecificParameters(params);
}
use of org.apache.cloudstack.api.BaseCmd in project cloudstack by apache.
the class FakeCmdWithRoleAdmin method testHandleWithUnknownParams.
@Test
public void testHandleWithUnknownParams() throws ResourceAllocationException {
// Prepare
final String unknownParamKey = "unknownParam";
final BaseCmd cmd = new FakeCmd();
final Map<String, String> params = new HashMap<String, String>();
params.put(ApiConstants.COMMAND, "");
params.put("addedParam", "");
params.put(unknownParamKey, "");
Account account = new AccountVO("testaccount", 1L, "networkdomain", (short) 0, "uuid");
UserVO user = new UserVO(1, "testuser", "password", "firstname", "lastName", "email", "timezone", UUID.randomUUID().toString(), User.Source.UNKNOWN);
CallContext.register(user, account);
// Execute
try {
driveTest(cmd, params);
} finally {
CallContext.unregister();
}
// Assert
assertTrue("There should be error msg, since there is one unknown parameter", loggerOutput.contains(unknownParamKey));
assertTrue("There should be error msg containing the correct command name", loggerOutput.contains(FAKE_CMD_NAME));
}
use of org.apache.cloudstack.api.BaseCmd in project cloudstack by apache.
the class FakeCmdWithRoleAdmin method testHandle.
@Test
public void testHandle() throws ResourceAllocationException {
// Prepare
final BaseCmd cmd = new FakeCmd();
final Map<String, String> params = new HashMap<String, String>();
params.put(ApiConstants.COMMAND, "");
params.put(ApiConstants.ACCOUNT_ID, "");
params.put(ApiConstants.CTX_START_EVENT_ID, "");
params.put(ApiConstants.COMMAND, "");
params.put(ApiConstants.CMD_EVENT_TYPE, "");
params.put(ApiConstants.USERNAME, "");
params.put(ApiConstants.USER_ID, "");
params.put(ApiConstants.PASSWORD, "");
params.put(ApiConstants.DOMAIN, "");
params.put(ApiConstants.DOMAIN_ID, "");
params.put(ApiConstants.DOMAIN__ID, "");
params.put(ApiConstants.SESSIONKEY, "");
params.put(ApiConstants.RESPONSE, "");
params.put(ApiConstants.PAGE, "");
params.put(ApiConstants.USER_API_KEY, "");
params.put(ApiConstants.API_KEY, "");
params.put(ApiConstants.PAGE_SIZE, "");
params.put(ApiConstants.HTTPMETHOD, "");
params.put(ApiConstants.SIGNATURE, "");
params.put(ApiConstants.CTX_ACCOUNT_ID, "");
params.put(ApiConstants.CTX_START_EVENT_ID, "");
// Make sure it's case insensitive
params.put(ApiConstants.CTX_START_EVENT_ID, "");
params.put(ApiConstants.CTX_START_EVENT_ID.toLowerCase(), "");
params.put(ApiConstants.CTX_USER_ID.toUpperCase(), "");
params.put(ApiConstants.CTX_USER_ID, "");
params.put(ApiConstants.UUID, "");
params.put(ApiConstants.ID, "");
params.put("_", "");
params.put("addedParam", "");
Account account = new AccountVO("testaccount", 1L, "networkdomain", (short) 0, "uuid");
UserVO user = new UserVO(1, "testuser", "password", "firstname", "lastName", "email", "timezone", UUID.randomUUID().toString(), User.Source.UNKNOWN);
CallContext.register(user, account);
// Execute
try {
driveTest(cmd, params);
} finally {
CallContext.unregister();
}
// Assert
assertEquals("There should be no errors since there are no unknown parameters for this command class", null, loggerOutput);
}
Aggregations