com.consol.citrus.annotations.CitrusTest Java Examples

The following examples show how to use com.consol.citrus.annotations.CitrusTest. 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: InvalidDevelopmentOrgTestIT.java    From apimanager-swagger-promote with Apache License 2.0 6 votes vote down vote up
@CitrusTest
public void runUnknownOrg() {
	description("Validates correct handling of invalid Owning-Organizations.");
	
	variable("apiNumber", RandomNumberFunction.getRandomNumber(3, true));
	variable("apiPath", "/invalid-org-${apiNumber}");
	variable("apiName", "Invalid organization ${apiNumber}");
	// Directly use an admin-account, otherwise the OrgAdmin organization is used by default
	variable("oadminUsername1", "apiadmin"); 
	variable("oadminPassword1", "changeme");
	variable("testOrgName", "Invalid organization ${orgNumber}");
	
	variable("testOrgName", "Org without permission ${apiNumber}");
	
	echo("####### Try to import an API with an invalid organization - Must be handled with a proper error-code and message #######");
	
	createVariable(ImportTestAction.API_DEFINITION,  "/com/axway/apim/test/files/basic/petstore.json");
	createVariable(ImportTestAction.API_CONFIG,  "/com/axway/apim/test/files/organizations/dynamic-organization.json");
	createVariable("state", "published");
	createVariable("expectedReturnCode", "57");
	action(swaggerImport);
}
 
Example #2
Source File: UnkownPolicyConfiguredTestIT.java    From apimanager-swagger-promote with Apache License 2.0 6 votes vote down vote up
@CitrusTest(name = "UnkownPolicyConfiguredTest")
public void run() {
	description("A dedicated return-code is expected, when an unknown policy is configured.");
	
	variable("apiNumber", RandomNumberFunction.getRandomNumber(3, true));
	variable("apiPath", "/unknown-policy-test-${apiNumber}");
	variable("apiName", "Unknown Policy Test ${apiNumber}");
	variable("status", "unpublished");
	

	echo("####### Importing API: '${apiName}' on path: '${apiPath}' with following settings: #######");
	createVariable("requestPolicy", "Brand new policy!");
	createVariable(ImportTestAction.API_DEFINITION,  "/com/axway/apim/test/files/security/petstore.json");
	createVariable(ImportTestAction.API_CONFIG,  "/com/axway/apim/test/files/policies/1_request-policy.json");
	createVariable("expectedReturnCode", "85");
	action(swaggerImport);
}
 
Example #3
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 #4
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 #5
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 #6
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 #7
Source File: OrgAdminCustomPropertiesTestIT.java    From apimanager-swagger-promote with Apache License 2.0 6 votes vote down vote up
@CitrusTest(name = "OrgAdminTriesToPublishTestIT")
public void run() {
	description("OrgAdmin wants to use a custom policy.");
	
	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

	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/customproperties/1_custom-properties-config.json");
	createVariable("status", "unpublished");
	createVariable("customProperty1", "Test-Input 1");
	createVariable("customProperty2", "1");
	createVariable("customProperty3", "true");
	createVariable("expectedReturnCode", "0");
	createVariable("apiManagerUser", "${oadminUsername1}"); // This is an org-admin user
	createVariable("apiManagerPass", "${oadminPassword1}");
	action(swaggerImport);
}
 
