org.testng.annotations.Optional Java Examples

The following examples show how to use org.testng.annotations.Optional. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GetJwksTest.java    From oxd with Apache License 2.0 6 votes vote down vote up
@Test
@Parameters({"opHost", "opDiscoveryPath"})
public void test(String opHost, @Optional String opDiscoveryPath) throws Exception {

    final DevelopersApi client = api();

    final GetJwksParams params = new GetJwksParams();
    params.setOpHost(opHost);
    params.setOpDiscoveryPath(opDiscoveryPath);

    final GetJwksResponse response = client.getJsonWebKeySet(params, Tester.getAuthorization(), null);
    assertNotNull(response);
    assertNotNull(response.getKeys());
    assertFalse(response.getKeys().isEmpty());

}
 
Example #2
Source File: MethodLevelInvalidProfileTestIT.java    From apimanager-swagger-promote with Apache License 2.0 6 votes vote down vote up
@CitrusTest
@Test @Parameters("context")
public void runInboundProfileValidation(@Optional @CitrusResource TestContext context) throws IOException, AppException {
	swaggerImport = new ImportTestAction();
	description("Make sure only valid profile names are referenced");
	
	variable("apiNumber", RandomNumberFunction.getRandomNumber(3, true));
	variable("apiPath", "/invalid-sec-profile-api-${apiNumber}");
	variable("apiName", "Invalid-SecProfile-API-${apiNumber}");
	
	echo("####### Try to replicate an API having invalid profiles referenced #######");		
	createVariable(ImportTestAction.API_DEFINITION,  "/com/axway/apim/test/files/basic/petstore.json");
	createVariable(ImportTestAction.API_CONFIG,  "/com/axway/apim/test/files/methodLevel/method-level-inbound-invalidProfileRefercence.json");
	createVariable("state", "unpublished");
	createVariable("expectedReturnCode", "73");
	createVariable("securityProfileName1", "APIKeyBased${apiNumber}");
	createVariable("securityProfileName2", "SomethingWrong${apiNumber}");
	swaggerImport.doExecute(context);
}
 
Example #3
Source File: InvalidQuotaConfigTestIT.java    From apimanager-swagger-promote with Apache License 2.0 6 votes vote down vote up
@CitrusTest
@Test @Parameters("context")
public void run(@Optional @CitrusResource TestContext context) throws IOException, AppException {
	swaggerImport = new ImportTestAction();
	description("Try to import an API with invalid quota configuration.");
	
	variable("apiNumber", RandomNumberFunction.getRandomNumber(3, true));
	variable("apiPath", "/invalid-quota-api-${apiNumber}");
	variable("apiName", "Invalid Quota-API-${apiNumber}");

	echo("####### Trying to import API: '${apiName}' on path: '${apiPath}' with invalid quota config #######");		
	createVariable(ImportTestAction.API_DEFINITION,  "/com/axway/apim/test/files/basic/petstore.json");
	createVariable(ImportTestAction.API_CONFIG,  "/com/axway/apim/test/files/quota/issue-109-invalid-quota-config-1.json");
	createVariable("state", "unpublished");
	createVariable("expectedReturnCode", "71");
	swaggerImport.doExecute(context);
	
	echo("####### Trying to import API: '${apiName}' on path: '${apiPath}' with invalid quota config #######");		
	createVariable(ImportTestAction.API_DEFINITION,  "/com/axway/apim/test/files/basic/petstore.json");
	createVariable(ImportTestAction.API_CONFIG,  "/com/axway/apim/test/files/quota/issue-109-invalid-quota-config-2.json");
	createVariable("state", "unpublished");
	createVariable("expectedReturnCode", "71");
	swaggerImport.doExecute(context);
}
 
Example #4
Source File: MethodLevelInvalidProfileTestIT.java    From apimanager-swagger-promote with Apache License 2.0 6 votes vote down vote up
@CitrusTest
@Test @Parameters("context")
public void runOutboundProfileValidation(@Optional @CitrusResource TestContext context) throws IOException, AppException {
	swaggerImport = new ImportTestAction();
	description("Make sure only valid profile names are referenced");
	
	variable("apiNumber", RandomNumberFunction.getRandomNumber(3, true));
	variable("apiPath", "/invalid-authn-profile-api-${apiNumber}");
	variable("apiName", "Invalid AuthN-Profile-API-${apiNumber}");
	
	echo("####### Try to replicate an API having invalid profiles referenced #######");		
	createVariable(ImportTestAction.API_DEFINITION,  "/com/axway/apim/test/files/basic/petstore.json");
	createVariable(ImportTestAction.API_CONFIG,  "/com/axway/apim/test/files/methodLevel/method-level-outboundbound-invalidProfileReference.json");
	createVariable("state", "unpublished");
	createVariable("expectedReturnCode", "73");
	createVariable("authenticationProfileName1", "HTTP Basic");
	createVariable("authenticationProfileName2", "SomethingWrong");
	swaggerImport.doExecute(context);
}
 
