Search in sources :

Example 1 with UserExportParams

use of com.axway.apim.users.lib.params.UserExportParams in project apim-cli by Axway-API-Management-Plus.

the class UserCLIOptionsTest method testExportUserParameters.

@Test
public void testExportUserParameters() throws ParseException, AppException {
    String[] args = { "-s", "prod", "-id", "UUID-ID-OF-THE-USER", "-loginName", "*mark24*", "-n", "*Mark*", "-email", "*@axway.com*", "-type", "external", "-org", "*Partner*", "-role", "oadmin", "-state", "pending", "-enabled", "false", "-o", "json" };
    CLIOptions options = UserExportCLIOptions.create(args);
    UserExportParams params = (UserExportParams) options.getParams();
    // Validate core parameters are included
    Assert.assertEquals(params.getUsername(), "apiadmin");
    Assert.assertEquals(params.getPassword(), "changeme");
    Assert.assertEquals(params.getHostname(), "localhost");
    // Validate standard export parameters are included
    Assert.assertEquals(params.getWide(), Wide.standard);
    Assert.assertEquals(params.getOutputFormat(), OutputFormat.json);
    // Validate user filter parameters
    Assert.assertEquals(params.getId(), "UUID-ID-OF-THE-USER");
    Assert.assertEquals(params.getLoginName(), "*mark24*");
    Assert.assertEquals(params.getName(), "*Mark*");
    Assert.assertEquals(params.getEmail(), "*@axway.com*");
    Assert.assertEquals(params.getType(), "external");
    Assert.assertEquals(params.getOrg(), "*Partner*");
    Assert.assertEquals(params.getRole(), "oadmin");
    Assert.assertEquals(params.getState(), "pending");
    Assert.assertFalse(params.isEnabled());
    Assert.assertNotNull(params.getProperties(), "Properties should never be null. They must be created as a base or per stage.");
}
Also used : UserImportCLIOptions(com.axway.apim.users.lib.cli.UserImportCLIOptions) CLIOptions(com.axway.apim.lib.CLIOptions) UserChangePasswordCLIOptions(com.axway.apim.users.lib.cli.UserChangePasswordCLIOptions) UserExportCLIOptions(com.axway.apim.users.lib.cli.UserExportCLIOptions) UserExportParams(com.axway.apim.users.lib.params.UserExportParams) Test(org.testng.annotations.Test)

Example 2 with UserExportParams

use of com.axway.apim.users.lib.params.UserExportParams in project apim-cli by Axway-API-Management-Plus.

the class ExportUserTestAction method runTest.

@Override
public ExportResult runTest(TestContext context) {
    UserExportParams params = new UserExportParams();
    addParameters(params, context);
    params.setLoginName(getParamLoginName(context));
    UserApp app = new UserApp();
    LOG.info("Running " + app.getClass().getSimpleName() + " with params: " + params);
    ExportResult result = app.export(params);
    if (this.getExpectedReturnCode(context) != result.getRc()) {
        throw new ValidationException("Expected RC was: " + this.getExpectedReturnCode(context) + " but got: " + result.getRc());
    }
    return result;
}
Also used : UserExportParams(com.axway.apim.users.lib.params.UserExportParams) ValidationException(com.consol.citrus.exceptions.ValidationException) UserApp(com.axway.apim.users.UserApp) ExportResult(com.axway.apim.lib.ExportResult)

Example 3 with UserExportParams

use of com.axway.apim.users.lib.params.UserExportParams in project apim-cli by Axway-API-Management-Plus.

the class UserApp method export.

@CLIServiceMethod(name = "get", description = "Get users from API-Manager in different formats")
public static int export(String[] args) {
    UserExportParams params;
    try {
        params = (UserExportParams) UserExportCLIOptions.create(args).getParams();
    } catch (AppException e) {
        LOG.error("Error " + e.getMessage());
        return e.getError().getCode();
    }
    UserApp app = new UserApp();
    return app.export(params).getRc();
}
Also used : UserExportParams(com.axway.apim.users.lib.params.UserExportParams) AppException(com.axway.apim.lib.errorHandling.AppException) CLIServiceMethod(com.axway.apim.cli.CLIServiceMethod)

Example 4 with UserExportParams

use of com.axway.apim.users.lib.params.UserExportParams in project apim-cli by Axway-API-Management-Plus.

the class UserApp method delete.

@CLIServiceMethod(name = "delete", description = "Delete selected user(s) from the API-Manager")
public static int delete(String[] args) {
    UserExportParams params;
    try {
        params = (UserExportParams) UserDeleteCLIOptions.create(args).getParams();
    } catch (AppException e) {
        LOG.error("Error " + e.getMessage());
        return e.getError().getCode();
    /*} catch (ParseException e) {
			LOG.error("Error " + e.getMessage());
			return ErrorCode.MISSING_PARAMETER.getCode();*/
    }
    UserApp app = new UserApp();
    return app.delete(params).getRc();
}
Also used : UserExportParams(com.axway.apim.users.lib.params.UserExportParams) AppException(com.axway.apim.lib.errorHandling.AppException) CLIServiceMethod(com.axway.apim.cli.CLIServiceMethod)

Example 5 with UserExportParams

use of com.axway.apim.users.lib.params.UserExportParams in project apim-cli by Axway-API-Management-Plus.

the class UserCLIOptionsTest method testEnabledToggleDefault.

@Test
public void testEnabledToggleDefault() throws ParseException, AppException {
    String[] args = { "-s", "prod" };
    CLIOptions options = UserExportCLIOptions.create(args);
    UserExportParams params = (UserExportParams) options.getParams();
    Assert.assertNull(params.isEnabled(), "Should be null, if not given");
}
Also used : UserImportCLIOptions(com.axway.apim.users.lib.cli.UserImportCLIOptions) CLIOptions(com.axway.apim.lib.CLIOptions) UserChangePasswordCLIOptions(com.axway.apim.users.lib.cli.UserChangePasswordCLIOptions) UserExportCLIOptions(com.axway.apim.users.lib.cli.UserExportCLIOptions) UserExportParams(com.axway.apim.users.lib.params.UserExportParams) Test(org.testng.annotations.Test)

Aggregations

UserExportParams (com.axway.apim.users.lib.params.UserExportParams)5 CLIServiceMethod (com.axway.apim.cli.CLIServiceMethod)2 CLIOptions (com.axway.apim.lib.CLIOptions)2 AppException (com.axway.apim.lib.errorHandling.AppException)2 UserChangePasswordCLIOptions (com.axway.apim.users.lib.cli.UserChangePasswordCLIOptions)2 UserExportCLIOptions (com.axway.apim.users.lib.cli.UserExportCLIOptions)2 UserImportCLIOptions (com.axway.apim.users.lib.cli.UserImportCLIOptions)2 Test (org.testng.annotations.Test)2 ExportResult (com.axway.apim.lib.ExportResult)1 UserApp (com.axway.apim.users.UserApp)1 ValidationException (com.consol.citrus.exceptions.ValidationException)1