Example #8
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 #9
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 #10
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 #11
Source File: NoAuthenticationGivenTestIT.java    From apimanager-swagger-promote with Apache License 2.0 5 votes vote down vote up
@CitrusTest(name = "NoAuthenticationGivenTest")
public void run() {
	description("Verify no error appears, if Authentication is not configured! Must be Passthrough");
	
	variable("apiNumber", RandomNumberFunction.getRandomNumber(3, true));
	variable("apiPath", "/no-authn-test-${apiNumber}");
	variable("apiName", "No AuthN Test ${apiNumber}");
	variable("status", "unpublished");
	

	echo("####### Importing API: '${apiName}' on path: '${apiPath}' with following settings: #######");
	createVariable(ImportTestAction.API_DEFINITION,  "/com/axway/apim/test/files/security/petstore.json");
	createVariable(ImportTestAction.API_CONFIG,  "/com/axway/apim/test/files/security/2_no_authn.json");
	createVariable("expectedReturnCode", "0");
	action(swaggerImport);
	
	echo("####### Validate API: '${apiName}' on path: '${apiPath}' with Passthrough-Security #######");
	http().client("apiManager")
		.send()
		.get("/proxies")
		.name("api")
		.header("Content-Type", "application/json");

	http().client("apiManager")
		.receive()
		.response(HttpStatus.OK)
		.messageType(MessageType.JSON)
		.validate("$.[?(@.path=='${apiPath}')].name", "${apiName}")
		.validate("$.[?(@.path=='${apiPath}')].state", "unpublished")
		.validate("$.[?(@.path=='${apiPath}')].securityProfiles[0].devices[0].type", "passThrough")
		.extractFromPayload("$.[?(@.path=='${apiPath}')].id", "apiId");
}
 
Example #12
Source File: OutboundNoAuthWithPoliciesTestIT.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("Test to validate behavior if OutboundProfiles are set, but no AuthN-Profile. It should result into no AuthN.");

	variable("apiNumber", RandomNumberFunction.getRandomNumber(3, true));
	variable("apiPath", "/issue-133-noauth-${apiNumber}");
	variable("apiName", "Issue 133 No-Auth ${apiNumber}");
	
	echo("####### Importing API: '${apiName}' on path: '${apiPath}' Outbound-Profiles (for policies) not containing a AuthN-Profile. #######");
	createVariable(ImportTestAction.API_DEFINITION,  "/com/axway/apim/test/files/security/petstore.json");
	createVariable(ImportTestAction.API_CONFIG,  "/com/axway/apim/test/files/security/issue-133-outbound-profile-no-auth.json");
	createVariable("state", "unpublished");
	createVariable("expectedReturnCode", "0");
	swaggerImport.doExecute(context);
	
	echo("####### Validate API: '${apiName}' on path: '${apiPath}' with outbound security set to No-AuthN as this should be the default. #######");
	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")
			.validate("$.[?(@.path=='${apiPath}')].authenticationProfiles[0].name", "_default")
			.validate("$.[?(@.path=='${apiPath}')].authenticationProfiles[0].type", "none")
			.validate("$.[?(@.path=='${apiPath}')].authenticationProfiles[0].isDefault", "true")
			.validate("$.[?(@.path=='${apiPath}')].outboundProfiles._default.authenticationProfile", "_default")
			.validate("$.[?(@.path=='${apiPath}')].outboundProfiles._default.routeType", "policy")
			.extractFromPayload("$.[?(@.path=='${apiPath}')].id", "apiId"));
	
	echo("####### No-Change test for '${apiName}' on path: '${apiPath}' #######");
	createVariable(ImportTestAction.API_DEFINITION,  "/com/axway/apim/test/files/security/petstore.json");
	createVariable(ImportTestAction.API_CONFIG,  "/com/axway/apim/test/files/security/issue-133-outbound-profile-no-auth.json");
	createVariable("state", "unpublished");
	createVariable("expectedReturnCode", "10");
	swaggerImport.doExecute(context);
}
 
Example #13
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 #14
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 #15
Source File: NoChangeAPITestIT.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 and re-import it without any change. It must be detected, that no change happened.");
	
	variable("apiNumber", RandomNumberFunction.getRandomNumber(3, true));
	variable("apiPath", "/my-no-change-${apiNumber}");
	variable("apiName", "No-Change-${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/1_no-change-config.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}")
		.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.json");
	createVariable(ImportTestAction.API_CONFIG,  "/com/axway/apim/test/files/basic/1_no-change-config.json");
	createVariable("expectedReturnCode", "10");
	swaggerImport.doExecute(context);
	
	echo("####### Make sure, the API-ID hasn't changed #######");
	http(builder -> builder.client("apiManager").send().get("/proxies/${apiId}").header("Content-Type", "application/json"));

	// Check the API is still exposed on the same path
	http(builder -> builder.client("apiManager").receive().response(HttpStatus.OK).messageType(MessageType.JSON)
		.validate("$.[?(@.path=='${apiPath}')].name", "${apiName}")
		.validate("$.[?(@.path=='${apiPath}')].id", "${apiId}")); // Must be the same API-ID as before!
}
 