Example #5
Source File: MethodLevelInvalidProfileTestIT.java    From apimanager-swagger-promote with Apache License 2.0 6 votes vote down vote up
@CitrusTest
@Test @Parameters("context")
public void runInboundCorsProfileValidation(@Optional @CitrusResource TestContext context) throws IOException, AppException {
	swaggerImport = new ImportTestAction();
	description("Is the CORS-Profile not know - Error must be handled");
	
	variable("apiNumber", RandomNumberFunction.getRandomNumber(3, true));
	variable("apiPath", "/basic-method-level-api-${apiNumber}");
	variable("apiName", "Basic Method-Level-API-${apiNumber}");
	
	echo("####### Try to replicate an API having invalid profiles referenced #######");		
	createVariable(ImportTestAction.API_DEFINITION,  "/com/axway/apim/test/files/basic/petstore.json");
	createVariable(ImportTestAction.API_CONFIG,  "/com/axway/apim/test/files/methodLevel/method-level-inbound-invalidCorsProfileRefercence.json");
	createVariable("state", "unpublished");
	createVariable("expectedReturnCode", "73");
	swaggerImport.doExecute(context);
}
 
Example #6
Source File: CommandRestTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Get Payara test server properties.
 * <p>
 * @return Payara test server properties.
 */
@BeforeSuite
@Parameters({ "rest-properties" })
public static Properties payaraProperties(@Optional String propertyFile) {
    if (payaraProperties != null) {
        return payaraProperties;
    }
    else {
        synchronized(CommandRestTest.class) {
            if (payaraProperties == null) {
                if (propertyFile == null)
                    propertyFile = PAYARA_PROPERTES;
                payaraProperties = readProperties(propertyFile);
            }
        }
        return payaraProperties;
    }
}
 
Example #7
Source File: CommandRestTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Get GlassFish test server properties.
 * <p>
 * @return GlassFish test server properties.
 */
@BeforeSuite
@Parameters({ "rest-properties" })
public static Properties glassfishProperties(@Optional String propertyFile) {
    if (glassfishProperties != null) {
        return glassfishProperties;
    }
    else {
        synchronized(CommandRestTest.class) {
            if (glassfishProperties == null) {
                if (propertyFile == null)
                    propertyFile = GLASSFISH_PROPERTES;
                glassfishProperties = readProperties(propertyFile);
            }
        }
        return glassfishProperties;
    }
}
 
Example #8
Source File: InboundMethodLevelInvalidOperationTestIT.java    From apimanager-swagger-promote with Apache License 2.0 6 votes vote down vote up
@CitrusTest
@Test @Parameters("context")
public void run(@Optional @CitrusResource TestContext context) throws IOException, AppException {
	swaggerImport = new ImportTestAction();
	description("Make sure, the error that an invalid operationId is given is properly handled.");
	
	variable("apiNumber", RandomNumberFunction.getRandomNumber(3, true));
	variable("apiPath", "/basic-method-level-api-${apiNumber}");
	variable("apiName", "Basic Method-Level-API-${apiNumber}");
	
	echo("####### Try to replicate an API having Method-Level settings declared #######");		
	createVariable(ImportTestAction.API_DEFINITION,  "/com/axway/apim/test/files/basic/petstore.json");
	createVariable(ImportTestAction.API_CONFIG,  "/com/axway/apim/test/files/methodLevel/method-level-inbound-invalidOperation.json");
	createVariable("state", "unpublished");
	createVariable("expectedReturnCode", "72");
	createVariable("securityProfileName", "APIKeyBased${apiNumber}");
	swaggerImport.doExecute(context);
}
 
Example #9
Source File: NoAPIDefinitionConfiguredIT.java    From apimanager-swagger-promote with Apache License 2.0 6 votes vote down vote up
@CitrusTest
@Test @Parameters("context")
public void run(@Optional @CitrusResource TestContext context) throws IOException, AppException {
	swaggerImport = new ImportTestAction();
	description("If no api-definition is passed as argument and no apiDefinition attribute is found in configuration file, the tool must fail with a dedicated return code.");
	
	variable("apiNumber", RandomNumberFunction.getRandomNumber(3, true));
	variable("apiPath", "/my-no-api-def-${apiNumber}");
	variable("apiName", "No-API-DEF-CONFIGURED-${apiNumber}");

	echo("####### Calling the tool with a Non-Admin-User. #######");
	createVariable(ImportTestAction.API_DEFINITION,  "");
	createVariable(ImportTestAction.API_CONFIG,  "/com/axway/apim/test/files/basic/minimal-config.json");
	createVariable("status", "unpublished");
	createVariable("expectedReturnCode", String.valueOf(ErrorCode.NO_API_DEFINITION_CONFIGURED.getCode()));
	swaggerImport.doExecute(context);
}
 