Example #16
Source File: OrgAdminCustomPoliciesTestIT.java    From apimanager-swagger-promote with Apache License 2.0 5 votes vote down vote up
@CitrusTest(name = "OrgAdminTriesToPublishTestIT")
public void run() {
	description("OrgAdmin wants to use a custom policy.");
	
	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

	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/policies/1_request-policy.json");
	createVariable("requestPolicy", "Request policy 1");
	createVariable("expectedReturnCode", "0");
	createVariable("apiManagerUser", "${oadminUsername1}"); // This is an org-admin user
	createVariable("apiManagerPass", "${oadminPassword1}");
	action(swaggerImport);
	
	echo("####### Validate API: '${apiName}' on path: '${apiPath}' has correct settings #######");
	http().client("apiManager")
		.send()
		.get("/proxies")
		.name("api")
		.header("Content-Type", "application/json");

	http().client("apiManager")
		.receive()
		.response(HttpStatus.OK)
		.messageType(MessageType.JSON)
		.validate("$.[?(@.path=='${apiPath}')].name", "${apiName}")
		.validate("$.[?(@.path=='${apiPath}')].state", "unpublished")
		.validate("$.[?(@.path=='${apiPath}')].outboundProfiles._default.requestPolicy", "@assertThat(containsString(Request policy 1))@")
		.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: CorsProfileBasicTestIT.java    From apimanager-swagger-promote with Apache License 2.0 5 votes vote down vote up
@CitrusTest(name = "CorsProfileBasicTest")
public void run() {
	description("Importing & validating CORS-Profile");
	
	variable("apiNumber", RandomNumberFunction.getRandomNumber(3, true));
	variable("apiPath", "/api-cors-profile-test-${apiNumber}");
	variable("apiName", "API CORS-Profile Test ${apiNumber}");
	variable("status", "unpublished");
	

	echo("####### 1. Importing API: '${apiName}' on path: '${apiPath}' with following settings: #######");
	createVariable("status", "unpublished");
	createVariable(ImportTestAction.API_DEFINITION,  "/com/axway/apim/test/files/security/petstore.json");
	createVariable(ImportTestAction.API_CONFIG,  "/com/axway/apim/test/files/cors/1_api-with_default_cors.json");
	createVariable("expectedReturnCode", "0");
	action(swaggerImport);
	
	echo("####### Validate API: '${apiName}' on path: '${apiPath}' has correct settings #######");
	http().client("apiManager")
		.send()
		.get("/proxies")
		.name("api")
		.header("Content-Type", "application/json");

	http().client("apiManager")
		.receive()
		.response(HttpStatus.OK)
		.messageType(MessageType.JSON)
		.validate("$.[?(@.path=='${apiPath}')].name", "${apiName}")
		.validate("$.[?(@.path=='${apiPath}')].state", "unpublished")
		.validate("$.[?(@.path=='${apiPath}')].corsProfiles.[?(@.name=='New CORS Profile')].allowedHeaders[0]", "Authorization")
		.validate("$.[?(@.path=='${apiPath}')].corsProfiles.[?(@.name=='New CORS Profile')].exposedHeaders[0]", "via")
		.validate("$.[?(@.path=='${apiPath}')].inboundProfiles._default.corsProfile", "New CORS Profile")
		.extractFromPayload("$.[?(@.path=='${apiPath}')].id", "apiId");
}
 
Example #19
Source File: NoChangedOrgsUnpublishedAPI.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("Making sure, organization are not conisdered as changes if desired state is Unpublished");
	
	variable("apiNumber", RandomNumberFunction.getRandomNumber(3, true));
	variable("apiPath", "/no-change-org-unpublished-${apiNumber}");
	variable("apiName", "No-Change-Org-Unpublished-${apiNumber}");

	// Replication must fail, is Query-String option is enabled, but API-Manager hasn't configured it 
	echo("####### API-Config without queryString option - Must fail #######");		
	createVariable(ImportTestAction.API_DEFINITION,  "/com/axway/apim/test/files/basic/petstore.json");
	createVariable(ImportTestAction.API_CONFIG,  "/com/axway/apim/test/files/organizations/1_api-with-client-orgs.json");
	createVariable("state", "unpublished");
	createVariable("orgName", "${orgName}");
	createVariable("orgName2", "${orgName2}");
	createVariable("expectedReturnCode", "0");
	swaggerImport.doExecute(context);
	
	echo("####### Re-Import the same - Must lead to a No-Change! #######");
	createVariable(ImportTestAction.API_DEFINITION,  "/com/axway/apim/test/files/basic/petstore.json");
	createVariable(ImportTestAction.API_CONFIG,  "/com/axway/apim/test/files/organizations/1_api-with-client-orgs.json");
	createVariable("state", "unpublished");
	createVariable("orgName", "${orgName}");
	createVariable("orgName2", "${orgName2}");
	createVariable("expectedReturnCode", "10"); // No-Change is expected!
	swaggerImport.doExecute(context);
}
 
Example #20
Source File: APIGrantToInvalidOrgTestIT.java    From apimanager-swagger-promote with Apache License 2.0 5 votes vote down vote up
@CitrusTest(name = "APIGrantToInvalidOrgTestIT")
public void run() {
	description("Tool must fail with a defined error, if a configured org is invalid");
	
	variable("apiNumber", RandomNumberFunction.getRandomNumber(3, true));
	variable("apiPath", "/grant_invalid_org-api-${apiNumber}");
	variable("apiName", "Grant to invalid orgs 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/organizations/1_api-with-client-orgs.json");
	createVariable("state", "published");
	createVariable("orgName", "${orgName}");
	createVariable("orgName2", "Invalid Org 0815");
	createVariable("expectedReturnCode", "0");
	action(swaggerImport);
	
	echo("####### Perform the No-Change, as the additionally configured invalid org should not lead to a change #######");
	createVariable(ImportTestAction.API_DEFINITION,  "/com/axway/apim/test/files/basic/petstore.json");
	createVariable(ImportTestAction.API_CONFIG,  "/com/axway/apim/test/files/organizations/1_api-with-client-orgs.json");
	createVariable("state", "published");
	createVariable("orgName", "${orgName}");
	createVariable("orgName2", "Invalid Org 0815");
	createVariable("expectedReturnCode", "10");
	action(swaggerImport);
}
 
Example #21
Source File: WSDLFromURLRefFileInConfigurationTestIT.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 described in API json configuration");
	
	variable("apiNumber", RandomNumberFunction.getRandomNumber(3, true));
	variable("apiPath", "/ref-file-wsdl-in-configuration-${apiNumber}");
	variable("apiName", "Ref-File-WSDL 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/wsdl/wsdl-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").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, "");
	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/wsdl/wsdl-file-with-username.url");
	createVariable("status", "unpublished");
	createVariable("expectedReturnCode", "10");
	swaggerImport.doExecute(context);
}
 