Example #10
Source File: OrgAdminTriesToPublishTestIT.java    From apimanager-swagger-promote with Apache License 2.0 6 votes vote down vote up
@CitrusTest
@Test @Parameters("context")
public void run(@Optional @CitrusResource TestContext context) throws IOException, AppException {
	swaggerImport = new ImportTestAction();
	
	description("But OrgAdmins should not being allowed to register published APIs.");
	
	variable("apiNumber", RandomNumberFunction.getRandomNumber(3, true));
	variable("apiPath", "/org-admin-published-${apiNumber}");
	variable("apiName", "OrgAdmin-Published-${apiNumber}");
	variable("ignoreAdminAccount", "true"); // This tests simulate to use only an Org-Admin-Account
	variable("allowOrgAdminsToPublish", "false"); // Disable OrgAdmins to publish APIs

	echo("####### Calling the tool with a Non-Admin-User. #######");
	createVariable(ImportTestAction.API_DEFINITION,  "/com/axway/apim/test/files/basic/petstore.json");
	createVariable(ImportTestAction.API_CONFIG,  "/com/axway/apim/test/files/basic/2_initially_published.json");
	createVariable("expectedReturnCode", "17");
	createVariable("apiManagerUser", "${oadminUsername1}"); // This is an org-admin user
	createVariable("apiManagerPass", "${oadminPassword1}");
	swaggerImport.doExecute(context);
}
 
Example #11
Source File: CustomPoliciesTestIT.java    From apimanager-swagger-promote with Apache License 2.0 6 votes vote down vote up
@CitrusTest
@Test @Parameters("context")
public void run(@Optional @CitrusResource TestContext context) throws IOException {		
	description("Import an API to export it afterwards");

	variable("apiNumber", RandomNumberFunction.getRandomNumber(3, true));
	variable("apiPath", "/api/test/"+this.getClass().getSimpleName()+"-${apiNumber}");
	variable("apiName", this.getClass().getSimpleName()+"-${apiNumber}");
	variable("state", "published");
	


	echo("####### Importing the API, which should exported in the second step #######");
	createVariable(ImportTestAction.API_DEFINITION,  "/test/export/files/basic/petstore.json");
	createVariable(ImportTestAction.API_CONFIG,  "/test/export/files/customPolicies/custom-policies-issue-156.json");
	createVariable("requestPolicy", "Request policy 1");
	createVariable("responsePolicy", "Response policy 1");
	createVariable("tokenInfoPolicy", "Tokeninfo policy 1");
	createVariable("expectedReturnCode", "0");
	swaggerImport.doExecute(context);
	
	exportAPI(context, false);
	exportAPI(context, true);
}
 
Example #12
Source File: GetJwksTest.java    From oxd with Apache License 2.0 6 votes vote down vote up
@Test
@Parameters({"opDiscoveryPath"})
public void testWithNoOP(@Optional String opDiscoveryPath) throws Exception {

    final DevelopersApi client = api();

    final GetJwksParams params = new GetJwksParams();
    params.setOpDiscoveryPath(opDiscoveryPath);

    try {
        client.getJsonWebKeySetWithHttpInfo(params, Tester.getAuthorization(), null);
    } catch (ApiException ex) {
        assertEquals(ex.getCode(), 400);
    }

}
 
Example #13
Source File: PerfHashBenchmark.java    From concurrentlinkedhashmap with Apache License 2.0 6 votes vote down vote up
@Test(groups = "perfHash")
@Parameters({"readRatio", "threadMin", "threadMax", "threadIncrement",
  "hashTableSize", "hashTableImpl"})
public static void benchmark(String readRatio, String threadMin, String threadMax,
    String threadIncrement, String hashTableSize, @Optional("0") String hashTableImpl)
    throws Exception {
  String[] args = {
    readRatio,
    threadMin,
    threadMax,
    threadIncrement,
    hashTableSize,
    hashTableImpl
  };
  main(args);
}
 
Example #14
Source File: GluuConfigurationWSTest.java    From oxAuth with MIT License 6 votes vote down vote up
@RunAsClient
@Parameters({ "gluuConfigurationPath", "webTarget" })
@Consumes(MediaType.APPLICATION_JSON)
@Test
public void getConfigurationTest(String gluuConfigurationPath,
		@Optional @ArquillianResteasyResource("") final WebTarget webTarget) throws Exception {
	Response response = webTarget.path(gluuConfigurationPath).request().get();
	String entity = response.readEntity(String.class);
	BaseTest.showResponse("UMA : TConfiguration.configuration", response, entity);

	assertEquals(response.getStatus(), 200, "Unexpected response code.");
	try {
		GluuConfiguration appConfiguration = ServerUtil.createJsonMapper().readValue(entity,
				GluuConfiguration.class);
		System.err.println(appConfiguration.getIdGenerationEndpoint());
		assertNotNull(appConfiguration, "Meta data configuration is null");
		assertNotNull(appConfiguration.getIdGenerationEndpoint());
		assertNotNull(appConfiguration.getIntrospectionEndpoint());
		assertNotNull(appConfiguration.getAuthLevelMapping());
		assertNotNull(appConfiguration.getScopeToClaimsMapping());
	} catch (IOException e) {
		e.printStackTrace();
		fail();
	}
}
 
Example #15
Source File: CompleteAPIExportTestIT.java    From apimanager-swagger-promote with Apache License 2.0 6 votes vote down vote up
@CitrusTest
@Test @Parameters("context")
public void run(@Optional @CitrusResource TestContext context) throws IOException, InterruptedException {
	description("Import an API, export it afterwards and validate it equals to the imported API");
	variable("apiNumber", RandomNumberFunction.getRandomNumber(3, true));
	variable("apiPath", "/api/test/"+this.getClass().getSimpleName()+"-${apiNumber}");
	variable("apiName", this.getClass().getSimpleName()+"-${apiNumber}");
	variable("state", "published");
	
	echo("####### Importing the API, which should exported in the second step #######");
	createVariable(ImportTestAction.API_DEFINITION,  "/test/export/files/basic/petstore.json");
	createVariable(ImportTestAction.API_CONFIG,  "/test/export/files/basic/complete-config.json");
	createVariable("image", "/com/axway/apim/test/files/basic/API-Logo.jpg");
	createVariable("expectedReturnCode", "0");
	
	swaggerImport.doExecute(context);
	if(APIManagerAdapter.hasAPIManagerVersion("7.7.20200130")) {
		Thread.sleep(1000); // Starting with this version, we need to wait a few milliseconds, otherwise the REST-API doesn't return the complete set of quotas
	}
	
	exportAPI(context, false);
	exportAPI(context, true);
}
 
Example #16
Source File: IntiallyPublishedAPITestIT.java    From apimanager-swagger-promote with Apache License 2.0 5 votes vote down vote up
@CitrusTest
@Test @Parameters("context")
public void run(@Optional @CitrusResource TestContext context) throws IOException, AppException {
	swaggerImport = new ImportTestAction();
	description("Import an API which initially has the status published.");
	
	variable("apiNumber", RandomNumberFunction.getRandomNumber(3, true));
	variable("apiPath", "/initially-published-${apiNumber}");
	variable("apiName", "Initially-Published-API-${apiNumber}");

	
	echo("####### Importing API: '${apiName}' on path: '${apiPath}' for the first time #######");
	
	createVariable(ImportTestAction.API_DEFINITION,  "/com/axway/apim/test/files/basic/petstore.json");
	createVariable(ImportTestAction.API_CONFIG,  "/com/axway/apim/test/files/basic/2_initially_published.json");
	createVariable("expectedReturnCode", "0");
	swaggerImport.doExecute(context);
	
	echo("####### Validate API: '${apiName}' on path: '${apiPath}' has been imported #######");
	http(builder -> builder.client("apiManager").send().get("/proxies").header("Content-Type", "application/json"));

	http(builder -> builder.client("apiManager").receive().response(HttpStatus.OK).messageType(MessageType.JSON)
		.validate("$.[?(@.path=='${apiPath}')].name", "${apiName}")
		.validate("$.[?(@.path=='${apiPath}')].state", "published")
		.validate("$.[?(@.path=='${apiPath}')].securityProfiles[0].devices[0].type", "apiKey")
		.extractFromPayload("$.[?(@.path=='${apiPath}')].id", "apiId"));
}
 
Example #17
Source File: UnpublishDeleteMustBeBreakingTestIT.java    From apimanager-swagger-promote with Apache License 2.0 5 votes vote down vote up
@CitrusTest
@Test @Parameters("context")
public void run(@Optional @CitrusResource TestContext context) throws IOException, AppException {
	swaggerImport = new ImportTestAction();
	echo("####### This test makes sure, once an API is published, unpublishing or deleting it requires a force #######");
	
	variable("apiNumber", RandomNumberFunction.getRandomNumber(4, true));
	variable("apiPath", "/check-is-breaking-${apiNumber}");
	variable("apiName", "Check-is-Breaking-${apiNumber}");

	
	echo("####### Importing API: '${apiName}' on path: '${apiPath}' as Published #######");
	createVariable(ImportTestAction.API_DEFINITION,  "/com/axway/apim/test/files/basic/petstore.json");
	createVariable(ImportTestAction.API_CONFIG,  "/com/axway/apim/test/files/basic/4_flexible-status-config.json");
	createVariable("state", "published");
	createVariable("expectedReturnCode", "0");
	swaggerImport.doExecute(context);
	
	echo("####### Validate unpublishing it, will fail, with the need to enforce it #######");
	createVariable(ImportTestAction.API_DEFINITION,  "/com/axway/apim/test/files/basic/petstore.json");
	createVariable(ImportTestAction.API_CONFIG,  "/com/axway/apim/test/files/basic/4_flexible-status-config.json");
	createVariable("state", "unpublished");
	createVariable("expectedReturnCode", "15");
	swaggerImport.doExecute(context);
	
	echo("####### Validate deleting it, will fail, with the need to enforce it #######");
	createVariable(ImportTestAction.API_DEFINITION,  "/com/axway/apim/test/files/basic/petstore.json");
	createVariable(ImportTestAction.API_CONFIG,  "/com/axway/apim/test/files/basic/4_flexible-status-config.json");
	createVariable("state", "deleted");
	createVariable("expectedReturnCode", "15");
	swaggerImport.doExecute(context);
}
 