Example #22
Source File: OrgAdminUnpublishedTestIT.java    From apimanager-swagger-promote with Apache License 2.0 5 votes vote down vote up
@CitrusTest(name = "OrgAdminUnpublishedTestIT")
public void run() {
	description("OrgAdmins should be able to register unpublished APIs and manage them.");
	
	variable("apiNumber", RandomNumberFunction.getRandomNumber(3, true));
	variable("apiPath", "/org-admin-${apiNumber}");
	variable("apiName", "OrgAdmin-Unpublished-${apiNumber}");
	variable("ignoreAdminAccount", "true"); // This tests simulate to use only an Org-Admin-Account

	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/1_no-change-config.json");
	createVariable("expectedReturnCode", "0");
	createVariable("apiManagerUser", "${oadminUsername1}"); // This is an org-admin user
	createVariable("apiManagerPass", "${oadminPassword1}");
	action(swaggerImport);
	
	echo("####### Validate API: '${apiName}' on path: '${apiPath}' has been imported using OrgAdmin only #######");
	http().client("apiManager")
		.send()
		.get("/proxies")
		.name("api")
		.header("Content-Type", "application/json");

	http().client("apiManager")
		.receive()
		.response(HttpStatus.OK)
		.messageType(MessageType.JSON)
		.validate("$.[?(@.path=='${apiPath}')].name", "${apiName}")
		.extractFromPayload("$.[?(@.path=='${apiPath}')].id", "apiId");
	
	echo("####### Re-Import another Swagger-File still unpublished. #######");
	createVariable(ImportTestAction.API_DEFINITION,  "/com/axway/apim/test/files/basic/petstore2.json");
	createVariable(ImportTestAction.API_CONFIG,  "/com/axway/apim/test/files/basic/1_no-change-config.json");
	createVariable("expectedReturnCode", "0");
	createVariable("apiManagerUser", "${oadminUsername1}"); // This is an org-admin user
	createVariable("apiManagerPass", "${oadminPassword1}");
	action(swaggerImport);
}
 
Example #23
Source File: UsingEnvironmentTestIT.java    From apimanager-swagger-promote with Apache License 2.0 5 votes vote down vote up
@CitrusTest(name = "UsingEnvironmentTestIT")
public void run() {
	description("Import an API using the API-Environment with a certain stage only.");
	
	variable("apiNumber", RandomNumberFunction.getRandomNumber(3, true));
	variable("apiPath", "/envrionment-stage-api-${apiNumber}");
	variable("apiName", "envrionment-stage-API-${apiNumber}");

	
	echo("####### Importing API: '${apiName}' on path: '${apiPath}' for the first time #######");
	createVariable(ImportTestAction.API_DEFINITION,  "");
	createVariable(ImportTestAction.API_CONFIG,  "/com/axway/apim/test/files/basic/minimal-config-with-api-definition.json");
	createVariable("testAPIDefinition",  "/com/axway/apim/test/files/basic/petstore.json");
	createVariable("status", "unpublished");
	createVariable("stage", "localhost");
	createVariable("useEnvironmentOnly", "true");
	createVariable("expectedReturnCode", "0");
	action(swaggerImport);
	
	echo("####### Importing API: '${apiName}' on path: '${apiPath}' for the first time #######");
	createVariable(ImportTestAction.API_DEFINITION,  "");
	createVariable(ImportTestAction.API_CONFIG,  "/com/axway/apim/test/files/basic/minimal-config-with-api-definition.json");
	createVariable("testAPIDefinition",  "/com/axway/apim/test/files/basic/petstore2.json");
	createVariable("status", "unpublished");
	createVariable("stage", "localhost");
	createVariable("expectedReturnCode", "0");
	action(swaggerImport);
}
 