Example #18
Source File: WSDLFromURLRefFileTestIT.java    From apimanager-swagger-promote with Apache License 2.0 5 votes vote down vote up
@CitrusTest
@Test @Parameters("context")
public void run(@Optional @CitrusResource TestContext context) throws IOException, AppException {
	swaggerImport = new ImportTestAction();
	description("Validates a WSDL-File can be taken from a URL using a REF-File.");
	
	variable("apiNumber", RandomNumberFunction.getRandomNumber(3, true));
	variable("apiPath", "/ref-file-wsdl-${apiNumber}");
	variable("apiName", "Ref-File-WSDL from URL-${apiNumber}");
	

	
	echo("####### Importing API: '${apiName}' on path: '${apiPath}' for the first time from URL #######");
	createVariable(ImportTestAction.API_DEFINITION, "/com/axway/apim/test/files/wsdl/wsdl-file-with-username.url");
	createVariable(ImportTestAction.API_CONFIG, "/com/axway/apim/test/files/wsdl/wsdl-minimal-config.json");
	createVariable("status", "unpublished");
	createVariable("expectedReturnCode", "0");
	swaggerImport.doExecute(context);
	
	echo("####### Validate API: '${apiName}' on path: '${apiPath}' has been imported #######");
	http(builder -> builder.client("apiManager").send().get("/proxies").name("api").header("Content-Type", "application/json"));

	http(builder -> builder.client("apiManager").receive().response(HttpStatus.OK).messageType(MessageType.JSON)
		.validate("$.[?(@.path=='${apiPath}')].name", "${apiName}")
		.validate("$.[?(@.path=='${apiPath}')].state", "unpublished")
		.extractFromPayload("$.[?(@.path=='${apiPath}')].id", "apiId"));
	
	echo("####### Re-Import API from URL without a change #######");
	createVariable(ImportTestAction.API_DEFINITION, "/com/axway/apim/test/files/wsdl/wsdl-file-with-username.url");
	createVariable(ImportTestAction.API_CONFIG, "/com/axway/apim/test/files/wsdl/wsdl-minimal-config.json");
	createVariable("status", "unpublished");
	createVariable("expectedReturnCode", "10");
	swaggerImport.doExecute(context);
}
 
Example #19
Source File: AutoscaleTestSuiteInitializer.java    From cloudbreak with Apache License 2.0 5 votes vote down vote up
@BeforeSuite(dependsOnMethods = "initContext")
@Parameters("periscopeServer")
public void initCloudbreakSuite(@Optional("") String periscopeServer, @Optional("") String caasProtocol, @Optional("") String caasAddress) {
    periscopeServer = StringUtils.hasLength(periscopeServer) ? periscopeServer : defaultPeriscopeServer;
    String userCrn = itContext.getContextParam(IntegrationTestContext.USER_CRN);

    AutoscaleUserCrnClient autoscaleClient = new AutoscaleUserCrnClientBuilder(periscopeServer + autoscaleRootContextPath).build();

    itContext.putContextParam(CloudbreakITContextConstants.AUTOSCALE_CLIENT, autoscaleClient.withCrn(userCrn));
}
 
Example #20
Source File: BindDnsServerByonLiveTest.java    From brooklyn-library with Apache License 2.0 5 votes vote down vote up
@Test(groups = "Live")
@Parameters({"locationSpec"})
public void testDns(@Optional String locationSpec) throws Exception {
    if (Strings.isBlank(locationSpec)) {
        LOG.info("{} got no spec, skipping test", this);
    } else {
        Location testLocation = mgmt.getLocationRegistry().getLocationManaged(locationSpec);
        BindDnsServerLiveTest.testBindStartsAndUpdates(app, testLocation);
    }
}
 
Example #21
Source File: ZooKeeperEnsembleLiveTest.java    From brooklyn-library with Apache License 2.0 5 votes vote down vote up
@BeforeClass(alwaysRun = true)
@Parameters({"locationSpec"})
public void setLocationSpec(@Optional String locationSpec) {
    this.locationSpec = !Strings.isBlank(locationSpec)
                        ? locationSpec
                        : DEFAULT_LOCATION;
    log.info("Running {} with in {}", this, this.locationSpec);
}
 
Example #22
Source File: BaseActions.java    From kspl-selenium-helper with GNU General Public License v3.0 5 votes vote down vote up
/**
 * This gets invoked even before suite starts.
 * @param ReportLocation - Provide location where you want to store the report
 */
@Parameters({"ReportLocation"})
@BeforeSuite
public void beforeSuite(@Optional String ReportLocation){
	log = new Log();
	log.setReportDirectory(ReportLocation);
}
 