Example #24
Source File: RequestPolicyTestIT.java    From apimanager-swagger-promote with Apache License 2.0 5 votes vote down vote up
@CitrusTest(name = "RequestPolicyTest")
public void run() {
	description("Test a Request-Policy");
	
	variable("apiNumber", RandomNumberFunction.getRandomNumber(3, true));
	variable("apiPath", "/request-policy-test-${apiNumber}");
	variable("apiName", "Request Policy Test ${apiNumber}");
	variable("status", "unpublished");
	

	echo("####### Importing API: '${apiName}' on path: '${apiPath}' with following settings: #######");
	createVariable("requestPolicy", "Request policy 1");
	createVariable(ImportTestAction.API_DEFINITION,  "/com/axway/apim/test/files/security/petstore.json");
	createVariable(ImportTestAction.API_CONFIG,  "/com/axway/apim/test/files/policies/1_request-policy.json");
	createVariable("expectedReturnCode", "0");
	action(swaggerImport);
	
	echo("####### Validate API: '${apiName}' on path: '${apiPath}' has correct settings #######");
	http().client("apiManager")
		.send()
		.get("/proxies")
		.name("api")
		.header("Content-Type", "application/json");

	http().client("apiManager")
		.receive()
		.response(HttpStatus.OK)
		.messageType(MessageType.JSON)
		.validate("$.[?(@.path=='${apiPath}')].name", "${apiName}")
		.validate("$.[?(@.path=='${apiPath}')].state", "unpublished")
		.validate("$.[?(@.path=='${apiPath}')].outboundProfiles._default.requestPolicy", "@assertThat(containsString(Request policy 1))@")
		.extractFromPayload("$.[?(@.path=='${apiPath}')].id", "apiId");
}
 
Example #25
Source File: ResponsePolicyEmptyStringTestIT.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("Issue #156 - Cant deploy an API with response policy only");
	
	variable("apiNumber", RandomNumberFunction.getRandomNumber(3, true));
	variable("apiPath", "/response-policy-empty-string-${apiNumber}");
	variable("apiName", "Response Policy Empty String ${apiNumber}");
	variable("status", "unpublished");
	

	echo("####### Trying to import API: '${apiName}' on path: '${apiPath}' with following settings: #######");
	createVariable("responsePolicy", "Response policy 1");
	createVariable(ImportTestAction.API_DEFINITION,  "/com/axway/apim/test/files/security/petstore.json");
	createVariable(ImportTestAction.API_CONFIG,  "/com/axway/apim/test/files/policies/1_response-policy.json");
	createVariable("expectedReturnCode", "0");
	swaggerImport.doExecute(context);
	
	echo("####### Validate API: '${apiName}' on path: '${apiPath}' has correct settings #######");
	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")
		.validate("$.[?(@.path=='${apiPath}')].outboundProfiles._default.responsePolicy", "@assertThat(containsString(Response policy 1))@")
		.extractFromPayload("$.[?(@.path=='${apiPath}')].id", "apiId"));
}
 
Example #26
Source File: SimpleStagingTestIT.java    From apimanager-swagger-promote with Apache License 2.0 5 votes vote down vote up
@CitrusTest(name = "SimpleStagingTest")
public void run() {
	description("Import the API with production stage settings");
	
	variable("apiNumber", RandomNumberFunction.getRandomNumber(3, true));
	variable("apiPath", "/my-stage-test-${apiNumber}");
	variable("apiName", "Stage-Test-${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/staging/1_no-change-config.json");
	createVariable("stage", "prod"); // << Program will search for file: 1_no-change-config.prod.json
	createVariable("expectedReturnCode", "0");
	action(swaggerImport);

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

	http().client("apiManager")
		.receive()
		.response(HttpStatus.OK)
		.messageType(MessageType.JSON)
		.validate("$.[?(@.path=='${apiPath}')].name", "${apiName}")
		.validate("$.[?(@.path=='${apiPath}')].state", "published") // State must be published in "prod"
		.extractFromPayload("$.[?(@.path=='${apiPath}')].id", "apiId");
}
 
Example #27
Source File: RoutingPolicyTestIT.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("Test a Routing-Policy");
	
	variable("apiNumber", RandomNumberFunction.getRandomNumber(3, true));
	variable("apiPath", "/routing-policy-test-${apiNumber}");
	variable("apiName", "Routing Policy Test ${apiNumber}");
	variable("status", "unpublished");
	

	echo("####### Importing API: '${apiName}' on path: '${apiPath}' with following settings: #######");
	createVariable("routePolicy", "Routing policy 1");
	createVariable(ImportTestAction.API_DEFINITION,  "/com/axway/apim/test/files/security/petstore.json");
	createVariable(ImportTestAction.API_CONFIG,  "/com/axway/apim/test/files/policies/1_routing-policy.json");
	createVariable("expectedReturnCode", "0");
	swaggerImport.doExecute(context);
	
	echo("####### Validate API: '${apiName}' on path: '${apiPath}' has correct settings #######");
	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")
		.validate("$.[?(@.path=='${apiPath}')].outboundProfiles._default.routePolicy", "@assertThat(containsString(Routing policy 1))@")
		.extractFromPayload("$.[?(@.path=='${apiPath}')].id", "apiId"));
}
 