Example #23
Source File: GetJwksTest.java    From oxd with Apache License 2.0 5 votes vote down vote up
@Test(enabled = false)
@Parameters({"host", "opHost", "opDiscoveryPath"})
public void test(String host, String opHost, @Optional String opDiscoveryPath) {

    final ClientInterface client = Tester.newClient(host);

    final GetJwksParams params = new GetJwksParams();
    params.setOpHost(opHost);
    params.setOpDiscoveryPath(opDiscoveryPath);

    final GetJwksResponse response = client.getJwks(Tester.getAuthorization(), null, params);
    assertNotNull(response);
    assertNotNull(response.getKeys());
    assertFalse(response.getKeys().isEmpty());
}
 
Example #24
Source File: TestBaseRunner.java    From heat with Apache License 2.0 5 votes vote down vote up
/**
 * Method that takes test suites parameters and sets some environment properties.
 * @param propFilePath path of the property file data
 * @param inputWebappName name of the service to test (optional parameter)
 * @param context testNG context
 */
@BeforeSuite
@Override
@Parameters({ENV_PROP_FILE_PATH, WEBAPP_NAME})
public void beforeTestSuite(String propFilePath,
                            @Optional(NO_INPUT_WEBAPP_NAME) String inputWebappName,
                            ITestContext context) {
    TestSuiteHandler testSuiteHandler = TestSuiteHandler.getInstance();
    testSuiteHandler.setPropertyFilePath(propFilePath);
    testSuiteHandler.populateEnvironmentHandler();
    testSuiteHandler.populateTestCaseUtils();

}
 
Example #25
Source File: SwaggerFromFileInConfigurationTestIT.java    From apimanager-swagger-promote with Apache License 2.0 5 votes vote down vote up
@CitrusTest
@Test @Parameters("context")
public void run(@Optional @CitrusResource TestContext context) throws IOException, AppException {
	swaggerImport = new ImportTestAction();
	description("Validates a Swagger-File can be taken from a file path described in json configuration file");
	
	variable("apiNumber", RandomNumberFunction.getRandomNumber(3, true));
	variable("apiPath", "/file-swagger-in-configuration-${apiNumber}");
	variable("apiName", "File-Swagger in configuration from URL-${apiNumber}");
	

	
	echo("####### Importing API: '${apiName}' on path: '${apiPath}' for the first time from URL #######");
	createVariable(ImportTestAction.API_DEFINITION,  "");
	createVariable(ImportTestAction.API_CONFIG,  "/com/axway/apim/test/files/basic/minimal-config-with-api-definition.json");
	createVariable("testAPIDefinition","./src/test/resources/com/axway/apim/test/files/basic/petstore.json");
	createVariable("status", "unpublished");
	createVariable("expectedReturnCode", "0");
	swaggerImport.doExecute(context);
	
	echo("####### Validate API: '${apiName}' on path: '${apiPath}' has been imported #######");
	http(builder -> builder.client("apiManager").send().get("/proxies").header("Content-Type", "application/json"));

	http(builder -> builder.client("apiManager").receive().response(HttpStatus.OK).messageType(MessageType.JSON)
		.validate("$.[?(@.path=='${apiPath}')].name", "${apiName}")
		.validate("$.[?(@.path=='${apiPath}')].state", "unpublished")
		.extractFromPayload("$.[?(@.path=='${apiPath}')].id", "apiId"));
	
	echo("####### Re-Import API from URL without a change #######");
	createVariable(ImportTestAction.API_DEFINITION,  "");
	createVariable(ImportTestAction.API_CONFIG,  "/com/axway/apim/test/files/basic/minimal-config-with-api-definition.json");
	createVariable("testAPIDefinition","./src/test/resources/com/axway/apim/test/files/basic/petstore.json");
	createVariable("status", "unpublished");
	createVariable("expectedReturnCode", "10");
	swaggerImport.doExecute(context);
}
 
Example #26
Source File: SwaggerFromURLRefFileInConfigurationTestIT.java    From apimanager-swagger-promote with Apache License 2.0 5 votes vote down vote up
@CitrusTest
@Test @Parameters("context")
public void run(@Optional @CitrusResource TestContext context) throws IOException, AppException {
	swaggerImport = new ImportTestAction();
	description("Validates a Swagger-File can be taken from a URL using a REF-File described in API json configuration");
	
	variable("apiNumber", RandomNumberFunction.getRandomNumber(3, true));
	variable("apiPath", "/ref-file-swagger-in-configuration-${apiNumber}");
	variable("apiName", "Ref-File-Swagger in configuration from URL-${apiNumber}");
	

	
	echo("####### Importing API: '${apiName}' on path: '${apiPath}' for the first time from URL #######");
	createVariable(ImportTestAction.API_DEFINITION,  "");
	createVariable(ImportTestAction.API_CONFIG,  "/com/axway/apim/test/files/basic/minimal-config-with-api-definition.json");
	createVariable("testAPIDefinition","./src/test/resources/com/axway/apim/test/files/basic/swagger-file-with-username.url");
	createVariable("status", "unpublished");
	createVariable("expectedReturnCode", "0");
	swaggerImport.doExecute(context);
	
	echo("####### Validate API: '${apiName}' on path: '${apiPath}' has been imported #######");
	http(builder -> builder.client("apiManager").send().get("/proxies").header("Content-Type", "application/json"));

	http(builder -> builder.client("apiManager").receive().response(HttpStatus.OK).messageType(MessageType.JSON)
		.validate("$.[?(@.path=='${apiPath}')].name", "${apiName}")
		.validate("$.[?(@.path=='${apiPath}')].state", "unpublished")
		.extractFromPayload("$.[?(@.path=='${apiPath}')].id", "apiId"));
	
	echo("####### Re-Import API from URL without a change #######");
	createVariable(ImportTestAction.API_DEFINITION,  "");
	createVariable(ImportTestAction.API_CONFIG,  "/com/axway/apim/test/files/basic/minimal-config-with-api-definition.json");
	createVariable("testAPIDefinition","./src/test/resources/com/axway/apim/test/files/basic/swagger-file-with-username.url");
	createVariable("status", "unpublished");
	createVariable("expectedReturnCode", "10");
	swaggerImport.doExecute(context);
}
 
Example #27
Source File: ImportUnpublishedSetToPublishedAPITestIT.java    From apimanager-swagger-promote with Apache License 2.0 5 votes vote down vote up
@CitrusTest
@Test @Parameters("context")
public void run(@Optional @CitrusResource TestContext context) throws IOException, AppException {
	swaggerImport = new ImportTestAction();
	echo("Import an Unpublished-API and in the second step publish it");
	
	variable("apiNumber", RandomNumberFunction.getRandomNumber(3, true));
	variable("apiPath", "/change-state-to-published-api-${apiNumber}");
	variable("apiName", "Change state to Published API ${apiNumber}");

	echo("####### Importing API: '${apiName}' on path: '${apiPath}' for the first time #######");		
	createVariable(ImportTestAction.API_DEFINITION,  "/com/axway/apim/test/files/basic/petstore.json");
	createVariable(ImportTestAction.API_CONFIG,  "/com/axway/apim/test/files/basic/4_flexible-status-config.json");
	createVariable("state", "unpublished");
	createVariable("expectedReturnCode", "0");
	swaggerImport.doExecute(context);
	
	echo("####### Validate API: '${apiName}' on path: '${apiPath}' has been imported #######");
	http(builder -> builder.client("apiManager").send().get("/proxies")	.header("Content-Type", "application/json"));

	http(builder -> builder.client("apiManager").receive().response(HttpStatus.OK).messageType(MessageType.JSON)
		.validate("$.[?(@.path=='${apiPath}')].name", "${apiName}")
		.validate("$.[?(@.path=='${apiPath}')].state", "${state}")
		.extractFromPayload("$.[?(@.path=='${apiPath}')].id", "apiId"));
	
	echo("####### Change API-State from Unpublished to Published #######");
	createVariable(ImportTestAction.API_DEFINITION,  "/com/axway/apim/test/files/basic/petstore.json");
	createVariable(ImportTestAction.API_CONFIG,  "/com/axway/apim/test/files/basic/4_flexible-status-config.json");
	createVariable("state", "published");
	createVariable("expectedReturnCode", "0");
	swaggerImport.doExecute(context);
	
	echo("####### Validate the API-ID hasn't changed by that change #######");
	http(builder -> builder.client("apiManager").send().get("/proxies/${apiId}").header("Content-Type", "application/json"));

	http(builder -> builder.client("apiManager").receive().response(HttpStatus.OK).messageType(MessageType.JSON)
		.validate("$.[?(@.path=='${apiPath}')].name", "${apiName}")
		.validate("$.[?(@.path=='${apiPath}')].state", "${state}")
		.validate("$.[?(@.path=='${apiPath}')].id", "${apiId}"));
}
 