Example #28
Source File: AllOutboundPoliciesTestIT.java    From apimanager-swagger-promote with Apache License 2.0 5 votes vote down vote up
@CitrusTest(name = "AllOutboundPoliciesTest")
public void run() {
	description("Test a Request-Policy");
	
	variable("apiNumber", RandomNumberFunction.getRandomNumber(3, true));
	variable("apiPath", "/all-outbound-policies-${apiNumber}");
	variable("apiName", "All Outbound Policies ${apiNumber}");
	variable("status", "unpublished");
	

	echo("####### Importing API: '${apiName}' on path: '${apiPath}' with following settings: #######");
	createVariable("requestPolicy", "Request policy 1");
	createVariable("responsePolicy", "Response policy 1");
	createVariable("routePolicy", "Routing policy 1");
	createVariable("faultHandlerPolicy", "Faulthandler policy 1");
	createVariable(ImportTestAction.API_DEFINITION,  "/com/axway/apim/test/files/security/petstore.json");
	createVariable(ImportTestAction.API_CONFIG,  "/com/axway/apim/test/files/policies/1_all-policies.json");
	createVariable("expectedReturnCode", "0");
	action(swaggerImport);
	
	echo("####### Validate API: '${apiName}' on path: '${apiPath}' has correct settings #######");
	http().client("apiManager")
		.send()
		.get("/proxies")
		.name("api")
		.header("Content-Type", "application/json");

	http().client("apiManager")
		.receive()
		.response(HttpStatus.OK)
		.messageType(MessageType.JSON)
		.validate("$.[?(@.path=='${apiPath}')].name", "${apiName}")
		.validate("$.[?(@.path=='${apiPath}')].state", "unpublished")
		.validate("$.[?(@.path=='${apiPath}')].outboundProfiles._default.requestPolicy", "@assertThat(containsString(Request policy 1))@")
		.validate("$.[?(@.path=='${apiPath}')].outboundProfiles._default.responsePolicy", "@assertThat(containsString(Response policy 1))@")
		.validate("$.[?(@.path=='${apiPath}')].outboundProfiles._default.routePolicy", "@assertThat(containsString(Routing policy 1))@")
		.validate("$.[?(@.path=='${apiPath}')].outboundProfiles._default.faultHandlerPolicy", "@assertThat(containsString(Faulthandler policy 1))@")
		.extractFromPayload("$.[?(@.path=='${apiPath}')].id", "apiId");
}
 
Example #29
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 #30
Source File: UnpublishedPublishedDeprecatedAPITestIT.java    From apimanager-swagger-promote with Apache License 2.0 4 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 Unpublished-API, then publish it and finally deprecate it.");
	
	variable("apiNumber", RandomNumberFunction.getRandomNumber(3, true));
	variable("apiPath", "/state-change-test-api-${apiNumber}");
	variable("apiName", "State-Change-Test-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 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 API-State has been changed to published, which is not a breaking 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}"));
	
	echo("####### Change API-State to deprecated #######");
	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", "deprecated");
	createVariable("expectedReturnCode", "0");
	swaggerImport.doExecute(context);
	
	echo("####### Validate API-State has been changed to deprecated, which is not a breaking 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", "published")
		.validate("$.[?(@.path=='${apiPath}')].id", "${apiId}")
		.validate("$.[?(@.path=='${apiPath}')].deprecated", "true"));
}