Example #28
Source File: SpecialCharactersAPITestIT.java    From apimanager-swagger-promote with Apache License 2.0 5 votes vote down vote up
@CitrusTest
@Test @Parameters("context")
public void run(@Optional @CitrusResource TestContext context) throws IOException, AppException {
	swaggerImport = new ImportTestAction();
	description("Import an API having some special characters in the Swagger & API-Config-File.");
	
	variable("apiNumber", RandomNumberFunction.getRandomNumber(3, true));
	variable("apiPath", "/special-chars-${apiNumber}");
	variable("apiName", "Special-Chars-${apiNumber}");

	echo("####### Importing Special-Chars API: '${apiName}' on path: '${apiPath}' #######");
	createVariable(ImportTestAction.API_DEFINITION,  "/com/axway/apim/test/files/basic/petstore-special-chars.json");
	createVariable(ImportTestAction.API_CONFIG,  "/com/axway/apim/test/files/basic/special-chars-config.json");
	createVariable("state", "unpublished");
	createVariable("expectedReturnCode", "0");
	swaggerImport.doExecute(context);

	echo("####### Validate API: '${apiName}' on path: '${apiPath}' has been imported #######");
	http(builder -> builder.client("apiManager").send().get("/proxies").header("Content-Type", "application/json"));

	http(builder -> builder.client("apiManager").receive().response(HttpStatus.OK).messageType(MessageType.JSON)
		.validate("$.[?(@.path=='${apiPath}')].name", "${apiName}")
		// TODO: Find a way to validate unicode characters as well
		//.validate("$.[?(@.path=='${apiPath}')].summary", "�дпат или умри.")
		.extractFromPayload("$.[?(@.path=='${apiPath}')].id", "apiId"));

	echo("####### RE-Importing same API: '${apiName}' on path: '${apiPath}' without changes. Expecting failure with RC 99. #######");
	createVariable(ImportTestAction.API_DEFINITION,  "/com/axway/apim/test/files/basic/petstore-special-chars.json");
	createVariable(ImportTestAction.API_CONFIG,  "/com/axway/apim/test/files/basic/special-chars-config.json");
	createVariable("expectedReturnCode", "10");
	swaggerImport.doExecute(context);
}
 
Example #29
Source File: BaseWeb.java    From selenium-java-bootstrap with MIT License 5 votes vote down vote up
@BeforeMethod(alwaysRun = true)
@Parameters("browser")
public void preCondition(@Optional("chrome") String browser) {
    Configuration configuration = ConfigurationManager.getConfiguration();

    WebDriver driver = DriverFactory.createInstance(browser);
    DriverManager.setDriver(driver);

    DriverManager.getDriver().get(configuration.url());
}
 
Example #30
Source File: CloudbreakTestSuiteInitializer.java    From cloudbreak with Apache License 2.0 5 votes vote down vote up
@BeforeSuite(dependsOnMethods = "initContext")
@Parameters({"cloudbreakServer", "cloudProvider", "credentialName", "instanceGroups", "hostGroups", "blueprintName",
        "stackName", "networkName", "securityGroupName"})
public void initCloudbreakSuite(@Optional("") String cloudbreakServer, @Optional("") String cloudProvider, @Optional("") String credentialName,
        @Optional("") String instanceGroups, @Optional("") String hostGroups, @Optional("") String blueprintName,
        @Optional("") String stackName, @Optional("") String networkName, @Optional("") String securityGroupName) {
    cloudbreakServer = StringUtils.hasLength(cloudbreakServer) ? cloudbreakServer : defaultCloudbreakServer;
    String cbServerRoot = cloudbreakServer + cbRootContextPath;

    itContext.putContextParam(CloudbreakITContextConstants.SKIP_REMAINING_SUITETEST_AFTER_ONE_FAILED, skipRemainingSuiteTestsAfterOneFailed);
    itContext.putContextParam(CloudbreakITContextConstants.CLOUDBREAK_SERVER, cloudbreakServer);
    itContext.putContextParam(CloudbreakITContextConstants.CLOUDBREAK_SERVER_ROOT, cbServerRoot);
    itContext.putContextParam(CloudbreakITContextConstants.CLOUDPROVIDER, cloudProvider);

    CloudbreakServiceUserCrnClient cloudbreakClient = new CloudbreakUserCrnClientBuilder(cbServerRoot)
            .withCertificateValidation(false)
            .withIgnorePreValidation(true)
            .withDebug(true)
            .build();

    itContext.putContextParam(CloudbreakITContextConstants.CLOUDBREAK_CLIENT, cloudbreakClient);
    Long workspaceId = itContext.getContextParam(CloudbreakITContextConstants.WORKSPACE_ID, Long.class);
    if (cleanUpBeforeStart) {
        cleanUpService.deleteTestStacksAndResources(cloudbreakClient.withCrn(userCrn), workspaceId);
    }
    putBlueprintToContextIfExist(itContext.getContextParam(CloudbreakITContextConstants.CLOUDBREAK_CLIENT, CloudbreakClient.class)
            .blueprintV4Endpoint(), blueprintName, workspaceId);
    putStackToContextIfExist(itContext.getContextParam(CloudbreakITContextConstants.CLOUDBREAK_CLIENT, CloudbreakClient.class)
            .stackV4Endpoint(), workspaceId, stackName);
    if (StringUtils.hasLength(instanceGroups)) {
        List<String[]> instanceGroupStrings = templateAdditionHelper.parseCommaSeparatedRows(instanceGroups);
    }
    if (StringUtils.hasLength(hostGroups)) {
        List<String[]> hostGroupStrings = templateAdditionHelper.parseCommaSeparatedRows(hostGroups);
        itContext.putContextParam(CloudbreakITContextConstants.HOSTGROUP_ID, createHostGroups(hostGroupStrings));
    }
}