diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml index 4f4463eb2..f209e5639 100644 --- a/.github/workflows/integration-test.yml +++ b/.github/workflows/integration-test.yml @@ -10,6 +10,8 @@ env: FED_FILE: swagger-promote-7.7-20260228.fed LOG_LEVEL: debug reset_password: true + apimanager_password: ${{ secrets.APIMANAGER_PASSWORD }} + oadmin_password: ${{ secrets.OADMIN_PASSWORD }} jobs: integration-test: diff --git a/.github/workflows/release-choco-pack-publish.yaml b/.github/workflows/release-choco-pack-publish.yaml index 9fbb7c684..b7b34a58e 100644 --- a/.github/workflows/release-choco-pack-publish.yaml +++ b/.github/workflows/release-choco-pack-publish.yaml @@ -9,14 +9,12 @@ jobs: name: Publish Choco package runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v6.0.0 name: Check-Out - name: Fetch release package - uses: wyozi/download-gh-release-asset@master - with: - args: axway-apimcli-${{ github.event.release.tag_name }}.zip + run: gh release download "${{ github.event.release.tag_name }}" --repo "$GITHUB_REPOSITORY" --pattern "axway-apimcli-${{ github.event.release.tag_name }}.zip" env: - GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + GH_TOKEN: "${{ secrets.GITHUB_TOKEN }}" - name: Move release to tools run: | mv axway-apimcli-${{ github.event.release.tag_name }}.zip tools/choco/axway-apim-cli/tools diff --git a/.gitignore b/.gitignore index 953f2f3b5..b0f29cb0e 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,6 @@ .DS_Store /.idea/ +/.claude/ +/CLAUDE.md +/.mcp.json diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 000000000..64f8c1b2d --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,53 @@ +# AGENTS.md + +## What this repo is +- Multi-module Maven Java CLI for Axway API Manager; root module graph is in `pom.xml` (`modules/*` + `distribution`). +- Core behavior is "desired state -> actual state" sync ("Everything as code") from config files to API Manager (`README.md`). + +## Architecture map (read these first) +- CLI bootstrap and command dispatch: `modules/apim-cli/src/main/java/com/axway/apim/cli/APIManagerCLI.java`. +- Plugin contract for command providers: `modules/apim-cli/src/main/java/com/axway/apim/cli/APIMCLIServiceProvider.java`. +- Service registration uses Java `ServiceLoader` files at `modules/*/src/main/resources/META-INF/services/com.axway.apim.cli.APIMCLIServiceProvider`. +- API management command flow example: `modules/apis/src/main/java/com/axway/apim/APIImportApp.java`. +- Remote system abstraction (HTTP/API Manager integration) lives in `modules/apim-adapter`. +- Shared test utilities and integration framework support live in `modules/apim-cli-tests`. + +## How commands are added here (project-specific pattern) +- Implement `APIMCLIServiceProvider` in the owning module (example: `APIImportApp`). +- Expose each CLI action with `@CLIServiceMethod(name = "...", description = "...")`. +- Register provider class name in the module ServiceLoader file under `META-INF/services/...APIMCLIServiceProvider`. +- Group routing is based on `getGroupId()`; usage output comes from `getGroupDescription()`. + +## Build and test workflows +- Baseline build (unit tests only by default): +```bash +mvn clean verify +``` +- Integration tests profile (disables unit tests, enables failsafe ITs): +```bash +mvn clean verify -Pintegration-tests +``` +- Skip all tests profile: +```bash +mvn clean verify -Pno-tests +``` +- Distribution artifacts are produced by module `distribution` (see `distribution/target/*.tar.gz` and `*.zip`). +- Java target is 11 at parent level (`pom.xml`), while `apim-cli-tests` compiles for Java 8 (`modules/apim-cli-tests/pom.xml`). + +## Integration and runtime assumptions +- API Manager access credentials/host are supplied via environment property files (sample: `examples/conf/env.api-env.properties`). +- API/app desired state payloads are JSON/YAML config files (see `examples/basic`, `examples/complex`, `examples/orgsAndApps`). +- Adapter dependencies indicate supported API styles/formats: Swagger/OpenAPI parser, OData (v2/v4), GraphQL, Jackson YAML/XML, HTTP client (`modules/apim-adapter/pom.xml`). + +## Testing + CI nuances +- Unit tests run via Surefire; integration tests via Failsafe with explicit exclusions in root `pom.xml`. +- Integration tests are Docker/API-Manager based; setup expectations and required GitHub secrets are documented in `Integration_test_setup.md`. +- For config-driven behavior changes, prefer adding/adjusting scenario-style tests in `modules/*/src/test` using patterns from existing ITs. + +## Release workflow anchors +- Release process is branch-based (`develop` -> `master`) and documented in `DEVELOPMENT.md`. +- Release profile (`-Prelease`) enables sources/javadocs/GPG signing/Nexus staging plugins in root `pom.xml`. + +## Existing AI guidance in repo +- No dedicated AI instruction files were found in the searched convention paths; `README.md` is the primary project-level guidance. + diff --git a/CHANGELOG.md b/CHANGELOG.md index 9c2beba4c..29d053985 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,10 +4,30 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). -# [Unreleased] +# [1.14.16] In progress ### Fixed -- API import of a WSDL based API with `-overrideSpecBasePath` ignores `backendBasepath` and uses the endpoint from the WSDL +API import of a WSDL based API with -overrideSpecBasePath ignores backendBasepath and uses the endpoint from the WSDL + +### Changed +- Quota restrictions are now added, updated and removed individually using the API-Manager endpoints below + `/quotas/{id}/constraints` instead of replacing the complete quota document. This leaves the restrictions of + other APIs untouched and avoids lost updates. API-Managers older than 7.7.20261130 keep using the previous + document level update, and the CLI falls back to it automatically if the endpoints are not served. + +### Added +- API import supports `-quotaUpdateMode` (`auto`, `legacy`, `constraints`) to control how quotas are written to + API-Manager. Defaults to `auto`. + +### Deprecated +- **OData support is deprecated and will be removed in the next release.** Passing an OData `$metadata` / EDMX + document as the API definition, which the CLI detects and converts to OpenAPI before importing, is affected for + all three versions: OData V2, V3 and V4. + The conversion is built on [Apache Olingo](https://olingo.apache.org/), which is no longer maintained, so it + cannot be kept up to date or secured within this project. + The conversion will move to a separate project that turns OData metadata into an OpenAPI definition. Convert the + metadata there first, then import the resulting OpenAPI document with the CLI as usual. Everything else about + importing such an API, including the generated API-Methods, stays the same. # [1.14.15] 2026-8-26 diff --git a/Integration_test_setup.md b/Integration_test_setup.md index 073e31387..b4c84ec8a 100644 --- a/Integration_test_setup.md +++ b/Integration_test_setup.md @@ -16,5 +16,25 @@ For that TravisCI is using, which is starting an API-Manager V7.x Docker-Contain Perform the following steps: - Update Github variable AXWAY_DOCKER_REG_PASS with client_id - Update Github variable AXWAY_DOCKER_REG_USER with client_secret +- Credentials are not stored in the repository. Add the following Github secrets, which the workflow exposes as + environment variables: + - `APIMANAGER_PASSWORD` - password of the `apiadmin` account, exposed as `apimanager_password` + - `OADMIN_PASSWORD` - password of the `testoadmin` organization admin, exposed as `oadmin_password` + +## Running the integration tests locally +`modules/apim-cli-tests/src/main/resources/citrus-global-variables.properties` only holds the defaults. Override +the credentials, and optionally the host, through environment variables before running the tests: + +```bash +export apimanager_password='' +export oadmin_password='' +export apimanager_host=localhost # optional, defaults to localhost +mvn clean verify -Pintegration-tests +``` + +Note that this properties file must not contain `${...}` placeholders. It is read twice: by Spring as a +`@PropertySource` and by the Citrus `GlobalVariablesPropertyLoader`, and the latter resolves `${...}` as a Citrus +test variable and fails on anything it does not know. The mapping from environment variable to property is done in +`EndpointConfig` instead. diff --git a/TODO.md b/TODO.md new file mode 100644 index 000000000..253c656be --- /dev/null +++ b/TODO.md @@ -0,0 +1,80 @@ +# TODO — Security & Dependency Hygiene + +Generated: 2026-08-26 +Branch: `fix/jackson-2.22-upgrade` + +--- + +## Security Scan Results + +**CVE scan date:** 2026-08-26 +**Result:** ✅ No known CVEs found in any direct or transitive dependency. + +--- + +## Dependency Hygiene Findings + +The items below are not CVEs today but represent outdated or end-of-life libraries +that carry long-term security and maintenance risk. + +### 🔴 High Priority + +#### 1. `io.swagger.core.v3:swagger-models` — version mismatch +- **Managed version:** `2.2.0` +- **Effective version (transitive via `swagger-parser:2.1.19`):** `2.2.19` +- **Issue:** The pinned version in `dependencyManagement` is 19 minor releases behind the + version already on the classpath. This means `swagger-models` is never actually + overriding the transitive resolution and gives a false sense of control. +- **Fix:** Update `swagger-models` version in `pom.xml` `dependencyManagement` to `2.2.19`. +- **File:** `pom.xml` + +--- + +### 🟠 Medium Priority + +#### 2. `org.apache.httpcomponents:httpclient` — EOL library +- **Managed version:** `4.5.14` +- **Issue:** Apache HttpClient 4.x is **end-of-life**. The successor is + `org.apache.hc.client5:httpclient5` (HttpClient 5.x), which is already used in + `modules/apim-cli-tests`. No CVE at 4.5.14 today, but the 4.x line will not receive + security patches. +- **Fix:** Migrate usages in `modules/apim-adapter` and `modules/apis` from + `org.apache.httpcomponents:httpclient` to `org.apache.hc.client5:httpclient5`. +- **Files:** `pom.xml`, `modules/apim-adapter/pom.xml`, `modules/apis/pom.xml` + +#### ~~3. `org.apache.logging.log4j:log4j-slf4j-impl` — behind current release~~ ✅ DONE +- **Was:** `log4j-slf4j-impl:2.20.0` + `slf4j-api:1.7.36` +- **Now:** `log4j-slf4j2-impl:2.25.4` + `log4j-api/core:2.25.4` + `slf4j-api:2.0.18` +- `log4j-slf4j-impl` (SLF4J 1.x bridge) was discontinued at 2.20.0; replaced with + `log4j-slf4j2-impl` (SLF4J 2.x bridge). Source unchanged — only `Logger`/`LoggerFactory` + used, both backward-compatible in SLF4J 2.x. + +--- + +### 🟡 Low Priority + +#### 4. `org.slf4j:slf4j-api` — legacy branch +- **Managed version:** `1.7.36` +- **Current release:** `2.0.x` +- **Issue:** SLF4J 1.x is the legacy branch. 2.x has been stable for over a year. No CVE + at 1.7.36. +- **Fix:** Upgrade to `slf4j-api:2.0.x` (requires aligning `log4j-slf4j-impl` → + `log4j-slf4j2-impl` artifact rename). +- **File:** `pom.xml` + +#### 5. `org.glassfish.jaxb:jaxb-runtime` — dated release +- **Managed version:** `2.3.9` +- **Current release:** `4.x` (under Eclipse EE4J) +- **Issue:** The 2.3.x line is a legacy Jakarta EE 8 artefact. No CVE at 2.3.9. +- **Fix:** Evaluate upgrade to `4.0.x` (requires Jakarta EE 10 namespace migration: + `javax.*` → `jakarta.*`). +- **File:** `pom.xml` + +#### 6. `commons-logging:commons-logging` — transitive, slightly outdated +- **Effective version (transitive):** `1.2` +- **Current release:** `1.3.x` +- **Issue:** Pulled transitively via `httpclient:4.5.14`. No CVE at 1.2. +- **Fix:** Add `commons-logging:commons-logging:1.3.x` to `dependencyManagement` to force + the newer version, or resolve as part of the HttpClient 5.x migration (item #2 above). +- **File:** `pom.xml` + diff --git a/modules/apim-adapter/pom.xml b/modules/apim-adapter/pom.xml index 06cf1799b..be33c63bf 100644 --- a/modules/apim-adapter/pom.xml +++ b/modules/apim-adapter/pom.xml @@ -16,8 +16,8 @@ - org.apache.httpcomponents - httpclient + org.apache.httpcomponents.client5 + httpclient5 commons-cli @@ -35,10 +35,7 @@ org.apache.commons commons-text - - org.apache.httpcomponents - httpmime - + com.fasterxml.jackson.core jackson-core @@ -89,7 +86,7 @@ org.apache.logging.log4j - log4j-slf4j-impl + log4j-slf4j2-impl dev.failsafe diff --git a/modules/apim-adapter/src/main/java/com/axway/apim/adapter/APIManagerAdapter.java b/modules/apim-adapter/src/main/java/com/axway/apim/adapter/APIManagerAdapter.java index d52130538..9266ce5c2 100644 --- a/modules/apim-adapter/src/main/java/com/axway/apim/adapter/APIManagerAdapter.java +++ b/modules/apim-adapter/src/main/java/com/axway/apim/adapter/APIManagerAdapter.java @@ -18,17 +18,18 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import org.apache.commons.io.IOUtils; -import org.apache.http.Header; -import org.apache.http.HttpEntity; -import org.apache.http.HttpResponse; -import org.apache.http.NameValuePair; -import org.apache.http.client.entity.UrlEncodedFormEntity; -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.client.utils.URIBuilder; -import org.apache.http.entity.ContentType; -import org.apache.http.entity.mime.MultipartEntityBuilder; -import org.apache.http.message.BasicNameValuePair; -import org.apache.http.util.EntityUtils; +import org.apache.hc.core5.http.Header; +import org.apache.hc.core5.http.HttpEntity; +import org.apache.hc.core5.http.HttpResponse; +import org.apache.hc.core5.http.NameValuePair; +import org.apache.hc.client5.http.entity.UrlEncodedFormEntity; +import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse; +import org.apache.hc.core5.net.URIBuilder; +import org.apache.hc.core5.http.ContentType; +import org.apache.hc.client5.http.entity.mime.MultipartEntityBuilder; +import org.apache.hc.core5.http.message.BasicNameValuePair; +import org.apache.hc.core5.http.io.entity.EntityUtils; +import org.apache.hc.core5.http.ParseException; import org.ehcache.Cache; import org.ehcache.CacheManager; import org.ehcache.StateTransitionException; @@ -231,7 +232,7 @@ public void loginToAPIManager() throws AppException { User user = getCurrentUser(); String role = getHigherRole(user); assignRoles(role); - } catch (IOException | URISyntaxException e) { + } catch (IOException | URISyntaxException | ParseException e) { throw new AppException("Can't login to API-Manager", ErrorCode.API_MANAGER_COMMUNICATION, e); } catch (InterruptedException e) { Thread.currentThread().interrupt(); @@ -294,7 +295,7 @@ public void logoutFromAPIManager() throws AppException { URI uri = new URIBuilder(cmd.getAPIManagerURL()).setPath(cmd.getApiBasepath() + "/login").build(); DELRequest logoutRequest = new DELRequest(uri); try (CloseableHttpResponse httpResponse = (CloseableHttpResponse) logoutRequest.execute()) { - int statusCode = httpResponse.getStatusLine().getStatusCode(); + int statusCode = httpResponse.getCode(); if (statusCode != 204) { String response = EntityUtils.toString(httpResponse.getEntity()); LOG.warn("Logout failed with statusCode: {} Got response: {}", statusCode, response); @@ -313,7 +314,7 @@ public static User getCurrentUser() throws AppException { try (CloseableHttpResponse httpResponse = (CloseableHttpResponse) currentUserRequest.execute()) { getCsrfToken(httpResponse); String currentUser = EntityUtils.toString(httpResponse.getEntity()); - int statusCode = httpResponse.getStatusLine().getStatusCode(); + int statusCode = httpResponse.getCode(); if (statusCode != 200) { throw new AppException("Status-Code: " + statusCode + ", Can't get current-user for user '" + currentUser + "'", ErrorCode.API_MANAGER_COMMUNICATION); @@ -332,7 +333,7 @@ public static User getCurrentUser() throws AppException { } private static void getCsrfToken(HttpResponse response) throws AppException { - for (Header header : response.getAllHeaders()) { + for (Header header : response.getHeaders()) { if (header.getName().equalsIgnoreCase("csrf-token")) { APIMHttpClient.getInstance().setCsrfToken(header.getValue()); break; @@ -532,7 +533,7 @@ public static Image getImageFromAPIM(URI uri, String baseFilename) throws AppExc try { RestAPICall getRequest = new GETRequest(uri); try (CloseableHttpResponse httpResponse = (CloseableHttpResponse) getRequest.execute()) { - int statusCode = httpResponse.getStatusLine().getStatusCode(); + int statusCode = httpResponse.getCode(); if (statusCode == 404) return null; // No Image found if (statusCode != 200) { String response = EntityUtils.toString(httpResponse.getEntity()); @@ -583,7 +584,7 @@ public static String getCertInfo(InputStream certificate, String password, CaCer .build(); POSTRequest postRequest = new POSTRequest(entity, uri); try (CloseableHttpResponse httpResponse = (CloseableHttpResponse) postRequest.execute()) { - int statusCode = httpResponse.getStatusLine().getStatusCode(); + int statusCode = httpResponse.getCode(); String response = EntityUtils.toString(httpResponse.getEntity()); if (statusCode != 200) { if (response != null && response.contains("Bad password")) { @@ -608,7 +609,7 @@ public List getCertInfoFromUrl(String url) throws AppException { params.add(new BasicNameValuePair("outbound", "true")); POSTRequest postRequest = new POSTRequest(new UrlEncodedFormEntity(params), uri); try (CloseableHttpResponse httpResponse = (CloseableHttpResponse) postRequest.execute()) { - int statusCode = httpResponse.getStatusLine().getStatusCode(); + int statusCode = httpResponse.getCode(); if (statusCode != 200) { String response = EntityUtils.toString(httpResponse.getEntity()); throw new AppException("API-Manager failed to read certificate information from URL. Got response: '" + response + "'", ErrorCode.API_MANAGER_COMMUNICATION); diff --git a/modules/apim-adapter/src/main/java/com/axway/apim/adapter/HttpHelper.java b/modules/apim-adapter/src/main/java/com/axway/apim/adapter/HttpHelper.java index a71e5ad97..504985fe6 100644 --- a/modules/apim-adapter/src/main/java/com/axway/apim/adapter/HttpHelper.java +++ b/modules/apim-adapter/src/main/java/com/axway/apim/adapter/HttpHelper.java @@ -1,18 +1,19 @@ package com.axway.apim.adapter; import com.axway.apim.lib.utils.rest.RestAPICall; -import org.apache.http.HttpEntity; -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.util.EntityUtils; +import org.apache.hc.core5.http.HttpEntity; +import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse; +import org.apache.hc.core5.http.io.entity.EntityUtils; +import org.apache.hc.core5.http.ParseException; import java.io.IOException; public class HttpHelper { - public Response execute(RestAPICall restAPICall, boolean responseBody) throws IOException { + public Response execute(RestAPICall restAPICall, boolean responseBody) throws IOException, ParseException { try(CloseableHttpResponse closeableHttpResponse = (CloseableHttpResponse) restAPICall.execute()){ Response response = new Response(); - response.setStatusCode(closeableHttpResponse.getStatusLine().getStatusCode()); + response.setStatusCode(closeableHttpResponse.getCode()); HttpEntity httpEntity = closeableHttpResponse.getEntity(); if(responseBody && httpEntity != null) response.setResponseBody(EntityUtils.toString(httpEntity)); diff --git a/modules/apim-adapter/src/main/java/com/axway/apim/adapter/apis/APIFilter.java b/modules/apim-adapter/src/main/java/com/axway/apim/adapter/apis/APIFilter.java index d085ed4e2..4b727ba5c 100644 --- a/modules/apim-adapter/src/main/java/com/axway/apim/adapter/apis/APIFilter.java +++ b/modules/apim-adapter/src/main/java/com/axway/apim/adapter/apis/APIFilter.java @@ -8,8 +8,8 @@ import com.axway.apim.lib.utils.Utils; import com.axway.apim.lib.utils.Utils.FedKeyType; import org.apache.commons.lang3.StringUtils; -import org.apache.http.NameValuePair; -import org.apache.http.message.BasicNameValuePair; +import org.apache.hc.core5.http.NameValuePair; +import org.apache.hc.core5.http.message.BasicNameValuePair; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/modules/apim-adapter/src/main/java/com/axway/apim/adapter/apis/APIManagerAPIAccessAdapter.java b/modules/apim-adapter/src/main/java/com/axway/apim/adapter/apis/APIManagerAPIAccessAdapter.java index 6595a2572..014c4e636 100644 --- a/modules/apim-adapter/src/main/java/com/axway/apim/adapter/apis/APIManagerAPIAccessAdapter.java +++ b/modules/apim-adapter/src/main/java/com/axway/apim/adapter/apis/APIManagerAPIAccessAdapter.java @@ -22,12 +22,13 @@ import com.fasterxml.jackson.databind.ser.FilterProvider; import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter; import com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider; -import org.apache.http.HttpEntity; -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.client.utils.URIBuilder; -import org.apache.http.entity.ContentType; -import org.apache.http.entity.StringEntity; -import org.apache.http.util.EntityUtils; +import org.apache.hc.core5.http.HttpEntity; +import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse; +import org.apache.hc.core5.net.URIBuilder; +import org.apache.hc.core5.http.ContentType; +import org.apache.hc.core5.http.io.entity.StringEntity; +import org.apache.hc.core5.http.io.entity.EntityUtils; +import org.apache.hc.core5.http.ParseException; import org.ehcache.Cache; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -88,7 +89,7 @@ private void readAPIAccessFromAPIManager(Type type, String id) throws AppExcepti LOG.debug("Load API-Access with type: {} from API-Manager with ID: {}", type, id); try (CloseableHttpResponse httpResponse = (CloseableHttpResponse) getRequest.execute()) { String response = EntityUtils.toString(httpResponse.getEntity()); - int statusCode = httpResponse.getStatusLine().getStatusCode(); + int statusCode = httpResponse.getCode(); if (statusCode < 200 || statusCode > 299) { LOG.error("Error loading API-Access from API-Manager for {}. Response-Code: {}. Got response: {}", type, statusCode, response); throw new AppException("Error loading API-Access from API-Manager for " + type + ". Response-Code: " + statusCode, ErrorCode.API_MANAGER_COMMUNICATION); @@ -100,7 +101,7 @@ private void readAPIAccessFromAPIManager(Type type, String id) throws AppExcepti apiManagerResponse.put(type, mappedResponse); putToCache(id, type, response); } - } catch (IOException | URISyntaxException e) { + } catch (IOException | URISyntaxException | ParseException e) { throw new AppException("Error loading API-Access from API-Manager for " + type + " from API-Manager", ErrorCode.API_MANAGER_COMMUNICATION, e); } } @@ -215,7 +216,7 @@ public APIAccess createAPIAccessForApplication(APIAccess apiAccess, String appli HttpEntity entity = new StringEntity(mapper.writeValueAsString(apiAccess), ContentType.APPLICATION_JSON); RestAPICall request = new POSTRequest(entity, uri); try (CloseableHttpResponse httpResponse = (CloseableHttpResponse) request.execute()) { - int statusCode = httpResponse.getStatusLine().getStatusCode(); + int statusCode = httpResponse.getCode(); String response = EntityUtils.toString(httpResponse.getEntity()); if (statusCode != 201) { if (statusCode == 409 && response.contains(RESOURCE_ALREADY_EXISTS)) { @@ -283,7 +284,7 @@ public void createAPIAccess(APIAccess apiAccess, AbstractEntity parentEntity, Ty removeFromCache(parentEntity.getId(), type); } catch (InterruptedException e) { Thread.currentThread().interrupt(); - } catch (IOException | URISyntaxException e) { + } catch (IOException | URISyntaxException | ParseException e) { throw new AppException("Error creating/updating API Access.", ErrorCode.CANT_CREATE_API_PROXY, e); } } @@ -294,7 +295,7 @@ public void deleteAPIAccess(APIAccess apiAccess, AbstractEntity parentEntity, Ty // Use an admin account for this request RestAPICall request = new DELRequest(uri); try (CloseableHttpResponse httpResponse = (CloseableHttpResponse) request.execute()) { - int statusCode = httpResponse.getStatusLine().getStatusCode(); + int statusCode = httpResponse.getCode(); if (statusCode < 200 || statusCode > 299) { String errorResponse = EntityUtils.toString(httpResponse.getEntity()); LOG.error("Can't delete API access requests for application. Response-Code: {}. Got response: {}", statusCode, errorResponse); @@ -342,7 +343,7 @@ public List getSubscribedOrganizationsAndApplicatio URI uri = new URIBuilder(cmd.getAPIManagerURL()).setPath(cmd.getApiBasepath() + "/proxies/" + apiId + "/apiaccess").build(); RestAPICall request = new GETRequest(uri); try (CloseableHttpResponse httpResponse = (CloseableHttpResponse) request.execute()) { - int statusCode = httpResponse.getStatusLine().getStatusCode(); + int statusCode = httpResponse.getCode(); String response = EntityUtils.toString(httpResponse.getEntity()); if (statusCode > 200) { LOG.error("Can't get API access requests for API. Response-Code: {}. Got response: {}", statusCode, response); diff --git a/modules/apim-adapter/src/main/java/com/axway/apim/adapter/apis/APIManagerAPIAdapter.java b/modules/apim-adapter/src/main/java/com/axway/apim/adapter/apis/APIManagerAPIAdapter.java index a3e51d338..8039edf61 100644 --- a/modules/apim-adapter/src/main/java/com/axway/apim/adapter/apis/APIManagerAPIAdapter.java +++ b/modules/apim-adapter/src/main/java/com/axway/apim/adapter/apis/APIManagerAPIAdapter.java @@ -32,17 +32,18 @@ import dev.failsafe.FailsafeException; import dev.failsafe.RetryPolicy; import org.apache.commons.io.IOUtils; -import org.apache.http.HttpEntity; -import org.apache.http.HttpStatus; -import org.apache.http.NameValuePair; -import org.apache.http.client.entity.UrlEncodedFormEntity; -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.client.utils.URIBuilder; -import org.apache.http.entity.ContentType; -import org.apache.http.entity.StringEntity; -import org.apache.http.entity.mime.MultipartEntityBuilder; -import org.apache.http.message.BasicNameValuePair; -import org.apache.http.util.EntityUtils; +import org.apache.hc.core5.http.HttpEntity; +import org.apache.hc.core5.http.HttpStatus; +import org.apache.hc.core5.http.NameValuePair; +import org.apache.hc.client5.http.entity.UrlEncodedFormEntity; +import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse; +import org.apache.hc.core5.net.URIBuilder; +import org.apache.hc.core5.http.ContentType; +import org.apache.hc.core5.http.io.entity.StringEntity; +import org.apache.hc.client5.http.entity.mime.MultipartEntityBuilder; +import org.apache.hc.core5.http.message.BasicNameValuePair; +import org.apache.hc.core5.http.io.entity.EntityUtils; +import org.apache.hc.core5.http.ParseException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -142,7 +143,7 @@ private void readAPIsFromAPIManager(APIFilter filter) throws AppException { RestAPICall getRequest = new GETRequest(uri); try (CloseableHttpResponse httpResponse = (CloseableHttpResponse) getRequest.execute()) { String response = EntityUtils.toString(httpResponse.getEntity()); - int statusCode = httpResponse.getStatusLine().getStatusCode(); + int statusCode = httpResponse.getCode(); if (statusCode < 200 || statusCode > 299) { if (statusCode == 403 && filter.getId() != null) { LOG.error("Unable to find API with ID: {} Please have in mind during API-Update the ID is re-created or add -ignoreCache !", filter.getId()); @@ -289,7 +290,7 @@ private void addImageFromAPIM(API api, boolean includeImage) throws AppException URI uri = new URIBuilder(cmd.getAPIManagerURL()).setPath(cmd.getApiBasepath() + PROXIES + api.getId() + "/image").build(); RestAPICall getRequest = new GETRequest(uri); try (CloseableHttpResponse httpResponse = (CloseableHttpResponse) getRequest.execute()) { - if (httpResponse == null || httpResponse.getEntity() == null || httpResponse.getStatusLine().getStatusCode() == HttpStatus.SC_NOT_FOUND) { + if (httpResponse == null || httpResponse.getEntity() == null || httpResponse.getCode() == HttpStatus.SC_NOT_FOUND) { api.setImage(null); return; // no Image found in API-Manager } @@ -350,7 +351,7 @@ public void updateAPIImage(API api, Image image) throws AppException { .build(); RestAPICall apiCall = new POSTRequest(entity, uri); try (CloseableHttpResponse httpResponse = (CloseableHttpResponse) apiCall.execute()) { - int statusCode = httpResponse.getStatusLine().getStatusCode(); + int statusCode = httpResponse.getCode(); String response = EntityUtils.toString(httpResponse.getEntity()); if (statusCode != 200) { LOG.error("Error updating API-Image. Received Status-Code: {} Response: {}", statusCode, response); @@ -485,7 +486,7 @@ private void addOriginalAPIDefinitionFromAPIM(API api, APIFilter filter) throws LOG.debug("Download API spec URL :{}", uri); RestAPICall getRequest = new GETRequest(uri); try (CloseableHttpResponse httpResponse = (CloseableHttpResponse) getRequest.execute()) { - int statusCode = httpResponse.getStatusLine().getStatusCode(); + int statusCode = httpResponse.getCode(); if (statusCode != 200) { if (filter.isUseFEAPIDefinition()) { LOG.debug("Failed to download API-Specification with version {} from Frontend-API. Received Status-Code: {}", specVersion, statusCode); @@ -556,7 +557,7 @@ private void addBackendResourcePath(API api, APISpecification apiDefinition, boo // In any case, we save the backend resource path, as it is necessary for the full backendBasepath in the exported API config. api.setBackendResourcePath(resourcePath); - } catch (IOException | URISyntaxException e) { + } catch (IOException | URISyntaxException | ParseException e) { throw new AppException("Cannot parse Backend-API for API: '" + api.toStringHuman() + "' in order to change API-Specification", ErrorCode.CANT_READ_API_DEFINITION_FILE, e); } catch (InterruptedException e) { Thread.currentThread().interrupt(); @@ -570,7 +571,7 @@ public API createAPIProxy(API api) throws AppException { HttpEntity entity = new StringEntity("{\"apiId\":\"" + api.getApiId() + "\",\"organizationId\":\"" + api.getOrganization().getId() + "\"}", ContentType.APPLICATION_JSON); RestAPICall request = new POSTRequest(entity, uri); try (CloseableHttpResponse httpResponse = (CloseableHttpResponse) request.execute()) { - int statusCode = httpResponse.getStatusLine().getStatusCode(); + int statusCode = httpResponse.getCode(); String response = EntityUtils.toString(httpResponse.getEntity()); if (statusCode != 201) { LOG.error("Error creating API-Proxy (FE-API) using URI: {} Received Status-Code: {} Response: {}", uri, statusCode, response); @@ -599,7 +600,7 @@ public API updateAPIProxy(API api) throws AppException { RestAPICall request = new PUTRequest(entity, uri); try (CloseableHttpResponse httpResponse = (CloseableHttpResponse) request.execute()) { String response = EntityUtils.toString(httpResponse.getEntity()); - int statusCode = httpResponse.getStatusLine().getStatusCode(); + int statusCode = httpResponse.getCode(); if (statusCode < 200 || statusCode > 299) { LOG.error("Error updating API-Proxy. Response-Code: {} Got response: {}", statusCode, response); throw new AppException("Error updating API-Proxy. Response-Code: " + statusCode, ErrorCode.API_MANAGER_COMMUNICATION); @@ -611,10 +612,14 @@ public API updateAPIProxy(API api) throws AppException { } } + /** + * queryStringPassThrough was added to the inboundProfiles in API-Manager 7.7.20220530. + */ + public static final String QUERY_STRING_PASS_THROUGH_MIN_VERSION = "7.7.20220530"; + public String[] getSerializeAllExcept() throws AppException { String[] serializeAllExcept; - // queryStringPassThrough added in inboundProfiles on API manager version 7.7.20220530 - if (isAPIManagerVersionGreaterThan7720220530(APIManagerAdapter.getInstance().getApiManagerVersion())) { + if (APIManagerAdapter.hasAPIManagerVersion(QUERY_STRING_PASS_THROUGH_MIN_VERSION)) { serializeAllExcept = new String[]{"apiDefinition", "certFile", "useForInbound", "useForOutbound", "organization", "applications", "image", "clientOrganizations", "applicationQuota", "systemQuota", "backendBasepath", "remoteHost"}; } else { serializeAllExcept = new String[]{"queryStringPassThrough", "apiDefinition", "certFile", "useForInbound", "useForOutbound", "organization", "applications", "image", "clientOrganizations", "applicationQuota", "systemQuota", "backendBasepath", "remoteHost"}; @@ -623,24 +628,13 @@ public String[] getSerializeAllExcept() throws AppException { return serializeAllExcept; } - private boolean isAPIManagerVersionGreaterThan7720220530(String apiManagerVersion) { - try { - apiManagerVersion = apiManagerVersion.replace("7.7.", ""); - LOG.debug("apiManagerVersion for conversion: {}", apiManagerVersion); - return (Integer.parseInt(apiManagerVersion) >= 20220530); - } catch (NumberFormatException nfe) { - LOG.warn("Failed to convert API Manager version to integer: {}, returning false", apiManagerVersion); - return false; - } - } - public void deleteAPIProxy(API api) throws AppException { LOG.debug("Deleting API-Proxy with Name : {} and Id: {}", api.getName(), api.getId()); try { URI uri = new URIBuilder(cmd.getAPIManagerURL()).setPath(cmd.getApiBasepath() + PROXIES + api.getId()).build(); RestAPICall request = new DELRequest(uri); try (CloseableHttpResponse httpResponse = (CloseableHttpResponse) request.execute()) { - int statusCode = httpResponse.getStatusLine().getStatusCode(); + int statusCode = httpResponse.getCode(); if (statusCode != 204) { LOG.error("Error deleting API-Proxy using URI: {} Response-Code: {}", uri, statusCode); Utils.logPayload(LOG, httpResponse); @@ -659,7 +653,7 @@ public void deleteBackendAPI(API api) throws AppException { URI uri = new URIBuilder(cmd.getAPIManagerURL()).setPath(cmd.getApiBasepath() + APIREPO + api.getApiId()).build(); RestAPICall request = new DELRequest(uri); try (CloseableHttpResponse httpResponse = (CloseableHttpResponse) request.execute()) { - int statusCode = httpResponse.getStatusLine().getStatusCode(); + int statusCode = httpResponse.getCode(); if (statusCode != 204) { LOG.error("Error deleting Backend-API. Response-Code: {}", statusCode); Utils.logPayload(LOG, httpResponse); @@ -677,7 +671,7 @@ public boolean isBackendApiExists(API api) { URI uri = new URIBuilder(cmd.getAPIManagerURL()).setPath(cmd.getApiBasepath() + APIREPO + api.getApiId()).build(); RestAPICall request = new GETRequest(uri); try (CloseableHttpResponse httpResponse = (CloseableHttpResponse) request.execute()) { - int statusCode = httpResponse.getStatusLine().getStatusCode(); + int statusCode = httpResponse.getCode(); if (statusCode != 200) { LOG.warn("Error getting Backend-API Response-Code: {}", statusCode); Utils.logPayload(LOG, httpResponse); @@ -697,7 +691,7 @@ public boolean isFrontendApiExists(API api) { URI uri = new URIBuilder(cmd.getAPIManagerURL()).setPath(cmd.getApiBasepath() + PROXIES + api.getId()).build(); RestAPICall request = new GETRequest(uri); try (CloseableHttpResponse httpResponse = (CloseableHttpResponse) request.execute()) { - int statusCode = httpResponse.getStatusLine().getStatusCode(); + int statusCode = httpResponse.getCode(); if (statusCode != 200) { LOG.error("Error getting Frontend-API Response-Code: {}", statusCode); Utils.logPayload(LOG, httpResponse); @@ -726,13 +720,16 @@ public byte[] getAPIDatFile(API api, String password) throws AppException { parameters.add(new BasicNameValuePair(FILENAME, "api-export.dat")); parameters.add(new BasicNameValuePair(PASSWORD, password)); parameters.add(new BasicNameValuePair("id", api.getId())); - HttpEntity entity = new UrlEncodedFormEntity(parameters); - URI uri = new URIBuilder(cmd.getAPIManagerURL()) - .setPath(cmd.getApiBasepath() + "/proxies/export") - .build(); - RestAPICall request = new POSTRequest(entity, uri); + URI uri; + RestAPICall request; + try (HttpEntity entity = new UrlEncodedFormEntity(parameters)) { + uri = new URIBuilder(cmd.getAPIManagerURL()) + .setPath(cmd.getApiBasepath() + "/proxies/export") + .build(); + request = new POSTRequest(entity, uri); + } try (CloseableHttpResponse httpResponse = (CloseableHttpResponse) request.execute()) { - int statusCode = httpResponse.getStatusLine().getStatusCode(); + int statusCode = httpResponse.getCode(); if (statusCode != 201) { String response = EntityUtils.toString(httpResponse.getEntity()); LOG.error("Error exporting DAT-File representation of API: {} ( {} ). Received Status-Code: {} Response: {}", api.getName(), api.getId(), statusCode, response); @@ -744,7 +741,7 @@ public byte[] getAPIDatFile(API api, String password) throws AppException { uri = new URI(cmd.getAPIManagerURL() + locationHeader); request = new GETRequest(uri); try (CloseableHttpResponse httpResponse = (CloseableHttpResponse) request.execute()) { - int statusCode = httpResponse.getStatusLine().getStatusCode(); + int statusCode = httpResponse.getCode(); if (statusCode != 200) { String response = EntityUtils.toString(httpResponse.getEntity()); LOG.error("Error getting DAT-File representation of API: {} ( {} ). Received Status-Code: {} Response: {}", api.getName(), api.getId(), statusCode, response); @@ -771,7 +768,7 @@ public void importAPIDatFile(File file, String password, String orgId) throws Ap .build(); RestAPICall request = new POSTRequest(entity, uri); try (CloseableHttpResponse httpResponse = (CloseableHttpResponse) request.execute()) { - int statusCode = httpResponse.getStatusLine().getStatusCode(); + int statusCode = httpResponse.getCode(); String response = EntityUtils.toString(httpResponse.getEntity()); if (statusCode != 201) { LOG.error("Error import DAT-File representation of API, Received Status-Code: {} Response: {}", statusCode, response); @@ -797,7 +794,7 @@ public void updateAPIStatus(API api, String desiredState, String vhost) throws A } RestAPICall request = new POSTRequest(entity, uri); try (CloseableHttpResponse httpResponse = (CloseableHttpResponse) request.execute()) { - int statusCode = httpResponse.getStatusLine().getStatusCode(); + int statusCode = httpResponse.getCode(); if (statusCode != 201 && statusCode != 200) { // See issue: #134 The API-Manager also returns 200 on this request String response = EntityUtils.toString(httpResponse.getEntity()); if (statusCode == 403 && response.contains("API is already unpublished")) { @@ -834,7 +831,7 @@ public void updateRetirementDate(API api, Long retirementDate) throws AppExcepti .setPath(cmd.getApiBasepath() + PROXIES + api.getId() + "/deprecate").build(); RestAPICall apiCall = new POSTRequest(new StringEntity("retirementDate=" + formatRetirementDate(retirementDate), ContentType.APPLICATION_FORM_URLENCODED), uri); try (CloseableHttpResponse httpResponse = (CloseableHttpResponse) apiCall.execute()) { - int statusCode = httpResponse.getStatusLine().getStatusCode(); + int statusCode = httpResponse.getCode(); String response = EntityUtils.toString(httpResponse.getEntity()); if (statusCode != 201) { LOG.error("Error updating retirement data of API. Received Status-Code: {} Response: {}", statusCode, response); @@ -892,7 +889,7 @@ public JsonNode importFromWSDL(API api) throws IOException { HttpEntity entity = new UrlEncodedFormEntity(nameValuePairs); RestAPICall importWSDL = new POSTRequest(entity, uri); try (CloseableHttpResponse httpResponse = (CloseableHttpResponse) importWSDL.execute()) { - int statusCode = httpResponse.getStatusLine().getStatusCode(); + int statusCode = httpResponse.getCode(); String response = EntityUtils.toString(httpResponse.getEntity()); if (statusCode != 201) { LOG.error("Error importing WSDL. Received Status-Code: {} Response: {}", statusCode, response); @@ -922,7 +919,7 @@ public JsonNode createBackend(HttpEntity entity, API api) throws AppException { URI uri = new URIBuilder(cmd.getAPIManagerURL()).setPath(cmd.getApiBasepath() + "/apirepo/import/").build(); RestAPICall importSwagger = new POSTRequest(entity, uri); try (CloseableHttpResponse httpResponse = (CloseableHttpResponse) importSwagger.execute()) { - int statusCode = httpResponse.getStatusLine().getStatusCode(); + int statusCode = httpResponse.getCode(); String response = EntityUtils.toString(httpResponse.getEntity()); if (statusCode != 201) { LOG.error("Error importing API-Specification ({}) to create Backend-API using URI: {} Received Status-Code: {} Response: {}", api.getApiDefinition().getAPIDefinitionType().getNiceName(), uri, statusCode, response); @@ -1002,7 +999,7 @@ public void upgradeAccessToNewerAPIWrapper(API apiToUpgradeAccess, API reference throw new AppException("Error taking over application quota to new API. Received Status-Code: " + statusCode, ErrorCode.CANT_UPDATE_QUOTA_CONFIG); } } - } catch (IOException | URISyntaxException e) { + } catch (IOException | URISyntaxException | ParseException e) { throw new AppException("Can't update application quota. Error message: " + e.getMessage(), ErrorCode.CANT_UPDATE_QUOTA_CONFIG, e); } catch (InterruptedException e) { Thread.currentThread().interrupt(); @@ -1039,7 +1036,7 @@ public boolean upgradeAccessToNewerAPI(API apiToUpgradeAccess, API referenceAPI, URI uri = new URIBuilder(cmd.getAPIManagerURL()).setPath(cmd.getApiBasepath() + "/proxies/upgrade/" + referenceAPI.getId()).build(); List params = addParam(apiToUpgradeAccess, deprecateRefApi, retireRefApi, retirementDateRefAPI); - HttpEntity entity = new UrlEncodedFormEntity(params, "UTF-8"); + HttpEntity entity = new UrlEncodedFormEntity(params, StandardCharsets.UTF_8); RestAPICall request = new POSTRequest(entity, uri); Response httpResponse = httpHelper.execute(request, true); int statusCode = httpResponse.getStatusCode(); @@ -1061,7 +1058,7 @@ public boolean upgradeAccessToNewerAPI(API apiToUpgradeAccess, API referenceAPI, } } return true; - } catch (IOException | URISyntaxException e) { + } catch (IOException | URISyntaxException | ParseException e) { throw new AppException("Can't upgrade access to newer API!", ErrorCode.CANT_UPGRADE_API_ACCESS, e); } } @@ -1097,7 +1094,7 @@ public boolean checkCatalogForApiPublishedState(String apiId, String apiName) th URI uri = new URIBuilder(cmd.getAPIManagerURL()).setPath(cmd.getApiBasepath() + "/discovery/swagger/api/id/" + apiId).build(); RestAPICall restAPICall = new GETRequest(uri); try (CloseableHttpResponse httpResponse = (CloseableHttpResponse) restAPICall.execute()) { - int statusCode = httpResponse.getStatusLine().getStatusCode(); + int statusCode = httpResponse.getCode(); String response = EntityUtils.toString(httpResponse.getEntity()); if (statusCode != 200) { LOG.error("API {} not found in API manger catalog Response code : {}", apiName, statusCode); @@ -1155,7 +1152,7 @@ public void grantClientOrganization(List grantAccessToOrgs, API ap // Update the actual state to reflect, which organizations now really have access to the API (this also includes prev. added orgs) if (api.getClientOrganizations() == null) api.setClientOrganizations(new ArrayList<>()); api.getClientOrganizations().addAll(grantAccessToOrgs); - } catch (IOException | URISyntaxException e) { + } catch (IOException | URISyntaxException | ParseException e) { LOG.error("grantAccessToOrgs: {}", grantAccessToOrgs); LOG.error("allOrgs: {}", allOrgs); throw new AppException("Can't grant access to organization.", ErrorCode.ACCESS_ORGANIZATION_ERR, e); @@ -1170,7 +1167,7 @@ public void grantClientApplication(ClientApplication clientApplication, API api) HttpEntity entity = new StringEntity("{\"apiId\":\"" + api.getId() + "\",\"enabled\":true}", ContentType.APPLICATION_JSON); RestAPICall request = new POSTRequest(entity, uri); try (CloseableHttpResponse httpResponse = (CloseableHttpResponse) request.execute()) { - int statusCode = httpResponse.getStatusLine().getStatusCode(); + int statusCode = httpResponse.getCode(); String response = EntityUtils.toString(httpResponse.getEntity()); if (statusCode != 201) { LOG.error("Error granting Application Access to API using URI: {} Received Status-Code: {} Response: {}", uri, statusCode, response); @@ -1189,7 +1186,7 @@ public void revokeClientOrganization(List organizations, API api) URI uri = new URIBuilder(cmd.getAPIManagerURL()).setPath(cmd.getApiBasepath() + PROXIES + api.getId() + "/apiaccess").addParameter(ORGANIZATION_ID, organization.getId()).build(); RestAPICall request = new DELRequest(uri); try (CloseableHttpResponse httpResponse = (CloseableHttpResponse) request.execute()) { - int statusCode = httpResponse.getStatusLine().getStatusCode(); + int statusCode = httpResponse.getCode(); if (statusCode != 204) { LOG.error("Error revoking Organization access to API using URI: {} Response-Code: {}", uri, statusCode); Utils.logPayload(LOG, httpResponse); @@ -1198,7 +1195,7 @@ public void revokeClientOrganization(List organizations, API api) LOG.info("Organization : {} removed access from API: {} {} ( {} ) successfully revoked ", organization.getName(), api.getName(), api.getVersion(), api.getId()); } } - } catch (IOException | URISyntaxException e) { + } catch (IOException | URISyntaxException | ParseException e) { throw new AppException("Can't revoke access to organization.", ErrorCode.ACCESS_ORGANIZATION_ERR, e); } } @@ -1212,7 +1209,7 @@ public void revokeClientApplication(ClientApplication clientApplication, API api URI uri = new URIBuilder(cmd.getAPIManagerURL()).setPath(cmd.getApiBasepath() + APPLICATIONS + clientApplication.getId() + "/apis/" + apiAccess.getId()).build(); RestAPICall request = new DELRequest(uri); try (CloseableHttpResponse httpResponse = (CloseableHttpResponse) request.execute()) { - int statusCode = httpResponse.getStatusLine().getStatusCode(); + int statusCode = httpResponse.getCode(); if (statusCode != 204) { LOG.error("Error revoking application access to API using URI: {} Response-Code: {}", uri, statusCode); Utils.logPayload(LOG, httpResponse); @@ -1223,7 +1220,7 @@ public void revokeClientApplication(ClientApplication clientApplication, API api break; } } - } catch (IOException | URISyntaxException e) { + } catch (IOException | URISyntaxException | ParseException e) { throw new AppException("Can't revoke access to organization.", ErrorCode.REVOKE_ACCESS_APPLICATION_ERR, e); } } diff --git a/modules/apim-adapter/src/main/java/com/axway/apim/adapter/apis/APIManagerAPIMethodAdapter.java b/modules/apim-adapter/src/main/java/com/axway/apim/adapter/apis/APIManagerAPIMethodAdapter.java index 21e087434..355f72e87 100644 --- a/modules/apim-adapter/src/main/java/com/axway/apim/adapter/apis/APIManagerAPIMethodAdapter.java +++ b/modules/apim-adapter/src/main/java/com/axway/apim/adapter/apis/APIManagerAPIMethodAdapter.java @@ -10,12 +10,12 @@ import com.axway.apim.lib.utils.rest.RestAPICall; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; -import org.apache.http.HttpEntity; -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.client.utils.URIBuilder; -import org.apache.http.entity.ContentType; -import org.apache.http.entity.StringEntity; -import org.apache.http.util.EntityUtils; +import org.apache.hc.core5.http.HttpEntity; +import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse; +import org.apache.hc.core5.net.URIBuilder; +import org.apache.hc.core5.http.ContentType; +import org.apache.hc.core5.http.io.entity.StringEntity; +import org.apache.hc.core5.http.io.entity.EntityUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -110,7 +110,7 @@ public void updateApiMethod(APIMethod apiMethod) throws AppException { HttpEntity entity = new StringEntity(json, ContentType.APPLICATION_JSON); RestAPICall putRequest = new PUTRequest(entity, uri); try (CloseableHttpResponse httpResponse = (CloseableHttpResponse) putRequest.execute()) { - int statusCode = httpResponse.getStatusLine().getStatusCode(); + int statusCode = httpResponse.getCode(); String response = EntityUtils.toString(httpResponse.getEntity(), "UTF-8"); if (statusCode < 200 || statusCode > 299) { LOG.debug("Response from server: {}", response); diff --git a/modules/apim-adapter/src/main/java/com/axway/apim/adapter/apis/APIManagerAlertsAdapter.java b/modules/apim-adapter/src/main/java/com/axway/apim/adapter/apis/APIManagerAlertsAdapter.java index 756eb6d43..bb21592ac 100644 --- a/modules/apim-adapter/src/main/java/com/axway/apim/adapter/apis/APIManagerAlertsAdapter.java +++ b/modules/apim-adapter/src/main/java/com/axway/apim/adapter/apis/APIManagerAlertsAdapter.java @@ -13,12 +13,13 @@ import com.fasterxml.jackson.databind.ser.FilterProvider; import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter; import com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider; -import org.apache.http.HttpEntity; -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.client.utils.URIBuilder; -import org.apache.http.entity.ContentType; -import org.apache.http.entity.StringEntity; -import org.apache.http.util.EntityUtils; +import org.apache.hc.core5.http.HttpEntity; +import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse; +import org.apache.hc.core5.net.URIBuilder; +import org.apache.hc.core5.http.ContentType; +import org.apache.hc.core5.http.io.entity.StringEntity; +import org.apache.hc.core5.http.ParseException; +import org.apache.hc.core5.http.io.entity.EntityUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -50,14 +51,14 @@ private void readAlertsFromAPIManager() throws AppException { LOG.debug("Load configured alerts from API-Manager using filter"); try (CloseableHttpResponse httpResponse = (CloseableHttpResponse) getRequest.execute()) { String response = EntityUtils.toString(httpResponse.getEntity()); - int statusCode = httpResponse.getStatusLine().getStatusCode(); + int statusCode = httpResponse.getCode(); if (statusCode < 200 || statusCode > 299) { LOG.error("Error loading alerts from API-Manager. Response-Code: {} Response Body: {}", statusCode, response); throw new AppException("Error loading alerts from API-Manager. Response-Code: " + statusCode, ErrorCode.API_MANAGER_COMMUNICATION); } apiManagerResponse = response; } - } catch (IOException | URISyntaxException e) { + } catch (IOException | URISyntaxException | ParseException e) { throw new AppException("Can't read alerts from API-Manager", ErrorCode.API_MANAGER_COMMUNICATION, e); } } @@ -89,14 +90,14 @@ public void updateAlerts(Alerts alerts) throws AppException { HttpEntity entity = new StringEntity(json, ContentType.APPLICATION_JSON); request = new POSTRequest(entity, uri); try (CloseableHttpResponse httpResponse = (CloseableHttpResponse) request.execute()) { - int statusCode = httpResponse.getStatusLine().getStatusCode(); + int statusCode = httpResponse.getCode(); if (statusCode < 200 || statusCode > 299) { String errorResponse = EntityUtils.toString(httpResponse.getEntity()); LOG.error("Error updating API-Manager alert configuration. Response-Code: {} Response Body: {}", statusCode, errorResponse); throw new AppException("Error updating API-Manager alert configuration. Response-Code: " + statusCode, ErrorCode.API_MANAGER_COMMUNICATION); } } - } catch (URISyntaxException | IOException e) { + } catch (URISyntaxException | IOException | ParseException e) { throw new AppException("Error updating API-Manager alert configuration.", ErrorCode.CANT_CREATE_API_PROXY, e); } } diff --git a/modules/apim-adapter/src/main/java/com/axway/apim/adapter/apis/APIManagerConfigAdapter.java b/modules/apim-adapter/src/main/java/com/axway/apim/adapter/apis/APIManagerConfigAdapter.java index 767544ca3..b0046969a 100644 --- a/modules/apim-adapter/src/main/java/com/axway/apim/adapter/apis/APIManagerConfigAdapter.java +++ b/modules/apim-adapter/src/main/java/com/axway/apim/adapter/apis/APIManagerConfigAdapter.java @@ -12,12 +12,13 @@ import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.module.SimpleModule; -import org.apache.http.HttpEntity; -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.client.utils.URIBuilder; -import org.apache.http.entity.ContentType; -import org.apache.http.entity.StringEntity; -import org.apache.http.util.EntityUtils; +import org.apache.hc.core5.http.HttpEntity; +import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse; +import org.apache.hc.core5.net.URIBuilder; +import org.apache.hc.core5.http.ContentType; +import org.apache.hc.core5.http.ParseException; +import org.apache.hc.core5.http.io.entity.StringEntity; +import org.apache.hc.core5.http.io.entity.EntityUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -43,7 +44,7 @@ public Config getConfig() throws AppException { RestAPICall getRequest = new GETRequest(uri); try (CloseableHttpResponse httpResponse = (CloseableHttpResponse) getRequest.execute()) { String response = EntityUtils.toString(httpResponse.getEntity()); - int statusCode = httpResponse.getStatusLine().getStatusCode(); + int statusCode = httpResponse.getCode(); if (statusCode < 200 || statusCode > 299) { LOG.error("Error loading configuration from API-Manager. Response-Code: {} Got response: {}", statusCode, response); throw new AppException("Error loading configuration from API-Manager. Response-Code: " + statusCode, ErrorCode.API_MANAGER_COMMUNICATION); @@ -68,14 +69,14 @@ public void updateConfiguration(Config desiredConfig) throws AppException { HttpEntity entity = new StringEntity(json, ContentType.APPLICATION_JSON); request = new PUTRequest(entity, uri); try (CloseableHttpResponse httpResponse = (CloseableHttpResponse) request.execute()) { - int statusCode = httpResponse.getStatusLine().getStatusCode(); + int statusCode = httpResponse.getCode(); if (statusCode < 200 || statusCode > 299) { String errorResponse = EntityUtils.toString(httpResponse.getEntity()); LOG.error("Error updating API-Manager configuration. Response-Code: {} Got response: {}", statusCode, errorResponse); throw new AppException("Error updating API-Manager configuration. Response-Code: " + statusCode, ErrorCode.API_MANAGER_COMMUNICATION); } } - } catch (IOException | URISyntaxException e) { + } catch (IOException | URISyntaxException | ParseException e) { throw new AppException("Error updating API-Manager configuration.", ErrorCode.CANT_CREATE_API_PROXY, e); } } diff --git a/modules/apim-adapter/src/main/java/com/axway/apim/adapter/apis/APIManagerOAuthClientProfilesAdapter.java b/modules/apim-adapter/src/main/java/com/axway/apim/adapter/apis/APIManagerOAuthClientProfilesAdapter.java index 932896a6f..afdda6d57 100644 --- a/modules/apim-adapter/src/main/java/com/axway/apim/adapter/apis/APIManagerOAuthClientProfilesAdapter.java +++ b/modules/apim-adapter/src/main/java/com/axway/apim/adapter/apis/APIManagerOAuthClientProfilesAdapter.java @@ -10,9 +10,10 @@ import com.axway.apim.lib.utils.rest.RestAPICall; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.client.utils.URIBuilder; -import org.apache.http.util.EntityUtils; +import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse; +import org.apache.hc.core5.net.URIBuilder; +import org.apache.hc.core5.http.io.entity.EntityUtils; +import org.apache.hc.core5.http.ParseException; import org.ehcache.Cache; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -49,14 +50,14 @@ private void readOAuthClientProfilesFromAPIManager() throws AppException { RestAPICall getRequest = new GETRequest(uri); LOG.debug("Load OAuth-Profiles from API-Manager."); try(CloseableHttpResponse httpResponse = (CloseableHttpResponse) getRequest.execute()) { - int statusCode = httpResponse.getStatusLine().getStatusCode(); + int statusCode = httpResponse.getCode(); if (statusCode != 200) { throw new AppException("Can't get OAuth Client profiles from API-Manager.", ErrorCode.API_MANAGER_COMMUNICATION); } this.apiManagerResponse = EntityUtils.toString(httpResponse.getEntity(), "UTF-8"); oauthClientCache.put(CACHE_KEY, this.apiManagerResponse); } - } catch (URISyntaxException | UnsupportedOperationException | IOException e) { + } catch (URISyntaxException | UnsupportedOperationException | IOException | ParseException e) { throw new AppException("Can't get OAuth Client profiles from API-Manager.", ErrorCode.API_MANAGER_COMMUNICATION, e); } } diff --git a/modules/apim-adapter/src/main/java/com/axway/apim/adapter/apis/APIManagerOrganizationAdapter.java b/modules/apim-adapter/src/main/java/com/axway/apim/adapter/apis/APIManagerOrganizationAdapter.java index 0e32e3fca..a72869fa8 100644 --- a/modules/apim-adapter/src/main/java/com/axway/apim/adapter/apis/APIManagerOrganizationAdapter.java +++ b/modules/apim-adapter/src/main/java/com/axway/apim/adapter/apis/APIManagerOrganizationAdapter.java @@ -17,14 +17,14 @@ import com.fasterxml.jackson.databind.ser.FilterProvider; import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter; import com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider; -import org.apache.http.HttpEntity; -import org.apache.http.HttpStatus; -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.client.utils.URIBuilder; -import org.apache.http.entity.ContentType; -import org.apache.http.entity.StringEntity; -import org.apache.http.entity.mime.MultipartEntityBuilder; -import org.apache.http.util.EntityUtils; +import org.apache.hc.core5.http.HttpEntity; +import org.apache.hc.core5.http.HttpStatus; +import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse; +import org.apache.hc.core5.net.URIBuilder; +import org.apache.hc.core5.http.ContentType; +import org.apache.hc.core5.http.io.entity.StringEntity; +import org.apache.hc.client5.http.entity.mime.MultipartEntityBuilder; +import org.apache.hc.core5.http.io.entity.EntityUtils; import org.ehcache.Cache; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -73,8 +73,8 @@ private void readOrgsFromAPIManager(OrgFilter filter) throws AppException { LOG.debug("Load organizations from API-Manager using filter: {}", filter); LOG.debug("Load organization with URI: {}", uri); try (CloseableHttpResponse httpResponse = (CloseableHttpResponse) getRequest.execute()) { - if (httpResponse.getStatusLine().getStatusCode() != HttpStatus.SC_OK) { - LOG.error("Received Status-Code: {}", httpResponse.getStatusLine().getStatusCode()); + if (httpResponse.getCode() != HttpStatus.SC_OK) { + LOG.error("Received Status-Code: {}", httpResponse.getCode()); Utils.logPayload(LOG, httpResponse); throw new AppException("", ErrorCode.API_MANAGER_COMMUNICATION); } @@ -144,7 +144,7 @@ public Organization upsertOrganization(URI uri, Organization actualOrg, Organiza request = new PUTRequest(entity, uri); } try (CloseableHttpResponse httpResponse = (CloseableHttpResponse) request.execute()) { - int statusCode = httpResponse.getStatusLine().getStatusCode(); + int statusCode = httpResponse.getCode(); if (statusCode < 200 || statusCode > 299) { LOG.error("Error creating/updating organization. Response-Code: {}", statusCode); Utils.logPayload(LOG, httpResponse); @@ -162,7 +162,7 @@ public void deleteOrganization(Organization org) throws AppException { URI uri = new URIBuilder(cmd.getAPIManagerURL()).setPath(cmd.getApiBasepath() + ORGANIZATIONS + org.getId()).build(); RestAPICall request = new DELRequest(uri); try (CloseableHttpResponse httpResponse = (CloseableHttpResponse) request.execute()) { - int statusCode = httpResponse.getStatusLine().getStatusCode(); + int statusCode = httpResponse.getCode(); if (statusCode != 204) { LOG.error("Error deleting organization. Response-Code: {}", statusCode); Utils.logPayload(LOG, httpResponse); @@ -188,7 +188,7 @@ private void saveImage(Organization org, Organization actualOrg) throws URISynta try { RestAPICall apiCall = new POSTRequest(entity, uri); try (CloseableHttpResponse httpResponse = (CloseableHttpResponse) apiCall.execute()) { - int statusCode = httpResponse.getStatusLine().getStatusCode(); + int statusCode = httpResponse.getCode(); if (statusCode < 200 || statusCode > 299) { LOG.error("Error saving/updating organization image. Response-Code: {}", statusCode); Utils.logPayload(LOG, httpResponse); diff --git a/modules/apim-adapter/src/main/java/com/axway/apim/adapter/apis/APIManagerPoliciesAdapter.java b/modules/apim-adapter/src/main/java/com/axway/apim/adapter/apis/APIManagerPoliciesAdapter.java index 203655840..df0d07ebc 100644 --- a/modules/apim-adapter/src/main/java/com/axway/apim/adapter/apis/APIManagerPoliciesAdapter.java +++ b/modules/apim-adapter/src/main/java/com/axway/apim/adapter/apis/APIManagerPoliciesAdapter.java @@ -15,9 +15,9 @@ import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.client.utils.URIBuilder; -import org.apache.http.util.EntityUtils; +import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse; +import org.apache.hc.core5.net.URIBuilder; +import org.apache.hc.core5.http.io.entity.EntityUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -154,7 +154,7 @@ public String getOauthTokenStore(String name) throws AppException { URI uri = new URIBuilder(cmd.getAPIManagerURL()).setPath(cmd.getApiBasepath() + "/tokenstores").build(); RestAPICall getRequest = new GETRequest(uri); try (CloseableHttpResponse httpResponse = (CloseableHttpResponse) getRequest.execute()) { - LOG.debug("Get token stores Response code : {}", httpResponse.getStatusLine().getStatusCode()); + LOG.debug("Get token stores Response code : {}", httpResponse.getCode()); String response = EntityUtils.toString(httpResponse.getEntity()); JsonNode jsonResponse = objectMapper.readTree(response); for (JsonNode node : jsonResponse) { diff --git a/modules/apim-adapter/src/main/java/com/axway/apim/adapter/apis/APIManagerQuotaAdapter.java b/modules/apim-adapter/src/main/java/com/axway/apim/adapter/apis/APIManagerQuotaAdapter.java index dd38abe4d..11ec4772f 100644 --- a/modules/apim-adapter/src/main/java/com/axway/apim/adapter/apis/APIManagerQuotaAdapter.java +++ b/modules/apim-adapter/src/main/java/com/axway/apim/adapter/apis/APIManagerQuotaAdapter.java @@ -4,28 +4,35 @@ import com.axway.apim.adapter.CacheType; import com.axway.apim.adapter.HttpHelper; import com.axway.apim.adapter.Response; +import com.axway.apim.adapter.apis.QuotaConstraintDiff.QuotaConstraintOperations; import com.axway.apim.adapter.jackson.QuotaRestrictionDeserializer; import com.axway.apim.adapter.jackson.QuotaRestrictionDeserializer.DeserializeMode; import com.axway.apim.api.API; import com.axway.apim.api.model.APIQuota; import com.axway.apim.api.model.QuotaRestriction; import com.axway.apim.lib.CoreParameters; +import com.axway.apim.lib.CoreParameters.QuotaUpdateMode; import com.axway.apim.lib.error.AppException; import com.axway.apim.lib.error.ErrorCode; +import com.axway.apim.lib.utils.rest.DELRequest; import com.axway.apim.lib.utils.rest.GETRequest; +import com.axway.apim.lib.utils.rest.POSTRequest; import com.axway.apim.lib.utils.rest.PUTRequest; import com.axway.apim.lib.utils.rest.RestAPICall; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.ObjectWriter; import com.fasterxml.jackson.databind.module.SimpleModule; import com.fasterxml.jackson.databind.ser.FilterProvider; import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter; import com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider; -import org.apache.http.HttpEntity; -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.client.utils.URIBuilder; -import org.apache.http.entity.ContentType; -import org.apache.http.entity.StringEntity; -import org.apache.http.util.EntityUtils; +import com.fasterxml.jackson.databind.type.CollectionType; +import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse; +import org.apache.hc.core5.http.ContentType; +import org.apache.hc.core5.http.HttpEntity; +import org.apache.hc.core5.http.ParseException; +import org.apache.hc.core5.http.io.entity.EntityUtils; +import org.apache.hc.core5.http.io.entity.StringEntity; +import org.apache.hc.core5.net.URIBuilder; import org.ehcache.Cache; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -34,15 +41,25 @@ import java.net.URI; import java.net.URISyntaxException; import java.util.ArrayList; +import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; +import static com.axway.apim.adapter.apis.APIManagerQuotaAdapter.Quota.isDefaultQuota; + public class APIManagerQuotaAdapter { private static final Logger LOG = LoggerFactory.getLogger(APIManagerQuotaAdapter.class); private static final HttpHelper httpHelper = new HttpHelper(); + /** + * The first API-Manager version exposing the per-constraint endpoints below /quotas/{id}/constraints. + */ + public static final String QUOTA_CONSTRAINTS_MIN_VERSION = "7.7.20261130"; + + private static final String[] QUOTA_WRITE_EXCLUDES = {"apiId", "apiName", "apiVersion", "apiPath", "vhost", "queryVersion"}; + public enum Quota { SYSTEM_DEFAULT("00000000-0000-0000-0000-000000000000", "System default"), APPLICATION_DEFAULT("00000000-0000-0000-0000-000000000001", "Application default"); @@ -62,15 +79,49 @@ public String getQuotaId() { public String getFriendlyName() { return friendlyName; } + + public static boolean isDefaultQuota(String quotaId) { + return SYSTEM_DEFAULT.getQuotaId().equals(quotaId) || APPLICATION_DEFAULT.getQuotaId().equals(quotaId); + } + } + + /** + * Signals that this API-Manager does not serve the /quotas/{id}/constraints endpoints, so the complete quota + * document has to be replaced instead. + */ + static class ConstraintsUnsupportedException extends Exception { + private static final long serialVersionUID = 1L; + + ConstraintsUnsupportedException(String message) { + super(message); + } } Cache applicationsQuotaCache; ObjectMapper mapper = new ObjectMapper(); + /** + * Separate mappers for the constraint endpoints, so that the shared mapper above - which getQuota and + * saveQuota mutate via registerModule and setFilterProvider - cannot influence them. + */ + private ObjectMapper constraintReadMapper; + private final ObjectMapper constraintWriteMapper = new ObjectMapper(); + private final CoreParameters cmd; private final Map apiManagerResponse = new HashMap<>(); + private final Map> constraintsResponse = new HashMap<>(); + /** + * Memoised result of the API-Manager version check. + */ + private Boolean constraintsSupported; + + /** + * Latched as soon as the API-Manager turns out not to serve the constraint endpoints, so that the probe is + * done at most once per run. + */ + private boolean constraintsUnavailable = false; public APIManagerQuotaAdapter(APIManagerAdapter apiManagerAdapter) { cmd = CoreParameters.getInstance(); @@ -83,7 +134,7 @@ private void readQuotaFromAPIManager(String quotaId) throws AppException { if (apiManagerResponse.get(quotaId) != null) return; URI uri; try { - if (Quota.APPLICATION_DEFAULT.getQuotaId().equals(quotaId) || Quota.SYSTEM_DEFAULT.getQuotaId().equals(quotaId)) { + if (isDefaultQuota(quotaId)) { uri = new URIBuilder(cmd.getAPIManagerURL()).setPath(cmd.getApiBasepath() + "/quotas/" + quotaId).build(); } else { if (applicationsQuotaCache.containsKey(quotaId)) { @@ -97,17 +148,17 @@ private void readQuotaFromAPIManager(String quotaId) throws AppException { RestAPICall getRequest = new GETRequest(uri); LOG.debug("Load quotas with ID: {} from API-Manager URI : {}", quotaId, uri); try (CloseableHttpResponse httpResponse = (CloseableHttpResponse) getRequest.execute()) { - int statusCode = httpResponse.getStatusLine().getStatusCode(); + int statusCode = httpResponse.getCode(); String response = EntityUtils.toString(httpResponse.getEntity(), "UTF-8"); if (statusCode != 200) { throw new AppException("Can't read API-Manager Quota-Configuration. Got status code: " + statusCode + " for request: " + uri, ErrorCode.API_MANAGER_COMMUNICATION); } apiManagerResponse.put(quotaId, response); - if (!Quota.APPLICATION_DEFAULT.getQuotaId().equals(quotaId) && !Quota.SYSTEM_DEFAULT.getQuotaId().equals(quotaId)) { + if (!isDefaultQuota(quotaId)) { applicationsQuotaCache.put(quotaId, response); } } - } catch (URISyntaxException | UnsupportedOperationException | IOException e) { + } catch (URISyntaxException | UnsupportedOperationException | IOException | ParseException e) { throw new AppException("Can't get API-Manager Quota-Configuration.", ErrorCode.UNXPECTED_ERROR, e); } } @@ -139,11 +190,84 @@ public APIQuota getQuota(String quotaId, API api, boolean addRestrictedAPI, bool return quotaConfig; } + /** + * Replicates the given quota document in the API-Manager. + *

+ * On an API-Manager serving the /quotas/{id}/constraints endpoints each restriction is added, updated or removed + * individually, which leaves the restrictions of other APIs untouched. Otherwise the complete quota document is + * replaced, as done before those endpoints existed. + */ public void saveQuota(APIQuota quotaConfig, String quotaId) throws AppException { if (!APIManagerAdapter.getInstance().hasAdminAccount()) return; + if (useConstraints(quotaId)) { + try { + saveQuotaUsingConstraints(quotaConfig, quotaId); + return; + } catch (ConstraintsUnsupportedException e) { + // The reported version promised the constraint endpoints but the API-Manager does not serve them. + // Falling back is safe even half way through the operations: the caller always hands over the + // complete desired quota document, so replacing the whole document re-establishes exactly the + // intended end state. The API-Manager supports both representations and does not deprecate the + // document level update, which makes this self healing rather than destructive. + LOG.warn("API-Manager does not support the quota constraints endpoints ({}). Falling back to updating the complete quota document for the rest of this run.", e.getMessage()); + constraintsUnavailable = true; + } + } + saveQuotaLegacy(quotaConfig, quotaId); + } + + /** + * Decides whether the per-constraint endpoints can be used for the given quota. + */ + public boolean useConstraints(String quotaId) { + if (constraintsUnavailable) return false; + QuotaUpdateMode quotaUpdateMode = cmd.getQuotaUpdateMode(); + if (quotaUpdateMode == QuotaUpdateMode.legacy) return false; + // The API-Manager exposes the constraints only below /quotas/{id}. Application specific quotas are managed + // through /applications/{id}/quota, which has no per-constraint sub resource. + if (!isDefaultQuota(quotaId)) return false; + if (quotaUpdateMode == QuotaUpdateMode.constraints) return true; + if (constraintsSupported == null) { + constraintsSupported = APIManagerAdapter.hasAPIManagerVersion(QUOTA_CONSTRAINTS_MIN_VERSION); + LOG.debug("API-Manager quota constraints endpoints supported: {} (required version: {})", constraintsSupported, QUOTA_CONSTRAINTS_MIN_VERSION); + } + return constraintsSupported; + } + + private void saveQuotaUsingConstraints(APIQuota quotaConfig, String quotaId) throws AppException, ConstraintsUnsupportedException { + List actualRestrictions = getConstraints(quotaId); + List desiredRestrictions = quotaConfig == null || quotaConfig.getRestrictions() == null + ? Collections.emptyList() : quotaConfig.getRestrictions(); + QuotaConstraintOperations operations = QuotaConstraintDiff.diff(actualRestrictions, desiredRestrictions); + if (operations.isEmpty()) { + LOG.info("Quota with ID: {} is UN-CHANGED. Nothing to do.", quotaId); + return; + } + LOG.debug("Updating quota with ID: {} using constraints: {}", quotaId, operations); + // Delete first: a changed restriction scope becomes a delete of the old scope plus a create of the new one, + // and the API-Manager may reject a create that collides with the restriction still to be deleted. + for (QuotaRestriction restriction : operations.getToDelete()) { + if (restriction.getId() == null) { + throw new ConstraintsUnsupportedException("API-Manager did not return an ID for restriction: " + restriction); + } + deleteConstraint(quotaId, restriction.getId()); + } + for (QuotaRestriction restriction : operations.getToUpdate()) { + updateConstraint(quotaId, restriction); + } + for (QuotaRestriction restriction : operations.getToCreate()) { + createConstraint(quotaId, restriction); + } + invalidateQuota(quotaId); + } + + /** + * The original document level update, kept for API-Managers without the constraint endpoints. + */ + private void saveQuotaLegacy(APIQuota quotaConfig, String quotaId) throws AppException { try { URI uri = new URIBuilder(cmd.getAPIManagerURL()).setPath(cmd.getApiBasepath() + "/quotas/" + quotaId).build(); - FilterProvider filter = new SimpleFilterProvider().setDefaultFilter(SimpleBeanPropertyFilter.serializeAllExcept("apiId", "apiName", "apiVersion", "apiPath", "vhost", "queryVersion")); + FilterProvider filter = new SimpleFilterProvider().setDefaultFilter(SimpleBeanPropertyFilter.serializeAllExcept(QUOTA_WRITE_EXCLUDES)); mapper.setFilterProvider(filter); HttpEntity entity = new StringEntity(mapper.writeValueAsString(quotaConfig), ContentType.APPLICATION_JSON); RestAPICall request = new PUTRequest(entity, uri); @@ -161,10 +285,8 @@ public void saveQuota(APIQuota quotaConfig, String quotaId) throws AppException throw new AppException("Can't update API-Manager Quota-Configuration. Response: '" + response + "'", ErrorCode.API_MANAGER_COMMUNICATION); } } - // Force reload of this quota next time - applicationsQuotaCache.remove(quotaId); - mapper.readValue(response, APIQuota.class); - } catch (IOException | URISyntaxException e) { + invalidateQuota(quotaId); + } catch (URISyntaxException | IOException | ParseException e) { throw new AppException("Can't update Quota-Configuration in API-Manager.", ErrorCode.UNXPECTED_ERROR, e); } catch (InterruptedException e) { Thread.currentThread().interrupt(); @@ -183,7 +305,200 @@ public APIQuota getDefaultQuota(Quota quotaType) throws AppException { return quotaConfig; } - private static void retrySaveQuota(RestAPICall request) throws IOException { + // ------------------------------------------------------------------------------------------------------------ + // Quota constraints: /quotas/{quotaId}/constraints[/{constraintId}] + // ------------------------------------------------------------------------------------------------------------ + + /** + * Returns every restriction of the given quota, each carrying the ID assigned by the API-Manager. + * + * @throws ConstraintsUnsupportedException if this API-Manager does not serve the constraint endpoints. + */ + public List getConstraints(String quotaId) throws AppException, ConstraintsUnsupportedException { + if (!APIManagerAdapter.getInstance().hasAdminAccount()) return Collections.emptyList(); + List cached = constraintsResponse.get(quotaId); + if (cached != null) return cached; + URI uri = constraintsUri(quotaId, null); + Response response = executeConstraintCall(new GETRequest(uri), "read quota constraints", uri); + int statusCode = response.getStatusCode(); + // A 404 on the collection of an always existing default quota, or a 405, means the endpoint itself is absent. + if (statusCode == 404 || statusCode == 405) { + throw new ConstraintsUnsupportedException("Got status code: " + statusCode + " for request: " + uri); + } + if (statusCode < 200 || statusCode > 299) { + throw new AppException("Can't read API-Manager quota constraints. Got status code: " + statusCode + " for request: " + uri + " Response: '" + response.getResponseBody() + "'", ErrorCode.API_MANAGER_COMMUNICATION); + } + List restrictions = readConstraintList(response.getResponseBody(), uri); + constraintsResponse.put(quotaId, restrictions); + return restrictions; + } + + + /** + * Adds a single restriction to the given quota, leaving the other restrictions untouched. + * + * @return the created restriction including the ID assigned by the API-Manager. + */ + public QuotaRestriction createConstraint(String quotaId, QuotaRestriction restriction) throws AppException { + if (!APIManagerAdapter.getInstance().hasAdminAccount()) return null; + URI uri = constraintsUri(quotaId, null); + HttpEntity entity = new StringEntity(writeConstraint(restriction), ContentType.APPLICATION_JSON); + Response response = executeConstraintCall(new POSTRequest(entity, uri), "create quota constraint", uri); + if (response.getStatusCode() < 200 || response.getStatusCode() > 299) { + throw new AppException("Can't create API-Manager quota constraint. Got status code: " + response.getStatusCode() + " for request: " + uri + " Response: '" + response.getResponseBody() + "'", ErrorCode.CANT_UPDATE_QUOTA_CONFIG); + } + LOG.info("Created quota constraint: {}", restriction); + invalidateQuota(quotaId); + return readConstraint(response.getResponseBody(), uri); + } + + /** + * Updates a single restriction in place. The API-Manager does not allow the api and the method of a restriction + * to be changed, which is why the caller must only change the configuration. + */ + public QuotaRestriction updateConstraint(String quotaId, QuotaRestriction restriction) throws AppException { + if (!APIManagerAdapter.getInstance().hasAdminAccount()) return null; + if (restriction.getId() == null) { + throw new AppException("Can't update quota constraint without an ID: " + restriction, ErrorCode.CANT_UPDATE_QUOTA_CONFIG); + } + URI uri = constraintsUri(quotaId, restriction.getId()); + HttpEntity entity = new StringEntity(writeConstraint(restriction), ContentType.APPLICATION_JSON); + Response response = executeConstraintCall(new PUTRequest(entity, uri), "update quota constraint", uri); + // The restriction disappeared between reading and writing it. Re-create it instead of failing the run. + if (response.getStatusCode() == 404 || isConstraintNotFound(response)) { + LOG.debug("Quota constraint: {} no longer exists. Creating it instead.", restriction.getId()); + invalidateQuota(quotaId); + return createConstraint(quotaId, restriction); + } + if (response.getStatusCode() < 200 || response.getStatusCode() > 299) { + throw new AppException("Can't update API-Manager quota constraint. Got status code: " + response.getStatusCode() + " for request: " + uri + " Response: '" + response.getResponseBody() + "'", ErrorCode.CANT_UPDATE_QUOTA_CONFIG); + } + LOG.info("Updated quota constraint: {}", restriction); + invalidateQuota(quotaId); + return readConstraint(response.getResponseBody(), uri); + } + + /** + * Removes a single restriction from the given quota, leaving the other restrictions untouched. + */ + public void deleteConstraint(String quotaId, String constraintId) throws AppException { + if (!APIManagerAdapter.getInstance().hasAdminAccount()) return; + URI uri = constraintsUri(quotaId, constraintId); + Response response = executeConstraintCall(new DELRequest(uri), "delete quota constraint", uri); + // Somebody else removed it already, which is the state we wanted to reach anyway. + if (response.getStatusCode() == 404 || isConstraintNotFound(response)) { + LOG.debug("Quota constraint: {} was already removed.", constraintId); + invalidateQuota(quotaId); + return; + } + if (response.getStatusCode() < 200 || response.getStatusCode() > 299) { + throw new AppException("Can't delete API-Manager quota constraint. Got status code: " + response.getStatusCode() + " for request: " + uri + " Response: '" + response.getResponseBody() + "'", ErrorCode.CANT_UPDATE_QUOTA_CONFIG); + } + LOG.info("Deleted quota constraint with ID: {}", constraintId); + invalidateQuota(quotaId); + } + + private URI constraintsUri(String quotaId, String constraintId) throws AppException { + try { + String path = cmd.getApiBasepath() + "/quotas/" + quotaId + "/constraints" + + (constraintId == null ? "" : "/" + constraintId); + return new URIBuilder(cmd.getAPIManagerURL()).setPath(path).build(); + } catch (URISyntaxException e) { + throw new AppException("Can't build quota constraints URI.", ErrorCode.UNXPECTED_ERROR, e); + } + } + + /** + * Executes the call and retries it once on the errors the API-Manager is known to report while a just created + * API is not yet visible to the quota service. This mirrors the tolerance of the document level update. + */ + private Response executeConstraintCall(RestAPICall request, String what, URI uri) throws AppException { + try { + LOG.debug("Request to {}: {}", what, uri); + Response response = httpHelper.execute(request, true); + if (isTransientError(response)) { + LOG.warn("Got unexpected error while trying to {} ... Try again in {} milliseconds. (you may set -retryDelay )", what, cmd.getRetryDelay()); + Thread.sleep(cmd.getRetryDelay()); + response = httpHelper.execute(request, true); + } + return response; + } catch (IOException | ParseException e) { + throw new AppException("Can't " + what + " in API-Manager.", ErrorCode.UNXPECTED_ERROR, e); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new AppException("Interrupted while trying to " + what + " in API-Manager.", ErrorCode.UNXPECTED_ERROR, e); + } + } + + private static boolean isTransientError(Response response) { + String body = response.getResponseBody() == null ? "" : response.getResponseBody(); + return (response.getStatusCode() == 400 && body.contains("API not found")) + || (response.getStatusCode() == 500 && body.contains("Internal server error")); + } + + /** + * The API-Manager reports a missing restriction in the response body rather than through a dedicated status code. + */ + private static boolean isConstraintNotFound(Response response) { + String body = response.getResponseBody(); + return body != null && body.contains("Quota constraint not found"); + } + + private List readConstraintList(String responseBody, URI uri) throws AppException { + if (responseBody == null || responseBody.trim().isEmpty()) return new ArrayList<>(); + try { + ObjectMapper readMapper = constraintReadMapper(); + CollectionType listType = readMapper.getTypeFactory().constructCollectionType(List.class, QuotaRestriction.class); + return readMapper.readValue(responseBody, listType); + } catch (IOException e) { + throw new AppException("Can't parse quota constraints returned by: " + uri, ErrorCode.API_MANAGER_COMMUNICATION, e); + } + } + + private QuotaRestriction readConstraint(String responseBody, URI uri) throws AppException { + if (responseBody == null || responseBody.trim().isEmpty()) return null; + try { + return constraintReadMapper().readValue(responseBody, QuotaRestriction.class); + } catch (IOException e) { + throw new AppException("Can't parse quota constraint returned by: " + uri, ErrorCode.API_MANAGER_COMMUNICATION, e); + } + } + + private String writeConstraint(QuotaRestriction restriction) throws AppException { + try { + FilterProvider filter = new SimpleFilterProvider().setDefaultFilter(SimpleBeanPropertyFilter.serializeAllExcept(QUOTA_WRITE_EXCLUDES)); + ObjectWriter writer = constraintWriteMapper.writer(filter); + return writer.writeValueAsString(restriction); + } catch (IOException e) { + throw new AppException("Can't serialize quota constraint: " + restriction, ErrorCode.UNXPECTED_ERROR, e); + } + } + + /** + * Built lazily, as the deserializer resolves other adapters which are not available while this adapter is + * being constructed. addRestrictedAPI is false on purpose: resolving the API per restriction would issue one + * lookup per restriction and the system default quota can hold hundreds of them. + */ + private ObjectMapper constraintReadMapper() { + if (constraintReadMapper == null) { + constraintReadMapper = new ObjectMapper(); + constraintReadMapper.registerModule(new SimpleModule().addDeserializer(QuotaRestriction.class, + new QuotaRestrictionDeserializer(DeserializeMode.apiManagerData, false))); + } + return constraintReadMapper; + } + + /** + * Drops every cached representation of the quota. apiManagerResponse must be included, as otherwise a later + * read in the same run returns the state from before the update. + */ + private void invalidateQuota(String quotaId) { + apiManagerResponse.remove(quotaId); + constraintsResponse.remove(quotaId); + applicationsQuotaCache.remove(quotaId); + } + + private static void retrySaveQuota(RestAPICall request) throws IOException, ParseException { Response httpResponse = httpHelper.execute(request, true); String response = httpResponse.getResponseBody(); int statusCode = httpResponse.getStatusCode(); diff --git a/modules/apim-adapter/src/main/java/com/axway/apim/adapter/apis/APIManagerRemoteHostsAdapter.java b/modules/apim-adapter/src/main/java/com/axway/apim/adapter/apis/APIManagerRemoteHostsAdapter.java index 9ec66c0b2..677ade22c 100644 --- a/modules/apim-adapter/src/main/java/com/axway/apim/adapter/apis/APIManagerRemoteHostsAdapter.java +++ b/modules/apim-adapter/src/main/java/com/axway/apim/adapter/apis/APIManagerRemoteHostsAdapter.java @@ -17,12 +17,12 @@ import com.fasterxml.jackson.databind.ser.FilterProvider; import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter; import com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider; -import org.apache.http.HttpEntity; -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.client.utils.URIBuilder; -import org.apache.http.entity.ContentType; -import org.apache.http.entity.StringEntity; -import org.apache.http.util.EntityUtils; +import org.apache.hc.core5.http.HttpEntity; +import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse; +import org.apache.hc.core5.net.URIBuilder; +import org.apache.hc.core5.http.ContentType; +import org.apache.hc.core5.http.io.entity.StringEntity; +import org.apache.hc.core5.http.io.entity.EntityUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -53,7 +53,7 @@ private void readRemoteHostsFromAPIManager(RemoteHostFilter filter) throws AppEx LOG.debug("Load remote hosts from API-Manager using filter: {}", filter); try (CloseableHttpResponse httpResponse = (CloseableHttpResponse) getRequest.execute()) { String response = EntityUtils.toString(httpResponse.getEntity()); - int statusCode = httpResponse.getStatusLine().getStatusCode(); + int statusCode = httpResponse.getCode(); if (statusCode < 200 || statusCode > 299) { LOG.error("Error loading remoteHosts from API-Manager. Response-Code: {} Got Response Body:{}", statusCode, response); throw new AppException("Error loading remoteHosts from API-Manager. Response-Code: " + statusCode, ErrorCode.API_MANAGER_COMMUNICATION); @@ -124,7 +124,7 @@ public void createOrUpdateRemoteHost(RemoteHost desiredRemoteHost, RemoteHost ac request = new PUTRequest(entity, uri); } try (CloseableHttpResponse httpResponse = (CloseableHttpResponse) request.execute()) { - int statusCode = httpResponse.getStatusLine().getStatusCode(); + int statusCode = httpResponse.getCode(); if (statusCode < 200 || statusCode > 299) { String errorResponse = EntityUtils.toString(httpResponse.getEntity()); LOG.error("Error creating/updating remote host. Response-Code: {} Response Body: {}", statusCode, errorResponse); diff --git a/modules/apim-adapter/src/main/java/com/axway/apim/adapter/apis/FilterHelper.java b/modules/apim-adapter/src/main/java/com/axway/apim/adapter/apis/FilterHelper.java index 10bf96ff5..3b8fa2982 100644 --- a/modules/apim-adapter/src/main/java/com/axway/apim/adapter/apis/FilterHelper.java +++ b/modules/apim-adapter/src/main/java/com/axway/apim/adapter/apis/FilterHelper.java @@ -1,7 +1,7 @@ package com.axway.apim.adapter.apis; -import org.apache.http.NameValuePair; -import org.apache.http.message.BasicNameValuePair; +import org.apache.hc.core5.http.NameValuePair; +import org.apache.hc.core5.http.message.BasicNameValuePair; import java.util.List; diff --git a/modules/apim-adapter/src/main/java/com/axway/apim/adapter/apis/OrgFilter.java b/modules/apim-adapter/src/main/java/com/axway/apim/adapter/apis/OrgFilter.java index ed133bdc5..35221d713 100644 --- a/modules/apim-adapter/src/main/java/com/axway/apim/adapter/apis/OrgFilter.java +++ b/modules/apim-adapter/src/main/java/com/axway/apim/adapter/apis/OrgFilter.java @@ -3,8 +3,8 @@ import com.axway.apim.api.model.Organization; import com.axway.apim.lib.CustomPropertiesFilter; import org.apache.commons.lang3.Strings; -import org.apache.http.NameValuePair; -import org.apache.http.message.BasicNameValuePair; +import org.apache.hc.core5.http.NameValuePair; +import org.apache.hc.core5.http.message.BasicNameValuePair; import java.util.ArrayList; import java.util.List; diff --git a/modules/apim-adapter/src/main/java/com/axway/apim/adapter/apis/QuotaConstraintDiff.java b/modules/apim-adapter/src/main/java/com/axway/apim/adapter/apis/QuotaConstraintDiff.java new file mode 100644 index 000000000..ad1a3fdc0 --- /dev/null +++ b/modules/apim-adapter/src/main/java/com/axway/apim/adapter/apis/QuotaConstraintDiff.java @@ -0,0 +1,188 @@ +package com.axway.apim.adapter.apis; + +import com.axway.apim.api.model.QuotaRestriction; +import com.axway.apim.api.model.QuotaRestrictionType; + +import java.util.ArrayDeque; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Deque; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * Turns a desired quota document into the set of per-constraint operations required to reach it, so that the + * API-Manager endpoints below /quotas/{id}/constraints can be used instead of replacing the entire quota document. + *

+ * This class is deliberately free of any HTTP or state, which makes the migration testable without a running + * API-Manager. + */ +public class QuotaConstraintDiff { + + public static final String PERIOD = "period"; + public static final String PER = "per"; + public static final String MESSAGES = "messages"; + public static final String MB = "mb"; + + private static final String ALL = "*"; + + private QuotaConstraintDiff() { + } + + /** + * The operations required to turn actual into desired. + * They must be executed in the order DELETE, UPDATE, CREATE. A change of the restriction scope surfaces as a + * delete of the old scope plus a create of the new one, and if the API-Manager enforces uniqueness on + * (api, method, type) creating before deleting would be rejected. + */ + public static class QuotaConstraintOperations { + private final List toDelete = new ArrayList<>(); + private final List toUpdate = new ArrayList<>(); + private final List toCreate = new ArrayList<>(); + + public List getToDelete() { + return toDelete; + } + + public List getToUpdate() { + return toUpdate; + } + + public List getToCreate() { + return toCreate; + } + + public boolean isEmpty() { + return toDelete.isEmpty() && toUpdate.isEmpty() && toCreate.isEmpty(); + } + + public int size() { + return toDelete.size() + toUpdate.size() + toCreate.size(); + } + + @Override + public String toString() { + return "QuotaConstraintOperations [delete=" + toDelete.size() + ", update=" + toUpdate.size() + + ", create=" + toCreate.size() + "]"; + } + } + + /** + * Compares the restrictions currently known to the API-Manager against the desired ones. + * + * @param actual the restrictions as returned by GET /quotas/{id}/constraints. These carry the constraint ID. + * @param desired the complete desired quota document. These do not need to carry a constraint ID. + * @return the operations required, which is empty when nothing has to be changed. + */ + public static QuotaConstraintOperations diff(List actual, List desired) { + QuotaConstraintOperations operations = new QuotaConstraintOperations(); + List actualRestrictions = actual == null ? Collections.emptyList() : actual; + List desiredRestrictions = desired == null ? Collections.emptyList() : desired; + + // A Deque per key, as the legacy replace-all PUT was able to create duplicates. Any surplus is deleted. + Map> actualByKey = new HashMap<>(); + for (QuotaRestriction restriction : actualRestrictions) { + actualByKey.computeIfAbsent(new Key(restriction), key -> new ArrayDeque<>()).add(restriction); + } + + for (QuotaRestriction desiredRestriction : desiredRestrictions) { + Deque candidates = actualByKey.get(new Key(desiredRestriction)); + QuotaRestriction match = candidates == null ? null : candidates.poll(); + if (match == null) { + operations.getToCreate().add(desiredRestriction); + } else if (!configEquals(match, desiredRestriction)) { + // The key already pins api, method and type, so an update can never attempt to change the + // restriction scope, which the API-Manager does not allow. + operations.getToUpdate().add(merge(match, desiredRestriction)); + } + } + + for (Deque remaining : actualByKey.values()) { + operations.getToDelete().addAll(remaining); + } + return operations; + } + + /** + * Builds the body for a PUT: the identity and the scope are taken from the restriction known to the API-Manager, + * only the configuration comes from the desired state. + */ + private static QuotaRestriction merge(QuotaRestriction actual, QuotaRestriction desired) { + QuotaRestriction merged = new QuotaRestriction(); + merged.setId(actual.getId()); + merged.setApiId(normalize(actual.getApiId())); + merged.setMethod(normalize(actual.getMethod())); + merged.setRestrictedAPI(actual.getRestrictedAPI()); + merged.setType(desired.getType()); + merged.setConfig(desired.getConfig()); + return merged; + } + + /** + * Compares only the configuration keys this CLI actually manages, which is the exact set written by + * APIQuotaManager.mergeRestriction and built by QuotaRestrictionDeserializer. Comparing the complete map would + * mean that a configuration key added by a future API-Manager causes a pointless update on every single run. + */ + static boolean configEquals(QuotaRestriction actual, QuotaRestriction desired) { + Map actualConfig = actual.getConfig(); + Map desiredConfig = desired.getConfig(); + if (actualConfig == null || desiredConfig == null) return actualConfig == desiredConfig; + if (!valueEquals(actualConfig.get(PERIOD), desiredConfig.get(PERIOD))) return false; + if (!valueEquals(actualConfig.get(PER), desiredConfig.get(PER))) return false; + if (desired.getType() == QuotaRestrictionType.throttlemb) { + return valueEquals(actualConfig.get(MB), desiredConfig.get(MB)); + } + return valueEquals(actualConfig.get(MESSAGES), desiredConfig.get(MESSAGES)); + } + + /** + * The API-Manager returns the numbers as strings, while a config file may provide them as numbers. + */ + private static boolean valueEquals(String actual, String desired) { + return Objects.equals(actual == null ? null : actual.trim(), desired == null ? null : desired.trim()); + } + + private static String normalize(String value) { + return value == null ? ALL : value; + } + + /** + * Identifies a restriction by its scope. + *

+ * api is part of the key because the whole quota document is compared, covering every API, unlike + * APIQuotaManager.isSameRestrictionScope which only works on a list already narrowed to a single API. + * type is part of the key because a single API-Method may carry a throttle and a throttlemb restriction at the + * same time. The consequence is that changing the type results in a delete plus a create. + */ + static class Key { + private final String api; + private final String method; + private final QuotaRestrictionType type; + + Key(QuotaRestriction restriction) { + this.api = normalize(restriction.getApiId()); + this.method = normalize(restriction.getMethod()); + this.type = restriction.getType(); + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + if (!(other instanceof Key)) return false; + Key key = (Key) other; + return Objects.equals(api, key.api) && Objects.equals(method, key.method) && type == key.type; + } + + @Override + public int hashCode() { + return Objects.hash(api, method, type); + } + + @Override + public String toString() { + return "[api=" + api + ", method=" + method + ", type=" + type + "]"; + } + } +} \ No newline at end of file diff --git a/modules/apim-adapter/src/main/java/com/axway/apim/adapter/client/apps/APIMgrAppsAdapter.java b/modules/apim-adapter/src/main/java/com/axway/apim/adapter/client/apps/APIMgrAppsAdapter.java index 8b5cee3a5..ef21922f3 100644 --- a/modules/apim-adapter/src/main/java/com/axway/apim/adapter/client/apps/APIMgrAppsAdapter.java +++ b/modules/apim-adapter/src/main/java/com/axway/apim/adapter/client/apps/APIMgrAppsAdapter.java @@ -18,13 +18,13 @@ import com.fasterxml.jackson.databind.ser.FilterProvider; import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter; import com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider; -import org.apache.http.HttpEntity; -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.client.utils.URIBuilder; -import org.apache.http.entity.ContentType; -import org.apache.http.entity.StringEntity; -import org.apache.http.entity.mime.MultipartEntityBuilder; -import org.apache.http.util.EntityUtils; +import org.apache.hc.core5.http.HttpEntity; +import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse; +import org.apache.hc.core5.net.URIBuilder; +import org.apache.hc.core5.http.ContentType; +import org.apache.hc.core5.http.io.entity.StringEntity; +import org.apache.hc.client5.http.entity.mime.MultipartEntityBuilder; +import org.apache.hc.core5.http.io.entity.EntityUtils; import org.ehcache.Cache; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -84,7 +84,7 @@ private void readApplicationsFromAPIManager(ClientAppFilter filter) throws AppEx LOG.debug("Sending request to find existing applications: {}", uri); RestAPICall getRequest = new GETRequest(uri); try (CloseableHttpResponse httpResponse = (CloseableHttpResponse) getRequest.execute()) { - int statusCode = httpResponse.getStatusLine().getStatusCode(); + int statusCode = httpResponse.getCode(); if (statusCode == 404) { // Nothing found - Simulate an empty response apiManagerResponse.put(filter, "[]"); @@ -172,7 +172,7 @@ private void readAppsSubscribedFromAPIManager(String apiId) throws AppException RestAPICall getRequest = new GETRequest(uri); LOG.debug("Load subscribed applications for API-ID: {} from API-Manager", apiId); try (CloseableHttpResponse httpResponse = (CloseableHttpResponse) getRequest.execute()) { - int statusCode = httpResponse.getStatusLine().getStatusCode(); + int statusCode = httpResponse.getCode(); String response = EntityUtils.toString(httpResponse.getEntity()); if (statusCode != 200) { LOG.error("Response from API Manager : {}", response); @@ -218,7 +218,7 @@ void addApplicationCredentials(ClientApplication app, boolean addCredentials) th RestAPICall getRequest = new GETRequest(uri); try (CloseableHttpResponse httpResponse = (CloseableHttpResponse) getRequest.execute()) { response = EntityUtils.toString(httpResponse.getEntity()); - int statusCode = httpResponse.getStatusLine().getStatusCode(); + int statusCode = httpResponse.getCode(); if (statusCode != 200) { LOG.error("Error reading application credentials. Response-Code: {} Got response: {}", statusCode, response); throw new AppException(ERROR_CREATING_APPLICATION_RESPONSE_CODE + statusCode, ErrorCode.API_MANAGER_COMMUNICATION); @@ -245,7 +245,7 @@ private void addOauthResources(ClientApplication app, boolean includeOauthResour RestAPICall getRequest = new GETRequest(uri); try (CloseableHttpResponse httpResponse = (CloseableHttpResponse) getRequest.execute()) { String response = EntityUtils.toString(httpResponse.getEntity()); - int statusCode = httpResponse.getStatusLine().getStatusCode(); + int statusCode = httpResponse.getCode(); if (statusCode != 200) { LOG.error("Error reading application oauth resources. Response-Code: {} Got response: {}", statusCode, response); throw new AppException("Error reading application oauth resources' Response-Code: " + statusCode, ErrorCode.API_MANAGER_COMMUNICATION); @@ -269,7 +269,7 @@ private void addApplicationPermissions(ClientApplication app, boolean includeApp RestAPICall getRequest = new GETRequest(uri); try (CloseableHttpResponse httpResponse = (CloseableHttpResponse) getRequest.execute()) { String response = EntityUtils.toString(httpResponse.getEntity()); - int statusCode = httpResponse.getStatusLine().getStatusCode(); + int statusCode = httpResponse.getCode(); if (statusCode != 200) { LOG.error("Error reading application permissions. Response-Code: {} Got response: {}", statusCode, response); throw new AppException("Error reading application permissions' Response-Code: " + statusCode, ErrorCode.API_MANAGER_COMMUNICATION); @@ -350,7 +350,7 @@ public ClientApplication upsertApplication(ClientApplication desiredApp, ClientA HttpEntity entity = new StringEntity(json, ContentType.APPLICATION_JSON); RestAPICall request = new POSTRequest(entity, uri); try (CloseableHttpResponse httpResponse = (CloseableHttpResponse) request.execute()) { - int statusCode = httpResponse.getStatusLine().getStatusCode(); + int statusCode = httpResponse.getCode(); if (statusCode < 200 || statusCode > 299) { LOG.error("Error creating application. Response-Code: {}", statusCode); throw new AppException("Error creating application. Response-Code: " + statusCode, ErrorCode.API_MANAGER_COMMUNICATION); @@ -385,7 +385,7 @@ public ClientApplication updateApplication(URI uri, ClientApplication clientAppl HttpEntity entity = new StringEntity(json, ContentType.APPLICATION_JSON); RestAPICall request = new PUTRequest(entity, uri); try (CloseableHttpResponse httpResponse = (CloseableHttpResponse) request.execute()) { - int statusCode = httpResponse.getStatusLine().getStatusCode(); + int statusCode = httpResponse.getCode(); if (statusCode < 200 || statusCode > 299) { LOG.error("Error updating application. Response-Code: {}", statusCode); throw new AppException("Error updating application. Response-Code: " + statusCode, ErrorCode.API_MANAGER_COMMUNICATION); @@ -403,7 +403,7 @@ private void saveImage(ClientApplication app, ClientApplication actualApp) throw .build(); RestAPICall apiCall = new POSTRequest(entity, uri); try (CloseableHttpResponse httpResponse = (CloseableHttpResponse) apiCall.execute()) { - int statusCode = httpResponse.getStatusLine().getStatusCode(); + int statusCode = httpResponse.getCode(); if (statusCode < 200 || statusCode > 299) { LOG.error("Error saving/updating application image. Response-Code: {}", statusCode); Utils.logPayload(LOG, httpResponse); @@ -511,7 +511,7 @@ private void deleteCredential(ClientApplication desiredApp, ClientAppCredential URI uri = new URIBuilder(cmd.getAPIManagerURL()).setPath(cmd.getApiBasepath() + APPLICATIONS + "/" + desiredApp.getId() + "/" + endpoint).build(); RestAPICall request = new DELRequest(uri); try (CloseableHttpResponse httpResponse = (CloseableHttpResponse) request.execute()) { - int statusCode = httpResponse.getStatusLine().getStatusCode(); + int statusCode = httpResponse.getCode(); if (statusCode != 204) { LOG.error("Error deleting application credential. Response-Code: {}", statusCode); Utils.logPayload(LOG, httpResponse); @@ -550,7 +550,7 @@ public void upsertCredential(ClientAppCredential cred, FilterProvider filter, St HttpEntity entity = new StringEntity(json, ContentType.APPLICATION_JSON); RestAPICall request = (update ? new PUTRequest(entity, uri) : new POSTRequest(entity, uri)); try (CloseableHttpResponse httpResponse = (CloseableHttpResponse) request.execute()) { - int statusCode = httpResponse.getStatusLine().getStatusCode(); + int statusCode = httpResponse.getCode(); if (statusCode < 200 || statusCode > 299) { LOG.error("Error saving/updating application credentials. Response-Code: {}", statusCode); Utils.logPayload(LOG, httpResponse); @@ -613,7 +613,7 @@ public void saveQuota(ClientApplication app, ClientApplication actualApp) throws // Use an admin account for this request RestAPICall request = createUpsertUri(entity, uri, actualApp); try (CloseableHttpResponse httpResponse = (CloseableHttpResponse) request.execute()) { - int statusCode = httpResponse.getStatusLine().getStatusCode(); + int statusCode = httpResponse.getCode(); if (statusCode < 200 || statusCode > 299) { LOG.error("Error creating/updating application quota. Response-Code: {}", statusCode); Utils.logPayload(LOG, httpResponse); @@ -670,7 +670,7 @@ private void saveOrUpdateOAuthResources(ClientApplication desiredApp, List 299) { LOG.error("Error saving/updating application oauth resource. Response-Code: {}", statusCode); Utils.logPayload(LOG, httpResponse); @@ -690,7 +690,7 @@ private void deleteOAuthResources(ClientApplication desiredApp, List 299) { LOG.error("Error saving/updating application permission. Response-Code: {}", statusCode); Utils.logPayload(LOG, httpResponse); @@ -840,7 +840,7 @@ private void deleteApplicationPermissions(ClientApplication desiredApp, List 299) { LOG.error("Error loading custom-properties from API-Manager. Response-Code: {} Response Body: {}", statusCode, response); throw new AppException("Error loading custom-properties from API-Manager. Response-Code: " + statusCode, ErrorCode.API_MANAGER_COMMUNICATION); diff --git a/modules/apim-adapter/src/main/java/com/axway/apim/adapter/jackson/APIImportSerializerModifier.java b/modules/apim-adapter/src/main/java/com/axway/apim/adapter/jackson/APIImportSerializerModifier.java index b58967f37..aa4948364 100644 --- a/modules/apim-adapter/src/main/java/com/axway/apim/adapter/jackson/APIImportSerializerModifier.java +++ b/modules/apim-adapter/src/main/java/com/axway/apim/adapter/jackson/APIImportSerializerModifier.java @@ -9,6 +9,7 @@ import com.fasterxml.jackson.databind.ser.BeanPropertyWriter; import com.fasterxml.jackson.databind.ser.BeanSerializerModifier; + public class APIImportSerializerModifier extends BeanSerializerModifier { @@ -19,10 +20,11 @@ public APIImportSerializerModifier() { @Override public List changeProperties(SerializationConfig config, BeanDescription beanDesc, List beanProperties) { - for(int i=0; i { @Override - public void serializeAsField(Object bean, - JsonGenerator gen, - SerializerProvider prov) throws Exception { - Object value = writer.get(bean); + public void serialize(Object value, JsonGenerator gen, SerializerProvider provider) throws IOException { if (value instanceof String) { - if(value.equals(Constants.API_DEPRECATED)) { - gen.writeStringField(writer.getName(), Constants.API_PUBLISHED); - } else { - gen.writeStringField(writer.getName(), (String)value); - } + String strValue = (String) value; + if (strValue.equals(Constants.API_DEPRECATED)) { + gen.writeString(Constants.API_PUBLISHED); + } else { + gen.writeString(strValue); + } } } } diff --git a/modules/apim-adapter/src/main/java/com/axway/apim/adapter/user/APIManagerUserAdapter.java b/modules/apim-adapter/src/main/java/com/axway/apim/adapter/user/APIManagerUserAdapter.java index 0a2a06d8f..bc16c59d5 100644 --- a/modules/apim-adapter/src/main/java/com/axway/apim/adapter/user/APIManagerUserAdapter.java +++ b/modules/apim-adapter/src/main/java/com/axway/apim/adapter/user/APIManagerUserAdapter.java @@ -15,14 +15,14 @@ import com.fasterxml.jackson.databind.ser.FilterProvider; import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter; import com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider; -import org.apache.http.HttpEntity; -import org.apache.http.HttpStatus; -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.client.utils.URIBuilder; -import org.apache.http.entity.ContentType; -import org.apache.http.entity.StringEntity; -import org.apache.http.entity.mime.MultipartEntityBuilder; -import org.apache.http.util.EntityUtils; +import org.apache.hc.core5.http.HttpEntity; +import org.apache.hc.core5.http.HttpStatus; +import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse; +import org.apache.hc.core5.net.URIBuilder; +import org.apache.hc.core5.http.ContentType; +import org.apache.hc.core5.http.io.entity.StringEntity; +import org.apache.hc.client5.http.entity.mime.MultipartEntityBuilder; +import org.apache.hc.core5.http.io.entity.EntityUtils; import org.ehcache.Cache; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -72,10 +72,10 @@ private void readUsersFromAPIManager(UserFilter filter) throws AppException { LOG.debug("Load users from API-Manager using filter: {}", filter); LOG.debug("Load users with URI: {}", uri); try (CloseableHttpResponse httpResponse = (CloseableHttpResponse) getRequest.execute()) { - if (httpResponse.getStatusLine().getStatusCode() == HttpStatus.SC_NOT_FOUND) { + if (httpResponse.getCode() == HttpStatus.SC_NOT_FOUND) { throw new AppException("No user found for user id: " + userId, ErrorCode.UNKNOWN_USER); - } else if (httpResponse.getStatusLine().getStatusCode() != HttpStatus.SC_OK) { - LOG.error("Received Status-Code: {}", httpResponse.getStatusLine().getStatusCode()); + } else if (httpResponse.getCode() != HttpStatus.SC_OK) { + LOG.error("Received Status-Code: {}", httpResponse.getCode()); Utils.logPayload(LOG, httpResponse); throw new AppException("", ErrorCode.API_MANAGER_COMMUNICATION); } @@ -204,7 +204,7 @@ public User upsertUser(URI uri, User desiredUser, User actualUser) throws AppExc } LOG.debug("Create/Update User Http Verb : {} URI : {}", request.getClass().getName(), uri); try (CloseableHttpResponse httpResponse = (CloseableHttpResponse) request.execute()) { - int statusCode = httpResponse.getStatusLine().getStatusCode(); + int statusCode = httpResponse.getCode(); if (statusCode < 200 || statusCode > 299) { LOG.error("Error creating/updating user. Response-Code: {}", statusCode); Utils.logPayload(LOG, httpResponse); @@ -228,7 +228,7 @@ public void changePassword(String newPassword, User actualUser) throws AppExcept HttpEntity entity = new StringEntity("newPassword=" + newPassword, ContentType.APPLICATION_FORM_URLENCODED); request = new POSTRequest(entity, uri); try (CloseableHttpResponse httpResponse = (CloseableHttpResponse) request.execute()) { - int statusCode = httpResponse.getStatusLine().getStatusCode(); + int statusCode = httpResponse.getCode(); if (statusCode != 204) { LOG.error("Error changing password of user. Response-Code: {}", statusCode); Utils.logPayload(LOG, httpResponse); @@ -245,7 +245,7 @@ public void deleteUser(User user) throws AppException { URI uri = new URIBuilder(cmd.getAPIManagerURL()).setPath(cmd.getApiBasepath() + USERS + user.getId()).build(); RestAPICall request = new DELRequest(uri); try (CloseableHttpResponse httpResponse = (CloseableHttpResponse) request.execute()) { - int statusCode = httpResponse.getStatusLine().getStatusCode(); + int statusCode = httpResponse.getCode(); if (statusCode != 204) { LOG.error("Error deleting user. Response-Code: {}", statusCode); Utils.logPayload(LOG, httpResponse); @@ -270,7 +270,7 @@ private void saveImage(User user, User actualUser) throws URISyntaxException, Ap try { RestAPICall apiCall = new POSTRequest(entity, uri); try (CloseableHttpResponse httpResponse = (CloseableHttpResponse) apiCall.execute()) { - int statusCode = httpResponse.getStatusLine().getStatusCode(); + int statusCode = httpResponse.getCode(); if (statusCode < 200 || statusCode > 299) { LOG.error("Error saving/updating user image. Response-Code: {}", statusCode); Utils.logPayload(LOG, httpResponse); diff --git a/modules/apim-adapter/src/main/java/com/axway/apim/adapter/user/UserFilter.java b/modules/apim-adapter/src/main/java/com/axway/apim/adapter/user/UserFilter.java index fb5634645..8066779ab 100644 --- a/modules/apim-adapter/src/main/java/com/axway/apim/adapter/user/UserFilter.java +++ b/modules/apim-adapter/src/main/java/com/axway/apim/adapter/user/UserFilter.java @@ -4,8 +4,8 @@ import com.axway.apim.api.model.User; import com.axway.apim.lib.CustomPropertiesFilter; import org.apache.commons.lang3.StringUtils; -import org.apache.http.NameValuePair; -import org.apache.http.message.BasicNameValuePair; +import org.apache.hc.core5.http.NameValuePair; +import org.apache.hc.core5.http.message.BasicNameValuePair; import java.util.ArrayList; import java.util.List; diff --git a/modules/apim-adapter/src/main/java/com/axway/apim/api/model/QuotaRestriction.java b/modules/apim-adapter/src/main/java/com/axway/apim/api/model/QuotaRestriction.java index e72b9a00c..e429c4d8a 100644 --- a/modules/apim-adapter/src/main/java/com/axway/apim/api/model/QuotaRestriction.java +++ b/modules/apim-adapter/src/main/java/com/axway/apim/api/model/QuotaRestriction.java @@ -9,9 +9,24 @@ import com.fasterxml.jackson.annotation.JsonAlias; import com.fasterxml.jackson.annotation.JsonFilter; import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; @JsonFilter("QuotaRestrictionFilter") +@JsonIgnoreProperties(ignoreUnknown = true) public class QuotaRestriction { + + /** + * The constraint ID assigned by the API-Manager. It is readOnly in the API-Manager REST-API: it is ignored on + * POST /quotas/{id}/constraints and taken from the URL on PUT, hence it must never be serialized. It must also + * not leak into exported API-/Application-Config files. + * Access.WRITE_ONLY removes the property from the BeanSerializer itself, which covers all serialization paths + * at once - including the ones that do NOT go through the QuotaRestrictionFilter (ExportHelper and + * JsonAPIManagerSetupExporter serialize this class with the default bean serializer). + */ + @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) + String id; + /** * Contains the ID of the API this restriction is applied to or a "*" if applied to all APIs. * The JsonAlias is required for Deserialization as the API-Manager returns the information in field api @@ -34,6 +49,14 @@ public class QuotaRestriction { Map config; + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + public String getApiId() { return apiId; } @@ -84,6 +107,12 @@ public void setConfig(Map config) { } + /** + * Note: id and apiId are deliberately NOT part of equals/hashCode. + * This equals is the desired-vs-actual change detector reached from APIQuota.equals via Utils.compareValues + * and finally APIChangeState. Desired restrictions are read from a config file and therefore never carry the + * API-Manager assigned id, so including it here would report every API as changed on every single run. + */ @Override public boolean equals(Object other) { if (other == null) return false; @@ -92,7 +121,7 @@ public boolean equals(Object other) { return StringUtils.equals(quotaRestriction.getMethod(), this.getMethod()) && quotaRestriction.getType() == this.getType() && - quotaRestriction.getConfig().equals(this.getConfig()); + Objects.equals(quotaRestriction.getConfig(), this.getConfig()); } else { return false; } @@ -105,6 +134,6 @@ public int hashCode() { @Override public String toString() { - return "QuotaRestriction [api=" + apiId + ", method=" + method + ", type=" + type + ", config=" + config + "]"; + return "QuotaRestriction [id=" + id + ", api=" + apiId + ", method=" + method + ", type=" + type + ", config=" + config + "]"; } } diff --git a/modules/apim-adapter/src/main/java/com/axway/apim/api/specification/APISpecificationFactory.java b/modules/apim-adapter/src/main/java/com/axway/apim/api/specification/APISpecificationFactory.java index b8084b652..c19276f9c 100644 --- a/modules/apim-adapter/src/main/java/com/axway/apim/api/specification/APISpecificationFactory.java +++ b/modules/apim-adapter/src/main/java/com/axway/apim/api/specification/APISpecificationFactory.java @@ -7,10 +7,10 @@ import com.axway.apim.lib.utils.URLParser; import com.axway.apim.lib.utils.Utils; import org.apache.commons.io.IOUtils; -import org.apache.http.client.config.RequestConfig; -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.util.EntityUtils; +import org.apache.hc.client5.http.config.RequestConfig; +import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse; +import org.apache.hc.client5.http.classic.methods.HttpGet; +import org.apache.hc.core5.http.io.entity.EntityUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -137,13 +137,12 @@ public static InputStream getAPIDefinitionFromURL(String urlToAPIDefinition) thr String password = url.getPassword(); try (HTTPClient httpClient = new HTTPClient(uri, username, password)) { RequestConfig config = RequestConfig.custom() - .setRelativeRedirectsAllowed(true) .setCircularRedirectsAllowed(true) .build(); HttpGet httpGet = new HttpGet(uri); httpGet.setConfig(config); try (CloseableHttpResponse httpResponse = httpClient.execute(httpGet)) { - int statusCode = httpResponse.getStatusLine().getStatusCode(); + int statusCode = httpResponse.getCode(); LOG.debug("{} {} : {} ", httpGet.getMethod(), uri, statusCode); String response = EntityUtils.toString(httpResponse.getEntity(), StandardCharsets.UTF_8); if (statusCode >= 200 && statusCode < 300) { diff --git a/modules/apim-adapter/src/main/java/com/axway/apim/api/specification/GraphqlIntrospectionHandler.java b/modules/apim-adapter/src/main/java/com/axway/apim/api/specification/GraphqlIntrospectionHandler.java index a5b9cbc83..e7f32473e 100644 --- a/modules/apim-adapter/src/main/java/com/axway/apim/api/specification/GraphqlIntrospectionHandler.java +++ b/modules/apim-adapter/src/main/java/com/axway/apim/api/specification/GraphqlIntrospectionHandler.java @@ -9,11 +9,11 @@ import graphql.introspection.IntrospectionResultToSchema; import graphql.language.Document; import graphql.schema.idl.SchemaPrinter; -import org.apache.http.HttpEntity; -import org.apache.http.client.config.RequestConfig; -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.entity.StringEntity; +import org.apache.hc.core5.http.HttpEntity; +import org.apache.hc.client5.http.config.RequestConfig; +import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse; +import org.apache.hc.client5.http.classic.methods.HttpPost; +import org.apache.hc.core5.http.io.entity.StringEntity; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -43,7 +43,7 @@ public InputStream readGraphqlSchema(HTTPClient httpClient, RequestConfig reques httpPost.setEntity(httpEntity); httpPost.setHeader("Content-Type", "application/json"); try (CloseableHttpResponse httpResponse = httpClient.execute(httpPost)) { - int statusCode = httpResponse.getStatusLine().getStatusCode(); + int statusCode = httpResponse.getCode(); LOG.debug("{} {} : {} ", httpPost.getMethod(), url, statusCode); if(statusCode == 200) { IntrospectionResultToSchema introspectionResultToSchema = new IntrospectionResultToSchema(); diff --git a/modules/apim-adapter/src/main/java/com/axway/apim/api/specification/ODataSpecification.java b/modules/apim-adapter/src/main/java/com/axway/apim/api/specification/ODataSpecification.java index 650956bcd..120f8f5ee 100644 --- a/modules/apim-adapter/src/main/java/com/axway/apim/api/specification/ODataSpecification.java +++ b/modules/apim-adapter/src/main/java/com/axway/apim/api/specification/ODataSpecification.java @@ -5,8 +5,8 @@ import com.axway.apim.lib.error.ErrorCode; import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; +import com.fasterxml.jackson.databind.json.JsonMapper; import com.fasterxml.jackson.databind.ser.FilterProvider; import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter; import com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider; @@ -59,12 +59,14 @@ public void configureBasePath(String backendBasePath, API api) throws AppExcepti @Override public byte[] getApiSpecificationContent() { - mapper = new ObjectMapper(); - mapper.configure(SerializationFeature.INDENT_OUTPUT, true); - mapper.setSerializationInclusion(Include.NON_NULL); FilterProvider filter = new SimpleFilterProvider().setDefaultFilter( SimpleBeanPropertyFilter.serializeAllExcept("exampleSetFlag")); - mapper.setFilterProvider(filter); + // Use builder to avoid deprecated mutating configure() method (removed in Jackson 2.19+) + mapper = JsonMapper.builder() + .enable(SerializationFeature.INDENT_OUTPUT) + .serializationInclusion(Include.NON_NULL) + .filterProvider(filter) + .build(); mapper.addMixIn(Object.class, OpenAPIMixIn.class); try { return mapper.writeValueAsBytes(openAPI); diff --git a/modules/apim-adapter/src/main/java/com/axway/apim/lib/CoreParameters.java b/modules/apim-adapter/src/main/java/com/axway/apim/lib/CoreParameters.java index 3bd61b1e3..c12d491bc 100644 --- a/modules/apim-adapter/src/main/java/com/axway/apim/lib/CoreParameters.java +++ b/modules/apim-adapter/src/main/java/com/axway/apim/lib/CoreParameters.java @@ -37,6 +37,28 @@ public static Mode valueOfDefault(String key) { } } + /** + * Controls how quota restrictions are written to the API-Manager. + * auto - use the /quotas/{id}/constraints endpoints when the API-Manager is new enough, otherwise + * replace the complete quota document. This is the default. + * legacy - always replace the complete quota document, as done before the constraints endpoints existed. + * constraints - always use the constraints endpoints, regardless of the reported API-Manager version. + */ + public enum QuotaUpdateMode { + auto, + legacy, + constraints; + + public static QuotaUpdateMode valueOfDefault(String key) { + for (QuotaUpdateMode e : values()) { + if (e.name().equals(key)) { + return e; + } + } + return QuotaUpdateMode.auto; + } + } + public static final String APIM_CLI_HOME = "AXWAY_APIM_CLI_HOME"; private static final String DEFAULT_API_BASEPATH = "/api/portal/v1.4"; private URI apiManagerUrl = null; @@ -59,6 +81,7 @@ public static Mode valueOfDefault(String key) { private boolean ignoreQuotas; private boolean zeroDowntimeUpdate; private Mode quotaMode; + private QuotaUpdateMode quotaUpdateMode; private Mode clientAppsMode; private Mode clientOrgsMode; private String detailsExportFile; @@ -205,6 +228,19 @@ public void setQuotaMode(Mode quotaMode) { this.quotaMode = quotaMode; } + public QuotaUpdateMode getQuotaUpdateMode() { + if (quotaUpdateMode != null) return quotaUpdateMode; + if (getFromProperties("quotaUpdateMode") != null) { + return QuotaUpdateMode.valueOfDefault(getFromProperties("quotaUpdateMode")); + } + return QuotaUpdateMode.auto; + } + + public void setQuotaUpdateMode(QuotaUpdateMode quotaUpdateMode) { + if (quotaUpdateMode == null) return; + this.quotaUpdateMode = quotaUpdateMode; + } + public boolean isIgnoreClientApps() { if (clientAppsMode == Mode.ignore) return true; if (getFromProperties(CLIENT_APPS_MODE) != null) { diff --git a/modules/apim-adapter/src/main/java/com/axway/apim/lib/utils/HTTPClient.java b/modules/apim-adapter/src/main/java/com/axway/apim/lib/utils/HTTPClient.java index 99220dfc7..920f855b5 100644 --- a/modules/apim-adapter/src/main/java/com/axway/apim/lib/utils/HTTPClient.java +++ b/modules/apim-adapter/src/main/java/com/axway/apim/lib/utils/HTTPClient.java @@ -2,20 +2,22 @@ import com.axway.apim.lib.error.AppException; import com.axway.apim.lib.error.ErrorCode; -import org.apache.http.HttpHost; -import org.apache.http.auth.AuthScope; -import org.apache.http.auth.UsernamePasswordCredentials; -import org.apache.http.client.AuthCache; -import org.apache.http.client.CredentialsProvider; -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.client.methods.HttpUriRequest; -import org.apache.http.client.protocol.HttpClientContext; -import org.apache.http.conn.ssl.NoopHostnameVerifier; -import org.apache.http.conn.ssl.SSLConnectionSocketFactory; -import org.apache.http.conn.ssl.TrustAllStrategy; -import org.apache.http.impl.auth.BasicScheme; -import org.apache.http.impl.client.*; -import org.apache.http.ssl.SSLContextBuilder; +import org.apache.hc.client5.http.auth.AuthCache; +import org.apache.hc.client5.http.auth.AuthScope; +import org.apache.hc.client5.http.auth.UsernamePasswordCredentials; +import org.apache.hc.client5.http.impl.auth.BasicAuthCache; +import org.apache.hc.client5.http.impl.auth.BasicCredentialsProvider; +import org.apache.hc.client5.http.impl.auth.BasicScheme; +import org.apache.hc.client5.http.impl.classic.CloseableHttpClient; +import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse; +import org.apache.hc.client5.http.impl.classic.HttpClients; +import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager; +import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManagerBuilder; +import org.apache.hc.client5.http.protocol.HttpClientContext; +import org.apache.hc.client5.http.ssl.*; +import org.apache.hc.core5.http.ClassicHttpRequest; +import org.apache.hc.core5.http.HttpHost; +import org.apache.hc.core5.ssl.SSLContextBuilder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -49,17 +51,22 @@ public void getClient() throws AppException { try { SSLContextBuilder builder = SSLContextBuilder.create(); builder.loadTrustMaterial(null, new TrustAllStrategy()); - SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(builder.build(), new NoopHostnameVerifier()); - HttpClientBuilder httpClientBuilder = HttpClients.custom() - .setSSLSocketFactory(sslsf); + TlsSocketStrategy tlsSocketStrategy = new DefaultClientTlsStrategy(builder.build(), HostnameVerificationPolicy.CLIENT, NoopHostnameVerifier.INSTANCE); + PoolingHttpClientConnectionManager connectionManager = PoolingHttpClientConnectionManagerBuilder.create() + .setTlsSocketStrategy(tlsSocketStrategy) + .build(); + var httpClientBuilder = HttpClients.custom() + .setConnectionManager(connectionManager); if (this.username != null) { - CredentialsProvider credsProvider = new BasicCredentialsProvider(); - credsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(username, password)); + BasicCredentialsProvider credsProvider = new BasicCredentialsProvider(); + credsProvider.setCredentials(new AuthScope(null, -1), + new UsernamePasswordCredentials(username, password != null ? password.toCharArray() : new char[0])); AuthCache authCache = new BasicAuthCache(); BasicScheme basicAuth = new BasicScheme(); - authCache.put(new HttpHost(url.getHost(), url.getPort(), url.getScheme()), basicAuth); + authCache.put(new HttpHost(url.getScheme(), url.getHost(), url.getPort()), basicAuth); clientContext = HttpClientContext.create(); clientContext.setAuthCache(authCache); + clientContext.setCredentialsProvider(credsProvider); httpClientBuilder.setDefaultCredentialsProvider(credsProvider); } this.closeableHttpClient = httpClientBuilder.build(); @@ -68,8 +75,8 @@ public void getClient() throws AppException { } } - public CloseableHttpResponse execute(HttpUriRequest request) throws IOException { - return closeableHttpClient.execute(request, clientContext); + public CloseableHttpResponse execute(ClassicHttpRequest request) throws IOException { + return (CloseableHttpResponse) closeableHttpClient.executeOpen(null, request, clientContext); } @Override diff --git a/modules/apim-adapter/src/main/java/com/axway/apim/lib/utils/Utils.java b/modules/apim-adapter/src/main/java/com/axway/apim/lib/utils/Utils.java index 7c3fc27f3..ad89bbb93 100644 --- a/modules/apim-adapter/src/main/java/com/axway/apim/lib/utils/Utils.java +++ b/modules/apim-adapter/src/main/java/com/axway/apim/lib/utils/Utils.java @@ -21,8 +21,8 @@ import org.apache.commons.io.FileUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.text.StringSubstitutor; -import org.apache.http.HttpResponse; -import org.apache.http.util.EntityUtils; +import org.apache.hc.core5.http.ClassicHttpResponse; +import org.apache.hc.core5.http.io.entity.EntityUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -419,7 +419,7 @@ public static int handleAppException(Exception e, Logger logger, ErrorCodeMapper } } - public static void logPayload(Logger logger, HttpResponse httpResponse) throws IOException { + public static void logPayload(Logger logger, ClassicHttpResponse httpResponse) throws IOException, org.apache.hc.core5.http.ParseException { if (logger.isDebugEnabled()) { logger.debug("APIManager Response : {}", EntityUtils.toString(httpResponse.getEntity())); } diff --git a/modules/apim-adapter/src/main/java/com/axway/apim/lib/utils/rest/APIMHttpClient.java b/modules/apim-adapter/src/main/java/com/axway/apim/lib/utils/rest/APIMHttpClient.java index 9037b6470..d53c542a0 100644 --- a/modules/apim-adapter/src/main/java/com/axway/apim/lib/utils/rest/APIMHttpClient.java +++ b/modules/apim-adapter/src/main/java/com/axway/apim/lib/utils/rest/APIMHttpClient.java @@ -3,31 +3,31 @@ import com.axway.apim.lib.CoreParameters; import com.axway.apim.lib.error.AppException; import com.axway.apim.lib.error.ErrorCode; -import org.apache.http.Header; -import org.apache.http.HttpHost; -import org.apache.http.auth.AuthScope; -import org.apache.http.auth.UsernamePasswordCredentials; -import org.apache.http.client.CredentialsProvider; -import org.apache.http.client.HttpClient; -import org.apache.http.client.config.CookieSpecs; -import org.apache.http.client.config.RequestConfig; -import org.apache.http.client.protocol.HttpClientContext; -import org.apache.http.config.Registry; -import org.apache.http.config.RegistryBuilder; -import org.apache.http.conn.routing.HttpRoute; -import org.apache.http.conn.routing.HttpRoutePlanner; -import org.apache.http.conn.socket.ConnectionSocketFactory; -import org.apache.http.conn.socket.PlainConnectionSocketFactory; -import org.apache.http.conn.ssl.NoopHostnameVerifier; -import org.apache.http.conn.ssl.SSLConnectionSocketFactory; -import org.apache.http.conn.ssl.TrustAllStrategy; -import org.apache.http.impl.client.BasicCookieStore; -import org.apache.http.impl.client.BasicCredentialsProvider; -import org.apache.http.impl.client.HttpClientBuilder; -import org.apache.http.impl.conn.DefaultProxyRoutePlanner; -import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; -import org.apache.http.message.BasicHeader; -import org.apache.http.ssl.SSLContextBuilder; +import org.apache.hc.client5.http.HttpRoute; +import org.apache.hc.client5.http.auth.AuthScope; +import org.apache.hc.client5.http.auth.UsernamePasswordCredentials; +import org.apache.hc.client5.http.config.ConnectionConfig; +import org.apache.hc.client5.http.config.RequestConfig; +import org.apache.hc.client5.http.cookie.BasicCookieStore; +import org.apache.hc.client5.http.cookie.StandardCookieSpec; +import org.apache.hc.client5.http.impl.auth.BasicCredentialsProvider; +import org.apache.hc.client5.http.impl.classic.CloseableHttpClient; +import org.apache.hc.client5.http.impl.classic.HttpClientBuilder; +import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager; +import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManagerBuilder; +import org.apache.hc.client5.http.impl.routing.DefaultProxyRoutePlanner; +import org.apache.hc.client5.http.protocol.HttpClientContext; +import org.apache.hc.client5.http.routing.HttpRoutePlanner; +import org.apache.hc.client5.http.ssl.DefaultClientTlsStrategy; +import org.apache.hc.client5.http.ssl.HostnameVerificationPolicy; +import org.apache.hc.client5.http.ssl.NoopHostnameVerifier; +import org.apache.hc.client5.http.ssl.TlsSocketStrategy; +import org.apache.hc.client5.http.ssl.TrustAllStrategy; +import org.apache.hc.core5.http.Header; +import org.apache.hc.core5.http.HttpHost; +import org.apache.hc.core5.http.message.BasicHeader; +import org.apache.hc.core5.ssl.SSLContextBuilder; +import org.apache.hc.core5.util.Timeout; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -46,7 +46,7 @@ public class APIMHttpClient { private static final Logger LOG = LoggerFactory.getLogger(APIMHttpClient.class); - private HttpClient httpClient; + private CloseableHttpClient httpClient; private PoolingHttpClientConnectionManager httpClientConnectionManager; private HttpClientContext clientContext; private final BasicCookieStore cookieStore = new BasicCookieStore(); @@ -73,30 +73,31 @@ private void createConnection(URI uri) throws AppException { HttpHost targetHost; SSLContextBuilder builder = new SSLContextBuilder(); try { + CoreParameters params = CoreParameters.getInstance(); + int timeout = params.getTimeout(); + LOG.debug("API Manager CLI http client timeout : {}", timeout); + builder.loadTrustMaterial(null, new TrustAllStrategy()); - SSLConnectionSocketFactory sslConnectionSocketFactory = new SSLConnectionSocketFactory(builder.build(), new NoopHostnameVerifier()); - Registry r = RegistryBuilder.create() - .register(uri.getScheme(), sslConnectionSocketFactory) - .register("http", PlainConnectionSocketFactory.INSTANCE) + TlsSocketStrategy tlsSocketStrategy = new DefaultClientTlsStrategy(builder.build(), HostnameVerificationPolicy.CLIENT, NoopHostnameVerifier.INSTANCE); + + httpClientConnectionManager = PoolingHttpClientConnectionManagerBuilder.create() + .setTlsSocketStrategy(tlsSocketStrategy) + .setMaxConnTotal(5) + .setMaxConnPerRoute(2) + .setDefaultConnectionConfig(ConnectionConfig.custom() + .setConnectTimeout(Timeout.ofMilliseconds(timeout)) + .build()) .build(); - - httpClientConnectionManager = new PoolingHttpClientConnectionManager(r); - httpClientConnectionManager.setMaxTotal(5); - httpClientConnectionManager.setDefaultMaxPerRoute(2); - targetHost = new HttpHost(uri.getHost(), uri.getPort(), uri.getScheme()); + targetHost = new HttpHost(uri.getScheme(), uri.getHost(), uri.getPort()); // Add AuthCache to the execution context clientContext = HttpClientContext.create(); clientContext.setCookieStore(cookieStore); httpClientConnectionManager.setMaxPerRoute(new HttpRoute(targetHost), 2); // We have make sure, that cookies are correctly parsed! - CoreParameters params = CoreParameters.getInstance(); - int timeout = params.getTimeout(); - LOG.debug("API Manager CLI http client timeout : {}", timeout); RequestConfig.Builder defaultRequestConfig = RequestConfig.custom() - .setConnectTimeout(timeout) - .setSocketTimeout(timeout) - .setConnectionRequestTimeout(timeout) - .setCookieSpec(CookieSpecs.STANDARD); + .setResponseTimeout(Timeout.ofMilliseconds(timeout)) + .setConnectionRequestTimeout(Timeout.ofMilliseconds(timeout)) + .setCookieSpec(StandardCookieSpec.RELAXED); HttpClientBuilder clientBuilder = HttpClientBuilder.create() .disableRedirectHandling() .setConnectionManager(httpClientConnectionManager) @@ -110,8 +111,10 @@ private void createConnection(URI uri) throws AppException { clientBuilder.setRoutePlanner(routePlanner); if (params.getProxyUsername() != null) { LOG.debug("API Manager CLI using Http(s) proxy Authentication"); - CredentialsProvider credentialsProvider = new BasicCredentialsProvider(); - credentialsProvider.setCredentials(new AuthScope(params.getProxyHost(), params.getProxyPort()), new UsernamePasswordCredentials(params.getProxyUsername(), params.getProxyPassword())); + BasicCredentialsProvider credentialsProvider = new BasicCredentialsProvider(); + credentialsProvider.setCredentials( + new AuthScope(params.getProxyHost(), params.getProxyPort()), + new UsernamePasswordCredentials(params.getProxyUsername(), params.getProxyPassword().toCharArray())); clientBuilder.setDefaultCredentialsProvider(credentialsProvider); } defaultRequestConfig.setProxy(proxyHost); @@ -145,7 +148,7 @@ public List

splitStringToHttpHeaders(String input) { return headers; } - public HttpClient getHttpClient() { + public CloseableHttpClient getHttpClient() { return httpClient; } diff --git a/modules/apim-adapter/src/main/java/com/axway/apim/lib/utils/rest/DELRequest.java b/modules/apim-adapter/src/main/java/com/axway/apim/lib/utils/rest/DELRequest.java index 2aa77fa3f..7a4af418b 100644 --- a/modules/apim-adapter/src/main/java/com/axway/apim/lib/utils/rest/DELRequest.java +++ b/modules/apim-adapter/src/main/java/com/axway/apim/lib/utils/rest/DELRequest.java @@ -1,8 +1,8 @@ package com.axway.apim.lib.utils.rest; import com.axway.apim.lib.error.AppException; -import org.apache.http.HttpResponse; -import org.apache.http.client.methods.HttpDelete; +import org.apache.hc.core5.http.HttpResponse; +import org.apache.hc.client5.http.classic.methods.HttpDelete; import java.net.URI; diff --git a/modules/apim-adapter/src/main/java/com/axway/apim/lib/utils/rest/GETRequest.java b/modules/apim-adapter/src/main/java/com/axway/apim/lib/utils/rest/GETRequest.java index a6d8702f7..9450b62cd 100644 --- a/modules/apim-adapter/src/main/java/com/axway/apim/lib/utils/rest/GETRequest.java +++ b/modules/apim-adapter/src/main/java/com/axway/apim/lib/utils/rest/GETRequest.java @@ -2,8 +2,8 @@ import java.net.URI; -import org.apache.http.HttpResponse; -import org.apache.http.client.methods.HttpGet; +import org.apache.hc.core5.http.HttpResponse; +import org.apache.hc.client5.http.classic.methods.HttpGet; import com.axway.apim.lib.error.AppException; diff --git a/modules/apim-adapter/src/main/java/com/axway/apim/lib/utils/rest/POSTRequest.java b/modules/apim-adapter/src/main/java/com/axway/apim/lib/utils/rest/POSTRequest.java index 7a5c7faae..0fa143954 100644 --- a/modules/apim-adapter/src/main/java/com/axway/apim/lib/utils/rest/POSTRequest.java +++ b/modules/apim-adapter/src/main/java/com/axway/apim/lib/utils/rest/POSTRequest.java @@ -2,9 +2,9 @@ import java.net.URI; -import org.apache.http.HttpEntity; -import org.apache.http.HttpResponse; -import org.apache.http.client.methods.HttpPost; +import org.apache.hc.core5.http.HttpEntity; +import org.apache.hc.core5.http.HttpResponse; +import org.apache.hc.client5.http.classic.methods.HttpPost; import com.axway.apim.lib.error.AppException; diff --git a/modules/apim-adapter/src/main/java/com/axway/apim/lib/utils/rest/PUTRequest.java b/modules/apim-adapter/src/main/java/com/axway/apim/lib/utils/rest/PUTRequest.java index 4db89c7f1..dc07836a7 100644 --- a/modules/apim-adapter/src/main/java/com/axway/apim/lib/utils/rest/PUTRequest.java +++ b/modules/apim-adapter/src/main/java/com/axway/apim/lib/utils/rest/PUTRequest.java @@ -2,9 +2,9 @@ import java.net.URI; -import org.apache.http.HttpEntity; -import org.apache.http.HttpResponse; -import org.apache.http.client.methods.HttpPut; +import org.apache.hc.core5.http.HttpEntity; +import org.apache.hc.core5.http.HttpResponse; +import org.apache.hc.client5.http.classic.methods.HttpPut; import com.axway.apim.lib.error.AppException; diff --git a/modules/apim-adapter/src/main/java/com/axway/apim/lib/utils/rest/RestAPICall.java b/modules/apim-adapter/src/main/java/com/axway/apim/lib/utils/rest/RestAPICall.java index 0b5b10c19..7bd30b6b8 100644 --- a/modules/apim-adapter/src/main/java/com/axway/apim/lib/utils/rest/RestAPICall.java +++ b/modules/apim-adapter/src/main/java/com/axway/apim/lib/utils/rest/RestAPICall.java @@ -2,11 +2,11 @@ import com.axway.apim.lib.error.AppException; import com.axway.apim.lib.error.ErrorCode; -import org.apache.http.HttpEntity; -import org.apache.http.HttpHost; -import org.apache.http.HttpResponse; -import org.apache.http.NoHttpResponseException; -import org.apache.http.client.methods.HttpUriRequest; +import org.apache.hc.core5.http.ClassicHttpRequest; +import org.apache.hc.core5.http.HttpEntity; +import org.apache.hc.core5.http.HttpHost; +import org.apache.hc.core5.http.HttpResponse; +import org.apache.hc.core5.http.NoHttpResponseException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -38,12 +38,12 @@ protected RestAPICall(HttpEntity entity, URI uri) { public abstract HttpResponse execute() throws AppException; - protected HttpResponse sendRequest(HttpUriRequest request) throws AppException { + protected HttpResponse sendRequest(ClassicHttpRequest request) throws AppException { try { APIMHttpClient apimClient = APIMHttpClient.getInstance(); - LOG.debug("Http verb:{} and URI: {}", request.getMethod(), request.getURI()); + LOG.debug("Http verb:{} and URI: {}", request.getMethod(), request.getRequestUri()); if (apimClient.getCsrfToken() != null) request.addHeader("CSRF-Token", apimClient.getCsrfToken()); - return apimClient.getHttpClient().execute(request, apimClient.getClientContext()); + return apimClient.getHttpClient().executeOpen(null, request, apimClient.getClientContext()); } catch (NoHttpResponseException e) { throw new AppException("No response received for request: " + request + " from API-Manager within time limit. " + "Perhaps the API-Manager is overloaded or contains too many entities to process the request.", ErrorCode.UNXPECTED_ERROR, e); diff --git a/modules/apim-adapter/src/test/java/com/axway/apim/adapter/apis/APIManagerQuotaConstraintsTest.java b/modules/apim-adapter/src/test/java/com/axway/apim/adapter/apis/APIManagerQuotaConstraintsTest.java new file mode 100644 index 000000000..65a8ce1c6 --- /dev/null +++ b/modules/apim-adapter/src/test/java/com/axway/apim/adapter/apis/APIManagerQuotaConstraintsTest.java @@ -0,0 +1,230 @@ +package com.axway.apim.adapter.apis; + +import com.axway.apim.WiremockWrapper; +import com.axway.apim.adapter.APIManagerAdapter; +import com.axway.apim.api.model.APIQuota; +import com.axway.apim.api.model.QuotaRestriction; +import com.axway.apim.api.model.QuotaRestrictionType; +import com.axway.apim.lib.CoreParameters; +import com.axway.apim.lib.CoreParameters.QuotaUpdateMode; +import com.axway.apim.lib.error.AppException; +import com.axway.apim.lib.utils.Utils; +import org.testng.Assert; +import org.testng.annotations.AfterClass; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +import static com.github.tomakehurst.wiremock.client.WireMock.deleteRequestedFor; +import static com.github.tomakehurst.wiremock.client.WireMock.postRequestedFor; +import static com.github.tomakehurst.wiremock.client.WireMock.putRequestedFor; +import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; +import static com.github.tomakehurst.wiremock.client.WireMock.urlPathMatching; + +/** + * Covers the migration of the quota write path to the /quotas/{id}/constraints endpoints. + * The API-Manager version is forced per test rather than changed in the Wiremock config.json fixture, so that both + * the legacy and the constraints path stay covered. + */ +public class APIManagerQuotaConstraintsTest extends WiremockWrapper { + + private static final String SYSTEM_QUOTA_ID = APIManagerQuotaAdapter.Quota.SYSTEM_DEFAULT.getQuotaId(); + private static final String SYSTEM_QUOTA_URL = "/api/portal/v1.4/quotas/" + SYSTEM_QUOTA_ID; + private static final String CONSTRAINTS_URL_PATTERN = "/api/portal/v1\\.4/quotas/[0-9a-f-]+/constraints/[0-9a-f-]+"; + private static final String API_WEEK = "9170e76e-ee7a-45ae-8afe-32a32a5da65c"; + private static final String API_SECOND = "e4ded8c8-0a40-4b50-bc13-552fb7209150"; + + private String originalVersion; + + @BeforeClass + public void initWiremock() { + super.initWiremock(); + try { + CoreParameters coreParameters = new CoreParameters(); + coreParameters.setHostname("localhost"); + coreParameters.setUsername("test"); + coreParameters.setPassword(Utils.getEncryptedPassword()); + originalVersion = APIManagerAdapter.getInstance().getApiManagerVersion(); + } catch (AppException e) { + throw new RuntimeException(e); + } + } + + @AfterClass + public void close() { + super.close(); + } + + @BeforeMethod + public void resetRequests() { + getWireMockServer().resetRequests(); + } + + @AfterMethod + public void restoreVersion() throws AppException { + APIManagerAdapter.getInstance().setApiManagerVersion(originalVersion); + CoreParameters.getInstance().setQuotaUpdateMode(QuotaUpdateMode.auto); + } + + /** + * A fresh adapter per test, as it memoises the capability check and the constraints it has read. + */ + private APIManagerQuotaAdapter newAdapter() throws AppException { + return new APIManagerQuotaAdapter(APIManagerAdapter.getInstance()); + } + + private static QuotaRestriction throttle(String apiId, String method, String messages, String period, String per) { + QuotaRestriction restriction = new QuotaRestriction(); + restriction.setApiId(apiId); + restriction.setMethod(method); + restriction.setType(QuotaRestrictionType.throttle); + Map config = new LinkedHashMap<>(); + config.put("period", period); + config.put("per", per); + config.put("messages", messages); + restriction.setConfig(config); + return restriction; + } + + private static APIQuota quotaWith(List restrictions) { + APIQuota quota = new APIQuota(); + quota.setId(SYSTEM_QUOTA_ID); + quota.setName("System"); + quota.setType("API"); + quota.setRestrictions(new ArrayList<>(restrictions)); + return quota; + } + + /** + * The three restrictions served by the constraints stub, expressed as a desired state. + */ + private static List unchangedDesiredState() { + return Arrays.asList( + throttle(API_WEEK, "*", "1000", "week", "2"), + throttle(API_SECOND, "*", "1000", "second", "2"), + throttle("*", "*", "10000", "second", "1")); + } + + @Test + public void getConstraintsPopulatesTheServerAssignedId() throws Exception { + List constraints = newAdapter().getConstraints(SYSTEM_QUOTA_ID); + Assert.assertEquals(constraints.size(), 3); + Assert.assertEquals(constraints.get(0).getId(), "c0000000-0000-0000-0000-000000000001"); + Assert.assertEquals(constraints.get(2).getId(), "c0000000-0000-0000-0000-000000000003"); + Assert.assertEquals(constraints.get(2).getApiId(), "*"); + } + + @Test + public void createConstraintReturnsTheServerAssignedId() throws Exception { + QuotaRestriction created = newAdapter().createConstraint(SYSTEM_QUOTA_ID, throttle("*", "*", "10000", "second", "1")); + Assert.assertNotNull(created); + Assert.assertEquals(created.getId(), "c0000000-0000-0000-0000-0000000000ff"); + getWireMockServer().verify(1, postRequestedFor(urlEqualTo(SYSTEM_QUOTA_URL + "/constraints"))); + } + + @Test + public void deleteConstraintAddressesTheConstraintById() throws Exception { + newAdapter().deleteConstraint(SYSTEM_QUOTA_ID, "c0000000-0000-0000-0000-000000000002"); + getWireMockServer().verify(1, deleteRequestedFor( + urlEqualTo(SYSTEM_QUOTA_URL + "/constraints/c0000000-0000-0000-0000-000000000002"))); + } + + /** + * The constraint id must never be sent in the body: it is ignored on create and taken from the URL on update. + */ + @Test + public void constraintIdIsNeverSerializedIntoTheBody() throws Exception { + QuotaRestriction restriction = throttle("*", "*", "10000", "second", "1"); + restriction.setId("c0000000-0000-0000-0000-000000000003"); + newAdapter().updateConstraint(SYSTEM_QUOTA_ID, restriction); + String body = getWireMockServer().findAll(putRequestedFor(urlPathMatching(CONSTRAINTS_URL_PATTERN))) + .get(0).getBodyAsString(); + Assert.assertFalse(body.contains("\"id\""), "The constraint ID must not be part of the request body: " + body); + Assert.assertTrue(body.contains("\"api\""), "The api field is expected in the request body: " + body); + } + + /** + * The whole point of the migration: a changed restriction must not rewrite the complete quota document. + */ + @Test + public void saveQuotaUsesConstraintsAndNeverReplacesTheWholeDocument() throws Exception { + APIManagerAdapter.getInstance().setApiManagerVersion(APIManagerQuotaAdapter.QUOTA_CONSTRAINTS_MIN_VERSION); + // Drop the second restriction and raise the message rate of the third one. + List desired = Arrays.asList( + throttle(API_WEEK, "*", "1000", "week", "2"), + throttle("*", "*", "20000", "second", "1")); + + newAdapter().saveQuota(quotaWith(desired), SYSTEM_QUOTA_ID); + + getWireMockServer().verify(0, putRequestedFor(urlEqualTo(SYSTEM_QUOTA_URL))); + getWireMockServer().verify(1, deleteRequestedFor( + urlEqualTo(SYSTEM_QUOTA_URL + "/constraints/c0000000-0000-0000-0000-000000000002"))); + getWireMockServer().verify(1, putRequestedFor( + urlEqualTo(SYSTEM_QUOTA_URL + "/constraints/c0000000-0000-0000-0000-000000000003"))); + getWireMockServer().verify(0, postRequestedFor(urlEqualTo(SYSTEM_QUOTA_URL + "/constraints"))); + } + + /** + * Restrictions that did not change must not cause a single write. + */ + @Test + public void saveQuotaIssuesNoWriteWhenNothingChanged() throws Exception { + APIManagerAdapter.getInstance().setApiManagerVersion(APIManagerQuotaAdapter.QUOTA_CONSTRAINTS_MIN_VERSION); + newAdapter().saveQuota(quotaWith(unchangedDesiredState()), SYSTEM_QUOTA_ID); + getWireMockServer().verify(0, putRequestedFor(urlEqualTo(SYSTEM_QUOTA_URL))); + getWireMockServer().verify(0, putRequestedFor(urlPathMatching(CONSTRAINTS_URL_PATTERN))); + getWireMockServer().verify(0, deleteRequestedFor(urlPathMatching(CONSTRAINTS_URL_PATTERN))); + getWireMockServer().verify(0, postRequestedFor(urlEqualTo(SYSTEM_QUOTA_URL + "/constraints"))); + } + + /** + * An API-Manager older than the constraints endpoints must keep replacing the complete quota document. + */ + @Test + public void olderApiManagerKeepsUsingTheDocumentLevelUpdate() throws Exception { + APIManagerAdapter.getInstance().setApiManagerVersion("7.7.20221130"); + newAdapter().saveQuota(quotaWith(unchangedDesiredState()), SYSTEM_QUOTA_ID); + getWireMockServer().verify(1, putRequestedFor(urlEqualTo(SYSTEM_QUOTA_URL))); + getWireMockServer().verify(0, putRequestedFor(urlPathMatching(CONSTRAINTS_URL_PATTERN))); + } + + /** + * The escape hatch must win over the version check. + */ + @Test + public void quotaUpdateModeLegacyForcesTheDocumentLevelUpdate() throws Exception { + APIManagerAdapter.getInstance().setApiManagerVersion(APIManagerQuotaAdapter.QUOTA_CONSTRAINTS_MIN_VERSION); + CoreParameters.getInstance().setQuotaUpdateMode(QuotaUpdateMode.legacy); + newAdapter().saveQuota(quotaWith(unchangedDesiredState()), SYSTEM_QUOTA_ID); + getWireMockServer().verify(1, putRequestedFor(urlEqualTo(SYSTEM_QUOTA_URL))); + getWireMockServer().verify(0, putRequestedFor(urlPathMatching(CONSTRAINTS_URL_PATTERN))); + } + + /** + * Application specific quotas are served by /applications/{id}/quota, which has no per-constraint sub resource, + * so they must stay on the document level update even on a new API-Manager. + */ + @Test + public void applicationSpecificQuotaIsNotMigrated() throws Exception { + APIManagerAdapter.getInstance().setApiManagerVersion(APIManagerQuotaAdapter.QUOTA_CONSTRAINTS_MIN_VERSION); + String appQuotaId = "54c4358c-2036-4082-a0b6-7eb44b6dd60d"; + APIQuota quota = quotaWith(unchangedDesiredState()); + quota.setId(appQuotaId); + try { + newAdapter().saveQuota(quota, appQuotaId); + } catch (AppException e) { + // There is no stub for this quota ID, the point of the test is which URL was called. + } + getWireMockServer().verify(0, postRequestedFor(urlPathMatching("/api/portal/v1\\.4/quotas/[0-9a-f-]+/constraints"))); + getWireMockServer().verify(0, putRequestedFor(urlPathMatching(CONSTRAINTS_URL_PATTERN))); + // It must have gone down the document level path instead. + getWireMockServer().verify(1, putRequestedFor(urlEqualTo("/api/portal/v1.4/quotas/" + appQuotaId))); + } +} diff --git a/modules/apim-adapter/src/test/java/com/axway/apim/adapter/apis/APIManagerVersionGatingTest.java b/modules/apim-adapter/src/test/java/com/axway/apim/adapter/apis/APIManagerVersionGatingTest.java new file mode 100644 index 000000000..e658df473 --- /dev/null +++ b/modules/apim-adapter/src/test/java/com/axway/apim/adapter/apis/APIManagerVersionGatingTest.java @@ -0,0 +1,90 @@ +package com.axway.apim.adapter.apis; + +import com.axway.apim.WiremockWrapper; +import com.axway.apim.adapter.APIManagerAdapter; +import com.axway.apim.lib.CoreParameters; +import com.axway.apim.lib.error.AppException; +import com.axway.apim.lib.utils.Utils; +import org.testng.Assert; +import org.testng.annotations.AfterClass; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import java.util.Arrays; +import java.util.List; + +/** + * queryStringPassThrough only exists in the inboundProfiles from API-Manager 7.7.20220530 onwards, so it has to be + * excluded from the proxy update on older versions. The check must cope with every version string the API-Manager + * reports, in particular the dated builds carrying a service pack suffix. + */ +public class APIManagerVersionGatingTest extends WiremockWrapper { + + private static final String QUERY_STRING_PASS_THROUGH = "queryStringPassThrough"; + + private APIManagerAPIAdapter apiAdapter; + private String originalVersion; + + @BeforeClass + public void initWiremock() { + super.initWiremock(); + try { + CoreParameters coreParameters = new CoreParameters(); + coreParameters.setHostname("localhost"); + coreParameters.setUsername("test"); + coreParameters.setPassword(Utils.getEncryptedPassword()); + apiAdapter = APIManagerAdapter.getInstance().getApiAdapter(); + originalVersion = APIManagerAdapter.getInstance().getApiManagerVersion(); + } catch (AppException e) { + throw new RuntimeException(e); + } + } + + @AfterClass + public void close() { + super.close(); + } + + @AfterMethod + public void restoreVersion() throws AppException { + APIManagerAdapter.getInstance().setApiManagerVersion(originalVersion); + } + + private boolean queryStringPassThroughIsSent(String version) throws AppException { + APIManagerAdapter.getInstance().setApiManagerVersion(version); + List excluded = Arrays.asList(apiAdapter.getSerializeAllExcept()); + // When the field is NOT excluded from serialization, it is sent to the API-Manager. + return !excluded.contains(QUERY_STRING_PASS_THROUGH); + } + + @Test + public void sentOnTheVersionThatIntroducedIt() throws AppException { + Assert.assertTrue(queryStringPassThroughIsSent(APIManagerAPIAdapter.QUERY_STRING_PASS_THROUGH_MIN_VERSION)); + } + + @Test + public void sentOnANewerDatedBuild() throws AppException { + Assert.assertTrue(queryStringPassThroughIsSent("7.7.20261130")); + } + + /** + * The previous implementation stripped the "7.7." prefix and called Integer.parseInt on the remainder, which + * threw on a service pack suffix and silently dropped the field. + */ + @Test + public void sentOnADatedBuildWithAServicePack() throws AppException { + Assert.assertTrue(queryStringPassThroughIsSent("7.7.20261130 SP1"), + "queryStringPassThrough must still be sent when the API-Manager reports a service pack"); + } + + @Test + public void notSentOnAnOlderDatedBuild() throws AppException { + Assert.assertFalse(queryStringPassThroughIsSent("7.7.20200130")); + } + + @Test + public void notSentOnAVersionPredatingTheDatedBuilds() throws AppException { + Assert.assertFalse(queryStringPassThroughIsSent("7.7.0")); + } +} diff --git a/modules/apim-adapter/src/test/java/com/axway/apim/adapter/apis/QuotaConstraintDiffTest.java b/modules/apim-adapter/src/test/java/com/axway/apim/adapter/apis/QuotaConstraintDiffTest.java new file mode 100644 index 000000000..8a8df5910 --- /dev/null +++ b/modules/apim-adapter/src/test/java/com/axway/apim/adapter/apis/QuotaConstraintDiffTest.java @@ -0,0 +1,209 @@ +package com.axway.apim.adapter.apis; + +import com.axway.apim.adapter.apis.QuotaConstraintDiff.QuotaConstraintOperations; +import com.axway.apim.api.model.QuotaRestriction; +import com.axway.apim.api.model.QuotaRestrictionType; +import org.testng.Assert; +import org.testng.annotations.Test; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +public class QuotaConstraintDiffTest { + + private static final String API_A = "aaaaaaaa-0000-0000-0000-000000000001"; + private static final String API_B = "bbbbbbbb-0000-0000-0000-000000000002"; + + private static QuotaRestriction throttle(String id, String apiId, String method, String messages) { + QuotaRestriction restriction = new QuotaRestriction(); + restriction.setId(id); + restriction.setApiId(apiId); + restriction.setMethod(method); + restriction.setType(QuotaRestrictionType.throttle); + Map config = new LinkedHashMap<>(); + config.put("period", "day"); + config.put("per", "1"); + config.put("messages", messages); + restriction.setConfig(config); + return restriction; + } + + private static QuotaRestriction throttlemb(String id, String apiId, String method, String mb) { + QuotaRestriction restriction = new QuotaRestriction(); + restriction.setId(id); + restriction.setApiId(apiId); + restriction.setMethod(method); + restriction.setType(QuotaRestrictionType.throttlemb); + Map config = new LinkedHashMap<>(); + config.put("period", "day"); + config.put("per", "1"); + config.put("mb", mb); + restriction.setConfig(config); + return restriction; + } + + @Test + public void identicalRestrictionsProduceNoOperations() { + List actual = Arrays.asList(throttle("id-1", API_A, "*", "1000")); + List desired = Arrays.asList(throttle(null, API_A, "*", "1000")); + QuotaConstraintOperations operations = QuotaConstraintDiff.diff(actual, desired); + Assert.assertTrue(operations.isEmpty(), "Expected no operations, but got: " + operations); + } + + @Test + public void changedConfigProducesSingleUpdateCarryingTheServerId() { + List actual = Arrays.asList(throttle("id-1", API_A, "*", "1000")); + List desired = Arrays.asList(throttle(null, API_A, "*", "2000")); + QuotaConstraintOperations operations = QuotaConstraintDiff.diff(actual, desired); + Assert.assertEquals(operations.getToUpdate().size(), 1); + Assert.assertTrue(operations.getToCreate().isEmpty()); + Assert.assertTrue(operations.getToDelete().isEmpty()); + QuotaRestriction update = operations.getToUpdate().get(0); + Assert.assertEquals(update.getId(), "id-1", "The update must address the restriction by its server assigned ID"); + Assert.assertEquals(update.getConfig().get("messages"), "2000"); + Assert.assertEquals(update.getApiId(), API_A, "The api must be taken over unchanged, as it cannot be modified"); + Assert.assertEquals(update.getMethod(), "*", "The method must be taken over unchanged, as it cannot be modified"); + } + + @Test + public void addedRestrictionProducesSingleCreate() { + List actual = Arrays.asList(throttle("id-1", API_A, "*", "1000")); + List desired = Arrays.asList(throttle(null, API_A, "*", "1000"), throttle(null, API_B, "*", "50")); + QuotaConstraintOperations operations = QuotaConstraintDiff.diff(actual, desired); + Assert.assertEquals(operations.getToCreate().size(), 1); + Assert.assertEquals(operations.getToCreate().get(0).getApiId(), API_B); + Assert.assertTrue(operations.getToUpdate().isEmpty()); + Assert.assertTrue(operations.getToDelete().isEmpty()); + } + + @Test + public void removedRestrictionProducesSingleDelete() { + List actual = Arrays.asList(throttle("id-1", API_A, "*", "1000"), throttle("id-2", API_B, "*", "50")); + List desired = Arrays.asList(throttle(null, API_A, "*", "1000")); + QuotaConstraintOperations operations = QuotaConstraintDiff.diff(actual, desired); + Assert.assertEquals(operations.getToDelete().size(), 1); + Assert.assertEquals(operations.getToDelete().get(0).getId(), "id-2"); + Assert.assertTrue(operations.getToCreate().isEmpty()); + Assert.assertTrue(operations.getToUpdate().isEmpty()); + } + + /** + * The API-Manager does not allow the method of a restriction to be changed, so it must become a delete plus a + * create instead of an update. + */ + @Test + public void changedMethodProducesDeleteAndCreateInsteadOfUpdate() { + List actual = Arrays.asList(throttle("id-1", API_A, "*", "1000")); + List desired = Arrays.asList(throttle(null, API_A, "method-1", "1000")); + QuotaConstraintOperations operations = QuotaConstraintDiff.diff(actual, desired); + Assert.assertTrue(operations.getToUpdate().isEmpty(), "A scope change must never become an update"); + Assert.assertEquals(operations.getToDelete().size(), 1); + Assert.assertEquals(operations.getToDelete().get(0).getId(), "id-1"); + Assert.assertEquals(operations.getToCreate().size(), 1); + Assert.assertEquals(operations.getToCreate().get(0).getMethod(), "method-1"); + } + + @Test + public void changedTypeProducesDeleteAndCreate() { + List actual = Arrays.asList(throttle("id-1", API_A, "*", "1000")); + List desired = Arrays.asList(throttlemb(null, API_A, "*", "100")); + QuotaConstraintOperations operations = QuotaConstraintDiff.diff(actual, desired); + Assert.assertTrue(operations.getToUpdate().isEmpty()); + Assert.assertEquals(operations.getToDelete().size(), 1); + Assert.assertEquals(operations.getToCreate().size(), 1); + Assert.assertEquals(operations.getToCreate().get(0).getType(), QuotaRestrictionType.throttlemb); + } + + /** + * A single API-Method may carry a throttle and a throttlemb restriction at the same time. They must not + * collapse into one another. + */ + @Test + public void twoTypesOnTheSameMethodAreIndependent() { + List actual = Arrays.asList(throttle("id-1", API_A, "*", "1000"), throttlemb("id-2", API_A, "*", "100")); + List desired = Arrays.asList(throttle(null, API_A, "*", "1000"), throttlemb(null, API_A, "*", "100")); + QuotaConstraintOperations operations = QuotaConstraintDiff.diff(actual, desired); + Assert.assertTrue(operations.isEmpty(), "Expected no operations, but got: " + operations); + } + + /** + * The document level update was able to create duplicates. The surplus must be removed. + */ + @Test + public void duplicateActualRestrictionIsDeleted() { + List actual = Arrays.asList(throttle("id-1", API_A, "*", "1000"), throttle("id-2", API_A, "*", "1000")); + List desired = Arrays.asList(throttle(null, API_A, "*", "1000")); + QuotaConstraintOperations operations = QuotaConstraintDiff.diff(actual, desired); + Assert.assertEquals(operations.getToDelete().size(), 1); + Assert.assertEquals(operations.getToDelete().get(0).getId(), "id-2"); + Assert.assertTrue(operations.getToCreate().isEmpty()); + Assert.assertTrue(operations.getToUpdate().isEmpty()); + } + + /** + * This is the behaviour that replaces the "do not overwrite manually maintained quota" guarantee: restrictions + * belonging to other APIs travel through the document unchanged and must not cause a single HTTP call. + */ + @Test + public void restrictionsOfOtherApisAreLeftAlone() { + List actual = new ArrayList<>(); + List desired = new ArrayList<>(); + for (int i = 0; i < 3; i++) { + String otherApi = "cccccccc-0000-0000-0000-00000000000" + i; + actual.add(throttle("id-" + i, otherApi, "*", "1000")); + desired.add(throttle(null, otherApi, "*", "1000")); + } + QuotaConstraintOperations operations = QuotaConstraintDiff.diff(actual, desired); + Assert.assertTrue(operations.isEmpty(), "Expected no operations, but got: " + operations); + } + + @Test + public void emptyDesiredDeletesEverything() { + List actual = Arrays.asList(throttle("id-1", API_A, "*", "1000"), throttle("id-2", API_B, "*", "50")); + QuotaConstraintOperations operations = QuotaConstraintDiff.diff(actual, Collections.emptyList()); + Assert.assertEquals(operations.getToDelete().size(), 2); + Assert.assertEquals(operations.size(), 2); + } + + @Test + public void nullListsAreTreatedAsEmpty() { + Assert.assertTrue(QuotaConstraintDiff.diff(null, null).isEmpty()); + Assert.assertEquals(QuotaConstraintDiff.diff(null, Arrays.asList(throttle(null, API_A, "*", "1000"))).getToCreate().size(), 1); + Assert.assertEquals(QuotaConstraintDiff.diff(Arrays.asList(throttle("id-1", API_A, "*", "1000")), null).getToDelete().size(), 1); + } + + /** + * The API-Manager returns the numbers as strings while a config file may provide them padded. + */ + @Test + public void configValuesAreComparedTrimmed() { + QuotaRestriction actual = throttle("id-1", API_A, "*", "1000"); + QuotaRestriction desired = throttle(null, API_A, "*", " 1000 "); + Assert.assertTrue(QuotaConstraintDiff.diff(Arrays.asList(actual), Arrays.asList(desired)).isEmpty()); + } + + /** + * A null api or method means "all", exactly as QuotaRestrictionDeserializer normalises it. + */ + @Test + public void nullApiAndMethodMatchTheStarNotation() { + List actual = Arrays.asList(throttle("id-1", null, null, "1000")); + List desired = Arrays.asList(throttle(null, "*", "*", "1000")); + Assert.assertTrue(QuotaConstraintDiff.diff(actual, desired).isEmpty()); + } + + /** + * A key that is only present in the API-Manager response must not trigger an endless stream of updates. + */ + @Test + public void unmanagedConfigKeysAreIgnored() { + QuotaRestriction actual = throttle("id-1", API_A, "*", "1000"); + actual.getConfig().put("someFutureKey", "someValue"); + QuotaRestriction desired = throttle(null, API_A, "*", "1000"); + Assert.assertTrue(QuotaConstraintDiff.diff(Arrays.asList(actual), Arrays.asList(desired)).isEmpty()); + } +} diff --git a/modules/apim-adapter/src/test/java/com/axway/apim/adapter/client/apps/APIMgrAppsAdapterTest.java b/modules/apim-adapter/src/test/java/com/axway/apim/adapter/client/apps/APIMgrAppsAdapterTest.java index 8b1468042..a3f12a8de 100644 --- a/modules/apim-adapter/src/test/java/com/axway/apim/adapter/client/apps/APIMgrAppsAdapterTest.java +++ b/modules/apim-adapter/src/test/java/com/axway/apim/adapter/client/apps/APIMgrAppsAdapterTest.java @@ -14,12 +14,12 @@ import com.fasterxml.jackson.databind.ser.FilterProvider; import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter; import com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider; -import org.apache.http.HttpEntity; -import org.apache.http.NameValuePair; -import org.apache.http.client.utils.URIBuilder; -import org.apache.http.entity.ContentType; -import org.apache.http.entity.StringEntity; -import org.apache.http.message.BasicNameValuePair; +import org.apache.hc.core5.http.HttpEntity; +import org.apache.hc.core5.http.NameValuePair; +import org.apache.hc.core5.net.URIBuilder; +import org.apache.hc.core5.http.ContentType; +import org.apache.hc.core5.http.io.entity.StringEntity; +import org.apache.hc.core5.http.message.BasicNameValuePair; import org.testng.Assert; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; @@ -65,7 +65,7 @@ public void queryForUniqueApplication() throws IOException, URISyntaxException { ClientAppFilter filter = new ClientAppFilter.Builder().hasName("Application 123").build(); URI requestUri = clientAppAdapter.getApplicationsUri(filter); Assert.assertNotNull(requestUri, "RequestUri is null"); - Assert.assertEquals(requestUri.toString(), "https://" + testHostname + ":" + testPort + "/api/portal/v1.4/applications?field=name&op=eq&value=Application+123"); + Assert.assertEquals(requestUri.toString(), "https://" + testHostname + ":" + testPort + "/api/portal/v1.4/applications?field=name&op=eq&value=Application%20123"); } @Test diff --git a/modules/apim-adapter/src/test/java/com/axway/apim/api/model/QuotaRestrictionSerializationTest.java b/modules/apim-adapter/src/test/java/com/axway/apim/api/model/QuotaRestrictionSerializationTest.java new file mode 100644 index 000000000..7ff44c4e8 --- /dev/null +++ b/modules/apim-adapter/src/test/java/com/axway/apim/api/model/QuotaRestrictionSerializationTest.java @@ -0,0 +1,90 @@ +package com.axway.apim.api.model; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.ser.FilterProvider; +import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter; +import com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider; +import org.testng.Assert; +import org.testng.annotations.Test; + +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * The constraint ID assigned by the API-Manager must never be written anywhere: it is ignored when a restriction is + * created, it is taken from the URL when a restriction is updated, and it must not end up in an exported config file. + *

+ * QuotaRestriction is serialized through four independent filter configurations across the modules, two of which do + * not use QuotaRestrictionSerializer at all, so every one of them is asserted here. + */ +public class QuotaRestrictionSerializationTest { + + private static QuotaRestriction restrictionWithId() { + QuotaRestriction restriction = new QuotaRestriction(); + restriction.setId("c0000000-0000-0000-0000-000000000001"); + restriction.setApiId("9170e76e-ee7a-45ae-8afe-32a32a5da65c"); + restriction.setMethod("*"); + restriction.setType(QuotaRestrictionType.throttle); + Map config = new LinkedHashMap<>(); + config.put("period", "day"); + config.put("per", "1"); + config.put("messages", "1000"); + restriction.setConfig(config); + return restriction; + } + + private static String serializeWith(SimpleBeanPropertyFilter filter) throws Exception { + FilterProvider filterProvider = new SimpleFilterProvider().setDefaultFilter(filter); + return new ObjectMapper().writer(filterProvider).writeValueAsString(restrictionWithId()); + } + + /** + * APIManagerQuotaAdapter when writing to the API-Manager. + */ + @Test + public void idIsNotSerializedForTheApiManagerRequest() throws Exception { + String json = serializeWith(SimpleBeanPropertyFilter.serializeAllExcept("apiId", "apiName", "apiVersion", "apiPath", "vhost", "queryVersion")); + Assert.assertFalse(json.contains("\"id\""), json); + Assert.assertTrue(json.contains("\"api\""), json); + } + + /** + * JsonAPIManagerSetupExporter, which uses the default bean serializer. + */ + @Test + public void idIsNotSerializedForTheSettingsExport() throws Exception { + String json = serializeWith(SimpleBeanPropertyFilter.serializeAllExcept("apiId")); + Assert.assertFalse(json.contains("\"id\""), json); + } + + /** + * ExportHelper, which serializes everything that is not explicitly excluded. + */ + @Test + public void idIsNotSerializedForTheApiExport() throws Exception { + String json = serializeWith(SimpleBeanPropertyFilter.serializeAllExcept()); + Assert.assertFalse(json.contains("\"id\""), json); + } + + /** + * JsonApplicationExporter. + */ + @Test + public void idIsNotSerializedForTheApplicationExport() throws Exception { + String json = serializeWith(SimpleBeanPropertyFilter.serializeAllExcept("api", "apiId")); + Assert.assertFalse(json.contains("\"id\""), json); + } + + /** + * Two restrictions differing only by the constraint ID must stay equal, as the desired state read from a config + * file never carries one. Otherwise every API would be reported as changed on every run. + */ + @Test + public void idIsNotPartOfEqualsAndHashCode() { + QuotaRestriction withId = restrictionWithId(); + QuotaRestriction withoutId = restrictionWithId(); + withoutId.setId(null); + Assert.assertEquals(withId, withoutId); + Assert.assertEquals(withId.hashCode(), withoutId.hashCode()); + } +} diff --git a/modules/apim-adapter/src/test/java/com/axway/apim/api/specification/APISpecificationFactoryTest.java b/modules/apim-adapter/src/test/java/com/axway/apim/api/specification/APISpecificationFactoryTest.java index 21767f443..8b126e27f 100644 --- a/modules/apim-adapter/src/test/java/com/axway/apim/api/specification/APISpecificationFactoryTest.java +++ b/modules/apim-adapter/src/test/java/com/axway/apim/api/specification/APISpecificationFactoryTest.java @@ -1,16 +1,10 @@ package com.axway.apim.api.specification; import com.axway.apim.WiremockWrapper; -import com.axway.apim.adapter.APIManagerAdapter; -import com.axway.apim.adapter.apis.APIManagerAPIAdapter; -import com.axway.apim.adapter.apis.APIManagerOrganizationAdapter; -import com.axway.apim.lib.CoreParameters; import com.axway.apim.lib.error.AppException; -import com.axway.apim.lib.utils.Utils; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import org.apache.commons.io.IOUtils; -import org.apache.http.util.Asserts; import org.testng.Assert; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; diff --git a/modules/apim-adapter/src/test/java/com/axway/lib/utils/HttpClientTest.java b/modules/apim-adapter/src/test/java/com/axway/lib/utils/HttpClientTest.java index 237395d14..c586b29f8 100644 --- a/modules/apim-adapter/src/test/java/com/axway/lib/utils/HttpClientTest.java +++ b/modules/apim-adapter/src/test/java/com/axway/lib/utils/HttpClientTest.java @@ -3,10 +3,10 @@ import com.axway.apim.WiremockWrapper; import com.axway.apim.lib.utils.HTTPClient; import com.axway.apim.lib.utils.Utils; -import org.apache.http.client.config.RequestConfig; -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.util.EntityUtils; +import org.apache.hc.client5.http.config.RequestConfig; +import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse; +import org.apache.hc.client5.http.classic.methods.HttpGet; +import org.apache.hc.core5.http.io.entity.EntityUtils; import org.testng.Assert; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; @@ -32,13 +32,12 @@ public void downloadApiSpec() throws Exception { HTTPClient httpClient = new HTTPClient(url, "user", Utils.getEncryptedPassword()); httpClient.getClient(); RequestConfig config = RequestConfig.custom() - .setRelativeRedirectsAllowed(true) .setCircularRedirectsAllowed(true) .build(); HttpGet httpGet = new HttpGet(url); httpGet.setConfig(config); try (CloseableHttpResponse httpResponse = httpClient.execute(httpGet)) { - Assert.assertEquals(200, httpResponse.getStatusLine().getStatusCode()); + Assert.assertEquals(200, httpResponse.getCode()); String response = EntityUtils.toString(httpResponse.getEntity(), StandardCharsets.UTF_8); Assert.assertNotNull(response); }finally { diff --git a/modules/apim-adapter/src/test/java/com/axway/lib/utils/rest/APIMHttpClientTest.java b/modules/apim-adapter/src/test/java/com/axway/lib/utils/rest/APIMHttpClientTest.java index 316bcde55..a6ce3004f 100644 --- a/modules/apim-adapter/src/test/java/com/axway/lib/utils/rest/APIMHttpClientTest.java +++ b/modules/apim-adapter/src/test/java/com/axway/lib/utils/rest/APIMHttpClientTest.java @@ -4,7 +4,7 @@ import com.axway.apim.lib.StandardImportParams; import com.axway.apim.lib.error.AppException; import com.axway.apim.lib.utils.rest.APIMHttpClient; -import org.apache.http.Header; +import org.apache.hc.core5.http.Header; import org.testng.Assert; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; diff --git a/modules/apim-cli-tests/pom.xml b/modules/apim-cli-tests/pom.xml index be2f2a9cd..0d64d923e 100644 --- a/modules/apim-cli-tests/pom.xml +++ b/modules/apim-cli-tests/pom.xml @@ -14,7 +14,7 @@ 8 8 UTF-8 - 3.3.1 + 3.13.1 @@ -58,11 +58,6 @@ citrus-validation-xml ${citrus.version} - - org.citrusframework - citrus-java-dsl - 4.0.0-M1 - org.citrusframework citrus-sql @@ -80,7 +75,7 @@ org.apache.logging.log4j - log4j-slf4j-impl + log4j-slf4j2-impl org.testng diff --git a/modules/apim-cli-tests/src/main/java/com/axway/apim/EndpointConfig.java b/modules/apim-cli-tests/src/main/java/com/axway/apim/EndpointConfig.java index dca63e368..e69ad6d8d 100644 --- a/modules/apim-cli-tests/src/main/java/com/axway/apim/EndpointConfig.java +++ b/modules/apim-cli-tests/src/main/java/com/axway/apim/EndpointConfig.java @@ -3,20 +3,26 @@ import org.apache.hc.client5.http.impl.classic.HttpClients; import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager; import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManagerBuilder; +import org.apache.hc.client5.http.ssl.DefaultClientTlsStrategy; +import org.apache.hc.client5.http.ssl.HostnameVerificationPolicy; import org.apache.hc.client5.http.ssl.NoopHostnameVerifier; -import org.apache.hc.client5.http.ssl.SSLConnectionSocketFactory; +import org.apache.hc.client5.http.ssl.TlsSocketStrategy; import org.apache.hc.core5.ssl.SSLContexts; import org.apache.hc.core5.ssl.TrustStrategy; import org.citrusframework.dsl.endpoint.CitrusEndpoints; import org.citrusframework.http.client.HttpClient; import org.citrusframework.http.interceptor.LoggingClientInterceptor; +import org.citrusframework.spring.variable.GlobalVariablesPropertyLoader; import org.citrusframework.variable.GlobalVariables; -import org.citrusframework.variable.GlobalVariablesPropertyLoader; import org.springframework.beans.factory.BeanCreationException; import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.EnvironmentAware; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; +import org.springframework.core.env.ConfigurableEnvironment; +import org.springframework.core.env.Environment; +import org.springframework.core.env.MapPropertySource; import org.springframework.http.client.ClientHttpRequestInterceptor; import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; @@ -24,12 +30,31 @@ import java.security.KeyManagementException; import java.security.KeyStoreException; import java.security.NoSuchAlgorithmException; +import java.util.ArrayList; import java.util.Arrays; +import java.util.LinkedHashMap; import java.util.List; +import java.util.Map; @Configuration @PropertySource({"classpath:citrus-global-variables.properties"}) -public class EndpointConfig { +public class EndpointConfig implements EnvironmentAware { + + /** + * Environment variable per property, so that the credentials and the host are not stored in the repository. + * They cannot be expressed as ${...} placeholders inside citrus-global-variables.properties, because the Citrus + * GlobalVariablesPropertyLoader reads that very file and resolves ${...} as a Citrus test variable, which fails + * for anything it does not know. + */ + private static final Map ENVIRONMENT_OVERRIDES = buildEnvironmentOverrides(); + + private static Map buildEnvironmentOverrides() { + Map overrides = new LinkedHashMap<>(); + overrides.put("apiManagerHost", "apimanager_host"); + overrides.put("apiManagerPass", "apimanager_password"); + overrides.put("oadminPassword1", "oadmin_password"); + return overrides; + } @Value("${apiManagerHost}") private String host; @@ -37,6 +62,26 @@ public class EndpointConfig { @Value("${apiManagerPort}") private int port; + /** + * Makes the environment variables win over the defaults of citrus-global-variables.properties for every + * Spring @Value in the test suite. Runs before any bean is created, so the placeholders resolve against it. + */ + @Override + public void setEnvironment(Environment environment) { + if (!(environment instanceof ConfigurableEnvironment)) return; + Map resolved = new LinkedHashMap<>(); + for (Map.Entry override : ENVIRONMENT_OVERRIDES.entrySet()) { + String value = environment.getProperty(override.getValue()); + if (value != null && !value.isEmpty()) { + resolved.put(override.getKey(), value); + } + } + if (!resolved.isEmpty()) { + ((ConfigurableEnvironment) environment).getPropertySources() + .addFirst(new MapPropertySource("apimCliTestEnvironmentOverrides", resolved)); + } + } + @Bean public HttpClient apiManager() { return CitrusEndpoints @@ -56,10 +101,10 @@ public org.apache.hc.client5.http.classic.HttpClient httpClient() { SSLContext sslContext = SSLContexts.custom() .loadTrustMaterial(null, acceptingTrustStrategy) .build(); - SSLConnectionSocketFactory sslSocketFactory = new SSLConnectionSocketFactory( - sslContext, NoopHostnameVerifier.INSTANCE); + TlsSocketStrategy tlsSocketStrategy = new DefaultClientTlsStrategy( + sslContext, HostnameVerificationPolicy.CLIENT, NoopHostnameVerifier.INSTANCE); PoolingHttpClientConnectionManager connectionManager = PoolingHttpClientConnectionManagerBuilder.create() - .setSSLSocketFactory(sslSocketFactory) + .setTlsSocketStrategy(tlsSocketStrategy) .build(); return HttpClients.custom() .setConnectionManager(connectionManager) @@ -86,9 +131,7 @@ public HttpComponentsClientHttpRequestFactory sslRequestFactory() { @Bean public GlobalVariables globalVariables() { - GlobalVariables globalVariables = new GlobalVariables(); - globalVariables.getVariables().put("myVar", "foo"); - return globalVariables; + return new GlobalVariables(); } @Bean @@ -97,4 +140,29 @@ public GlobalVariablesPropertyLoader globalVariablesPropertyLoader() { propertyLoader.getPropertyFiles().add("classpath:citrus-global-variables.properties"); return propertyLoader; } + + /** + * The property loader fills the Citrus global variables straight from the file and therefore knows nothing + * about the environment overrides. This re-reads every variable through the Spring environment, where the + * overrides registered in {@link #setEnvironment(Environment)} take precedence. + * Declaring the loader as a parameter guarantees it has already run. + */ + @Bean + public GlobalVariableEnvironmentOverrides globalVariableEnvironmentOverrides(GlobalVariables globalVariables, + GlobalVariablesPropertyLoader propertyLoader, + Environment environment) { + return new GlobalVariableEnvironmentOverrides(globalVariables, environment); + } + + public static class GlobalVariableEnvironmentOverrides { + + GlobalVariableEnvironmentOverrides(GlobalVariables globalVariables, Environment environment) { + for (String name : new ArrayList<>(globalVariables.getVariables().keySet())) { + String resolved = environment.getProperty(name); + if (resolved != null) { + globalVariables.getVariables().put(name, resolved); + } + } + } + } } diff --git a/modules/apim-cli-tests/src/main/java/com/axway/apim/TestUtils.java b/modules/apim-cli-tests/src/main/java/com/axway/apim/TestUtils.java index 2637fc35b..99f00d71d 100644 --- a/modules/apim-cli-tests/src/main/java/com/axway/apim/TestUtils.java +++ b/modules/apim-cli-tests/src/main/java/com/axway/apim/TestUtils.java @@ -51,10 +51,10 @@ public static String createTestConfig(String configFilePath, TestContext context public static String writeDataToFile(Resource configFile, String tempDirName, String replacedConfig){ File testDirectory = createTestDirectory(tempDirName); - File newConfigFilePath = new File(testDirectory, configFile.getFile().getName()); + File newConfigFilePath = new File(testDirectory, configFile.file().getName()); try (Writer writer = new FileWriter(newConfigFilePath)) { writer.write(replacedConfig); - copyTestAssets(configFile.getFile().getParentFile(), testDirectory); + copyTestAssets(configFile.file().getParentFile(), testDirectory); } catch (IOException e) { throw new ValidationException("Unable to create test config file.", e); } diff --git a/modules/apim-cli-tests/src/main/java/com/axway/apim/WiremockWrapper.java b/modules/apim-cli-tests/src/main/java/com/axway/apim/WiremockWrapper.java index 009b84873..4f5436360 100644 --- a/modules/apim-cli-tests/src/main/java/com/axway/apim/WiremockWrapper.java +++ b/modules/apim-cli-tests/src/main/java/com/axway/apim/WiremockWrapper.java @@ -14,6 +14,12 @@ public class WiremockWrapper { WireMockServer wireMockServer; + /** + * Allows tests in other packages to assert which requests the CLI actually sent. + */ + public WireMockServer getWireMockServer() { + return wireMockServer; + } public void initWiremock() { Notifier notifier; diff --git a/modules/apim-cli-tests/src/main/resources/citrus-global-variables.properties b/modules/apim-cli-tests/src/main/resources/citrus-global-variables.properties index 01832510d..f5297fc1d 100644 --- a/modules/apim-cli-tests/src/main/resources/citrus-global-variables.properties +++ b/modules/apim-cli-tests/src/main/resources/citrus-global-variables.properties @@ -1,14 +1,22 @@ +# Defaults for the integration tests. Plain values only. +# This file is read twice: by Spring as a @PropertySource and by the Citrus GlobalVariablesPropertyLoader. +# Citrus resolves ${...} as a Citrus test variable and fails on anything it does not know, so placeholders +# must NOT be used here. Credentials and the host are taken from environment variables instead, see +# EndpointConfig#setEnvironment: +# apimanager_host -> apiManagerHost +# apimanager_password -> apiManagerPass +# oadmin_password -> oadminPassword1 apiManagerHost=localhost apiManagerPort=8075 -# This user-account is only used for the initial-test to setup the envirnoment. +# This user-account is only used for the initial-test to set up the environment. apiManagerUser=apiadmin -apiManagerPass=Axway@2026! +apiManagerPass= enforce=true API_VERSION=/api/portal/v1.4 orgNumber=2172 orgName=API Development 2172 oadminUsername1=testoadmin -oadminPassword1=Axway@2026! +oadminPassword1= testAppName=Test_Consumer orgName2=API Development 4172 orgName3=API Development 5172 diff --git a/modules/apim-cli-tests/src/main/resources/wiremock_apim/__files/quota_constraint_created.json b/modules/apim-cli-tests/src/main/resources/wiremock_apim/__files/quota_constraint_created.json new file mode 100644 index 000000000..c603b88e3 --- /dev/null +++ b/modules/apim-cli-tests/src/main/resources/wiremock_apim/__files/quota_constraint_created.json @@ -0,0 +1,11 @@ +{ + "id": "c0000000-0000-0000-0000-0000000000ff", + "api": "*", + "method": "*", + "type": "throttle", + "config": { + "messages": "10000", + "period": "second", + "per": "1" + } +} diff --git a/modules/apim-cli-tests/src/main/resources/wiremock_apim/__files/quota_constraints_api.json b/modules/apim-cli-tests/src/main/resources/wiremock_apim/__files/quota_constraints_api.json new file mode 100644 index 000000000..74ff747ad --- /dev/null +++ b/modules/apim-cli-tests/src/main/resources/wiremock_apim/__files/quota_constraints_api.json @@ -0,0 +1,35 @@ +[ + { + "id": "c0000000-0000-0000-0000-000000000001", + "api": "9170e76e-ee7a-45ae-8afe-32a32a5da65c", + "method": "*", + "type": "throttle", + "config": { + "messages": "1000", + "period": "week", + "per": "2" + } + }, + { + "id": "c0000000-0000-0000-0000-000000000002", + "api": "e4ded8c8-0a40-4b50-bc13-552fb7209150", + "method": "*", + "type": "throttle", + "config": { + "messages": "1000", + "period": "second", + "per": "2" + } + }, + { + "id": "c0000000-0000-0000-0000-000000000003", + "api": "*", + "method": "*", + "type": "throttle", + "config": { + "messages": "10000", + "period": "second", + "per": "1" + } + } +] diff --git a/modules/apim-cli-tests/src/main/resources/wiremock_apim/__files/quota_constraints_application.json b/modules/apim-cli-tests/src/main/resources/wiremock_apim/__files/quota_constraints_application.json new file mode 100644 index 000000000..fea041a2e --- /dev/null +++ b/modules/apim-cli-tests/src/main/resources/wiremock_apim/__files/quota_constraints_application.json @@ -0,0 +1,13 @@ +[ + { + "id": "c0000000-0000-0000-0000-00000000000a", + "api": "e4ded8c8-0a40-4b50-bc13-552fb7209150", + "method": "*", + "type": "throttle", + "config": { + "messages": "200", + "period": "second", + "per": "5" + } + } +] diff --git a/modules/apim-cli-tests/src/main/resources/wiremock_apim/mappings/createQuotaConstraint.json b/modules/apim-cli-tests/src/main/resources/wiremock_apim/mappings/createQuotaConstraint.json new file mode 100644 index 000000000..f90537d2f --- /dev/null +++ b/modules/apim-cli-tests/src/main/resources/wiremock_apim/mappings/createQuotaConstraint.json @@ -0,0 +1,13 @@ +{ + "request": { + "method": "POST", + "urlPathPattern": "/api/portal/v1.4/quotas/[0-9a-f-]+/constraints" + }, + "response": { + "status": 201, + "bodyFileName": "quota_constraint_created.json", + "headers": { + "Content-Type": "application/json" + } + } +} diff --git a/modules/apim-cli-tests/src/main/resources/wiremock_apim/mappings/deleteQuotaConstraint.json b/modules/apim-cli-tests/src/main/resources/wiremock_apim/mappings/deleteQuotaConstraint.json new file mode 100644 index 000000000..2f5091fb7 --- /dev/null +++ b/modules/apim-cli-tests/src/main/resources/wiremock_apim/mappings/deleteQuotaConstraint.json @@ -0,0 +1,9 @@ +{ + "request": { + "method": "DELETE", + "urlPathPattern": "/api/portal/v1.4/quotas/[0-9a-f-]+/constraints/[0-9a-f-]+" + }, + "response": { + "status": 204 + } +} diff --git a/modules/apim-cli-tests/src/main/resources/wiremock_apim/mappings/getApplicationByName.json b/modules/apim-cli-tests/src/main/resources/wiremock_apim/mappings/getApplicationByName.json index 08aa7cc79..89ea07c31 100644 --- a/modules/apim-cli-tests/src/main/resources/wiremock_apim/mappings/getApplicationByName.json +++ b/modules/apim-cli-tests/src/main/resources/wiremock_apim/mappings/getApplicationByName.json @@ -1,7 +1,7 @@ { "request": { "method": "GET", - "url": "/api/portal/v1.4/applications?field=name&op=eq&value=Test+App+2008" + "url": "/api/portal/v1.4/applications?field=name&op=eq&value=Test%20App%202008" }, "response": { "status": 200, diff --git a/modules/apim-cli-tests/src/main/resources/wiremock_apim/mappings/getQuotaConstraintsApplication.json b/modules/apim-cli-tests/src/main/resources/wiremock_apim/mappings/getQuotaConstraintsApplication.json new file mode 100644 index 000000000..b4a01ca3e --- /dev/null +++ b/modules/apim-cli-tests/src/main/resources/wiremock_apim/mappings/getQuotaConstraintsApplication.json @@ -0,0 +1,13 @@ +{ + "request": { + "method": "GET", + "url": "/api/portal/v1.4/quotas/00000000-0000-0000-0000-000000000001/constraints" + }, + "response": { + "status": 200, + "bodyFileName": "quota_constraints_application.json", + "headers": { + "Content-Type": "application/json" + } + } +} diff --git a/modules/apim-cli-tests/src/main/resources/wiremock_apim/mappings/getQuotaConstraintsSystem.json b/modules/apim-cli-tests/src/main/resources/wiremock_apim/mappings/getQuotaConstraintsSystem.json new file mode 100644 index 000000000..ac7ed3d9b --- /dev/null +++ b/modules/apim-cli-tests/src/main/resources/wiremock_apim/mappings/getQuotaConstraintsSystem.json @@ -0,0 +1,13 @@ +{ + "request": { + "method": "GET", + "url": "/api/portal/v1.4/quotas/00000000-0000-0000-0000-000000000000/constraints" + }, + "response": { + "status": 200, + "bodyFileName": "quota_constraints_api.json", + "headers": { + "Content-Type": "application/json" + } + } +} diff --git a/modules/apim-cli-tests/src/main/resources/wiremock_apim/mappings/updateQuotaConstraint.json b/modules/apim-cli-tests/src/main/resources/wiremock_apim/mappings/updateQuotaConstraint.json new file mode 100644 index 000000000..c956d6da0 --- /dev/null +++ b/modules/apim-cli-tests/src/main/resources/wiremock_apim/mappings/updateQuotaConstraint.json @@ -0,0 +1,13 @@ +{ + "request": { + "method": "PUT", + "urlPathPattern": "/api/portal/v1.4/quotas/[0-9a-f-]+/constraints/[0-9a-f-]+" + }, + "response": { + "status": 200, + "bodyFileName": "quota_constraint_created.json", + "headers": { + "Content-Type": "application/json" + } + } +} diff --git a/modules/apim-cli-tests/src/test/java/com/axway/apim/EndpointConfigEnvironmentOverrideTest.java b/modules/apim-cli-tests/src/test/java/com/axway/apim/EndpointConfigEnvironmentOverrideTest.java new file mode 100644 index 000000000..b67bb9d10 --- /dev/null +++ b/modules/apim-cli-tests/src/test/java/com/axway/apim/EndpointConfigEnvironmentOverrideTest.java @@ -0,0 +1,96 @@ +package com.axway.apim; + +import com.axway.apim.EndpointConfig.GlobalVariableEnvironmentOverrides; +import org.citrusframework.variable.GlobalVariables; +import org.springframework.core.env.MapPropertySource; +import org.springframework.core.env.StandardEnvironment; +import org.testng.Assert; +import org.testng.annotations.Test; + +import java.util.HashMap; +import java.util.Map; + +/** + * The integration test credentials come from environment variables, while citrus-global-variables.properties only + * holds the defaults. The file cannot use ${...} placeholders, because the Citrus GlobalVariablesPropertyLoader + * reads that same file and resolves ${...} as a Citrus test variable, failing on anything it does not know. + */ +public class EndpointConfigEnvironmentOverrideTest { + + private static StandardEnvironment environmentWith(Map properties) { + StandardEnvironment environment = new StandardEnvironment(); + // Stands in for the citrus-global-variables.properties defaults. + Map defaults = new HashMap<>(); + defaults.put("apiManagerHost", "localhost"); + defaults.put("apiManagerPass", ""); + defaults.put("oadminPassword1", ""); + defaults.put("apiManagerUser", "apiadmin"); + environment.getPropertySources().addLast(new MapPropertySource("defaults", defaults)); + if (!properties.isEmpty()) { + environment.getPropertySources().addFirst(new MapPropertySource("environment", properties)); + } + return environment; + } + + @Test + public void environmentVariablesOverrideTheDefaults() { + Map env = new HashMap<>(); + env.put("apimanager_host", "apim.example.com"); + env.put("apimanager_password", "secret-from-environment"); + env.put("oadmin_password", "oadmin-from-environment"); + StandardEnvironment environment = environmentWith(env); + + new EndpointConfig().setEnvironment(environment); + + Assert.assertEquals(environment.getProperty("apiManagerHost"), "apim.example.com"); + Assert.assertEquals(environment.getProperty("apiManagerPass"), "secret-from-environment"); + Assert.assertEquals(environment.getProperty("oadminPassword1"), "oadmin-from-environment"); + Assert.assertEquals(environment.getProperty("apiManagerUser"), "apiadmin", "Untouched properties must keep their default"); + } + + @Test + public void defaultsSurviveWhenNoEnvironmentVariableIsSet() { + StandardEnvironment environment = environmentWith(new HashMap<>()); + + new EndpointConfig().setEnvironment(environment); + + Assert.assertEquals(environment.getProperty("apiManagerHost"), "localhost"); + } + + /** + * An empty environment variable must not win over the default, otherwise an unset CI secret would silently + * blank out the host. + */ + @Test + public void emptyEnvironmentVariableDoesNotOverrideTheDefault() { + Map env = new HashMap<>(); + env.put("apimanager_host", ""); + StandardEnvironment environment = environmentWith(env); + + new EndpointConfig().setEnvironment(environment); + + Assert.assertEquals(environment.getProperty("apiManagerHost"), "localhost"); + } + + /** + * The Citrus global variables are filled straight from the file by the property loader, so they have to be + * re-read through the environment to pick the overrides up. + */ + @Test + public void citrusGlobalVariablesPickUpTheOverrides() { + Map env = new HashMap<>(); + env.put("apimanager_password", "secret-from-environment"); + StandardEnvironment environment = environmentWith(env); + new EndpointConfig().setEnvironment(environment); + + GlobalVariables globalVariables = new GlobalVariables(); + // What GlobalVariablesPropertyLoader would have loaded from the file. + globalVariables.getVariables().put("apiManagerPass", ""); + globalVariables.getVariables().put("apiManagerUser", "apiadmin"); + + new GlobalVariableEnvironmentOverrides(globalVariables, environment); + + Assert.assertEquals(globalVariables.getVariables().get("apiManagerPass"), "secret-from-environment"); + Assert.assertEquals(globalVariables.getVariables().get("apiManagerUser"), "apiadmin"); + } +} diff --git a/modules/apim-cli-tests/src/test/java/com/axway/apim/EndpointConfigTest.java b/modules/apim-cli-tests/src/test/java/com/axway/apim/EndpointConfigTest.java index 87c220d92..2d7a1facf 100644 --- a/modules/apim-cli-tests/src/test/java/com/axway/apim/EndpointConfigTest.java +++ b/modules/apim-cli-tests/src/test/java/com/axway/apim/EndpointConfigTest.java @@ -4,7 +4,7 @@ import org.citrusframework.http.client.HttpClient; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; import org.citrusframework.variable.GlobalVariables; -import org.citrusframework.variable.GlobalVariablesPropertyLoader; +import org.citrusframework.spring.variable.GlobalVariablesPropertyLoader; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; import org.springframework.http.*; @@ -30,7 +30,8 @@ public void testConfiguration() throws IOException { GlobalVariables globalVariables = context.getBean("globalVariables", GlobalVariables.class); Assert.assertNotNull(globalVariables); - Assert.assertEquals(globalVariables.getVariables().get("myVar"), "foo"); + Assert.assertEquals(globalVariables.getVariables().get("apiManagerPort"), + context.getEnvironment().getRequiredProperty("apiManagerPort")); GlobalVariablesPropertyLoader globalVariablesPropertyLoader = context.getBean("globalVariablesPropertyLoader", GlobalVariablesPropertyLoader.class); @@ -73,11 +74,15 @@ public URI getURI() { public HttpHeaders getHeaders() { return httpHeaders; } + + @Override + public java.util.Map getAttributes() { + return java.util.Collections.emptyMap(); + } }; ClientHttpRequestExecution clientHttpRequestExecution = (request, body) -> { - ClientHttpResponse clientHttpResponse = new MockClientHttpResponse(body, HttpStatus.OK); - return clientHttpResponse; + return new MockClientHttpResponse(body, HttpStatus.OK); }; ClientHttpResponse httpResponse = basicAuthInterceptor.intercept(httpRequest, "hello world".getBytes(), clientHttpRequestExecution); Assert.assertNotNull(httpResponse); diff --git a/modules/apis/pom.xml b/modules/apis/pom.xml index f1eecf426..856379a28 100644 --- a/modules/apis/pom.xml +++ b/modules/apis/pom.xml @@ -26,8 +26,8 @@ ${project.version} - org.apache.httpcomponents - httpclient + org.apache.httpcomponents.client5 + httpclient5 commons-cli @@ -41,10 +41,7 @@ org.apache.commons commons-text - - org.apache.httpcomponents - httpmime - + com.fasterxml.jackson.core jackson-core diff --git a/modules/apis/src/main/java/com/axway/apim/APIImportApp.java b/modules/apis/src/main/java/com/axway/apim/APIImportApp.java index 1bfec23f6..05e14660a 100644 --- a/modules/apis/src/main/java/com/axway/apim/APIImportApp.java +++ b/modules/apis/src/main/java/com/axway/apim/APIImportApp.java @@ -22,8 +22,8 @@ import com.axway.apim.lib.error.ErrorCode; import com.axway.apim.lib.error.ErrorCodeMapper; import com.axway.apim.lib.utils.Utils; -import org.apache.http.NameValuePair; -import org.apache.http.message.BasicNameValuePair; +import org.apache.hc.core5.http.NameValuePair; +import org.apache.hc.core5.http.message.BasicNameValuePair; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/modules/apis/src/main/java/com/axway/apim/api/export/impl/CheckCertificatesAPIHandler.java b/modules/apis/src/main/java/com/axway/apim/api/export/impl/CheckCertificatesAPIHandler.java index d4d6a302e..68b69f60a 100644 --- a/modules/apis/src/main/java/com/axway/apim/api/export/impl/CheckCertificatesAPIHandler.java +++ b/modules/apis/src/main/java/com/axway/apim/api/export/impl/CheckCertificatesAPIHandler.java @@ -116,9 +116,9 @@ public void writeJSON(List apiCerts) throws AppException { LOG.debug("Going to export expired certificates details into folder: {}", localFolder); exportHelper.validateFolder(localFolder); String filePath = localFolder.getCanonicalPath() + File.separator + "certificates.json"; - ObjectMapper mapper = new ObjectMapper().enable(SerializationFeature.INDENT_OUTPUT); + ObjectMapper mapper = new ObjectMapper(); try (Writer writer = new FileWriter(filePath)) { - mapper.writeValue(writer, apiCerts); + mapper.writer().with(SerializationFeature.INDENT_OUTPUT).writeValue(writer, apiCerts); } LOG.debug("Successfully exported Certificate Expiry Data to file : {}", filePath); } catch (IOException e) { diff --git a/modules/apis/src/main/java/com/axway/apim/api/export/impl/ExportHelper.java b/modules/apis/src/main/java/com/axway/apim/api/export/impl/ExportHelper.java index a451a4a78..3d357ba80 100644 --- a/modules/apis/src/main/java/com/axway/apim/api/export/impl/ExportHelper.java +++ b/modules/apis/src/main/java/com/axway/apim/api/export/impl/ExportHelper.java @@ -101,11 +101,11 @@ public void updateMapperFilter(ObjectMapper mapper) { public void writeToConsole(ObjectMapper mapper, List exportAPI) throws AppException { if (exportAPI == null || exportAPI.isEmpty()) return; try { - mapper.enable(SerializationFeature.INDENT_OUTPUT); + // Use ObjectWriter to avoid mutating the shared mapper instance if (exportAPI.size() == 1) - mapper.writeValue(System.out, exportAPI.get(0)); + mapper.writer().with(SerializationFeature.INDENT_OUTPUT).writeValue(System.out, exportAPI.get(0)); else - mapper.writeValue(System.out, exportAPI); + mapper.writer().with(SerializationFeature.INDENT_OUTPUT).writeValue(System.out, exportAPI); } catch (IOException e) { throw new AppException("Problem in writing JSON / Yaml data", ErrorCode.UNXPECTED_ERROR, e); @@ -197,8 +197,8 @@ public void writeSpec(APISpecification apiDef, ExportAPI exportAPI, File localFo public void writeContent(ObjectMapper mapper, ExportAPI exportAPI, File localFolder, String configFile) throws AppException { try { if (!EnvironmentProperties.PRINT_CONFIG_CONSOLE) { - mapper.enable(SerializationFeature.INDENT_OUTPUT); - mapper.writeValue(new File(localFolder.getCanonicalPath() + configFile), exportAPI); + // Use ObjectWriter to avoid mutating the shared mapper instance + mapper.writer().with(SerializationFeature.INDENT_OUTPUT).writeValue(new File(localFolder.getCanonicalPath() + configFile), exportAPI); } } catch (Exception e) { throw new AppException("Can't create API-Configuration file for API: '" + exportAPI.getName() + "' exposed on path: '" + exportAPI.getPath() + "'.", ErrorCode.UNXPECTED_ERROR, e); diff --git a/modules/apis/src/main/java/com/axway/apim/apiimport/APIImportConfigAdapter.java b/modules/apis/src/main/java/com/axway/apim/apiimport/APIImportConfigAdapter.java index cce02ae12..2d15f0aab 100644 --- a/modules/apis/src/main/java/com/axway/apim/apiimport/APIImportConfigAdapter.java +++ b/modules/apis/src/main/java/com/axway/apim/apiimport/APIImportConfigAdapter.java @@ -29,7 +29,7 @@ import com.fasterxml.jackson.databind.module.SimpleModule; import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.StringUtils; -import org.apache.http.entity.ContentType; +import org.apache.hc.core5.http.ContentType; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/modules/apis/src/main/java/com/axway/apim/apiimport/actions/APIQuotaManager.java b/modules/apis/src/main/java/com/axway/apim/apiimport/actions/APIQuotaManager.java index e13fc3df4..53e9cbc94 100644 --- a/modules/apis/src/main/java/com/axway/apim/apiimport/actions/APIQuotaManager.java +++ b/modules/apis/src/main/java/com/axway/apim/apiimport/actions/APIQuotaManager.java @@ -17,6 +17,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; +import java.util.Objects; public class APIQuotaManager { @@ -100,18 +101,17 @@ public List mergeRestriction(List existingRe desiredRestriction.setApiId(null); // Update restriction if actual and desired are same. for (QuotaRestriction existingRestriction : existingRestrictions) { - // It's considered as the same restriction when quota type, method, period & per are equal - if (desiredRestriction.getMethod().equals(existingRestriction.getMethod())) { + // Restrictions are matched by method + type. + if (isSameRestrictionScope(desiredRestriction, existingRestriction)) { mergedRestrictions.remove(existingRestriction); - if(existingRestriction.getType() != desiredRestriction.getType()){ - existingRestriction.setType(desiredRestriction.getType()); - } // If it is the same restriction, we need to update the restriction configuration - if (existingRestriction.getType() == QuotaRestrictionType.throttle) { + if (desiredRestriction.getType() == QuotaRestrictionType.throttle) { + existingRestriction.setType(QuotaRestrictionType.throttle); existingRestriction.getConfig().put(MESSAGES, desiredRestriction.getConfig().get(MESSAGES)); existingRestriction.getConfig().put(PERIOD, desiredRestriction.getConfig().get(PERIOD)); existingRestriction.getConfig().put(PER, desiredRestriction.getConfig().get(PER)); } else { + existingRestriction.setType(QuotaRestrictionType.throttlemb); existingRestriction.getConfig().put(MB, desiredRestriction.getConfig().get(MB)); existingRestriction.getConfig().put(PER, desiredRestriction.getConfig().get(PER)); existingRestriction.getConfig().put(PERIOD, desiredRestriction.getConfig().get(PERIOD)); @@ -121,17 +121,16 @@ public List mergeRestriction(List existingRe } } } - // Add missing desired restrictions to actual restriction for (QuotaRestriction desiredRestriction : desiredRestrictions) { - if (!quotaApiMethodExists(existingRestrictions, desiredRestriction)) { + if (!quotaApiRestrictionExists(existingRestrictions, desiredRestriction)) { mergedRestrictions.add(desiredRestriction); } } // Remove actual restrictions are not found in desired restriction. for (QuotaRestriction existingRestriction : existingRestrictions) { - if (!quotaApiMethodExists(desiredRestrictions, existingRestriction)) { + if (!quotaApiRestrictionExists(desiredRestrictions, existingRestriction)) { mergedRestrictions.remove(existingRestriction); } } @@ -139,15 +138,20 @@ public List mergeRestriction(List existingRe return mergedRestrictions; } - public boolean quotaApiMethodExists(List desiredRestrictions, QuotaRestriction existingRestriction) { + public boolean quotaApiRestrictionExists(List desiredRestrictions, QuotaRestriction existingRestriction) { for (QuotaRestriction desiredRestriction : desiredRestrictions) { - if (desiredRestriction.getMethod().equals(existingRestriction.getMethod())) { + if (isSameRestrictionScope(desiredRestriction, existingRestriction)) { return true; } } return false; } + private boolean isSameRestrictionScope(QuotaRestriction firstRestriction, QuotaRestriction secondRestriction) { + return Objects.equals(firstRestriction.getMethod(), secondRestriction.getMethod()) + && firstRestriction.getType() == secondRestriction.getType(); + } + public void populateMethodId(API createdAPI, List mergedRestrictions) throws AppException { APIManagerAPIMethodAdapter methodAdapter = APIManagerAdapter.getInstance().getMethodAdapter(); diff --git a/modules/apis/src/main/java/com/axway/apim/apiimport/lib/cli/CLIAPIImportOptions.java b/modules/apis/src/main/java/com/axway/apim/apiimport/lib/cli/CLIAPIImportOptions.java index b407e0389..9b8a05773 100644 --- a/modules/apis/src/main/java/com/axway/apim/apiimport/lib/cli/CLIAPIImportOptions.java +++ b/modules/apis/src/main/java/com/axway/apim/apiimport/lib/cli/CLIAPIImportOptions.java @@ -8,6 +8,7 @@ import com.axway.apim.lib.CLIOptions; import com.axway.apim.lib.CoreCLIOptions; import com.axway.apim.lib.CoreParameters.Mode; +import com.axway.apim.lib.CoreParameters.QuotaUpdateMode; import com.axway.apim.lib.Parameters; import com.axway.apim.lib.StandardImportCLIOptions; import com.axway.apim.lib.error.AppException; @@ -73,6 +74,10 @@ public void addOptions() { option.setArgName(IGNORE_REPLACE_ADD); addOption(option); + option = new Option("quotaUpdateMode", true, "Controls how quotas are written to API-Manager. auto uses the per-constraint endpoints if the API-Manager is new enough, legacy always replaces the complete quota document, constraints always uses the per-constraint endpoints. Defaults to auto!"); + option.setArgName("auto|legacy|constraints"); + addOption(option); + option = new Option("validateRemoteHost", true, "Disables the remote host validation which is turned on by default if a remote host is given"); option.setRequired(false); @@ -143,6 +148,7 @@ public Parameters getParams() { params.setClientOrgsMode(Mode.valueOfDefault(getValue("clientOrgsMode"))); params.setClientAppsMode(Mode.valueOfDefault(getValue("clientAppsMode"))); params.setQuotaMode(Mode.valueOfDefault(getValue("quotaMode"))); + params.setQuotaUpdateMode(QuotaUpdateMode.valueOfDefault(getValue("quotaUpdateMode"))); params.setDetailsExportFile(getValue("detailsExportFile")); params.setValidateRemoteHost(Boolean.parseBoolean(getValue("validateRemoteHost"))); params.setZeroDowntimeUpdate(Boolean.parseBoolean(getValue("zeroDowntimeUpdate"))); diff --git a/modules/apis/src/test/java/com/axway/apim/apiimport/actions/APIQuotaManagerTest.java b/modules/apis/src/test/java/com/axway/apim/apiimport/actions/APIQuotaManagerTest.java index 5a6824bc4..811fe98aa 100644 --- a/modules/apis/src/test/java/com/axway/apim/apiimport/actions/APIQuotaManagerTest.java +++ b/modules/apis/src/test/java/com/axway/apim/apiimport/actions/APIQuotaManagerTest.java @@ -269,6 +269,78 @@ public void mergeRestrictionDesiredWithNoActual() throws IOException { Assert.assertEquals(3, result.size()); } + @Test + public void mergeRestrictionWithSameMethodAndDifferentTypes() throws IOException { + String actualQuota = "[\n" + + " {\n" + + " \"api\": \"api-1\",\n" + + " \"method\": \"GET /orders\",\n" + + " \"type\": \"throttle\",\n" + + " \"config\": {\n" + + " \"messages\": \"100\",\n" + + " \"period\": \"minute\",\n" + + " \"per\": \"1\"\n" + + " }\n" + + " },\n" + + " {\n" + + " \"api\": \"api-1\",\n" + + " \"method\": \"GET /orders\",\n" + + " \"type\": \"throttlemb\",\n" + + " \"config\": {\n" + + " \"mb\": \"20\",\n" + + " \"period\": \"day\",\n" + + " \"per\": \"1\"\n" + + " }\n" + + " }\n" + + "]"; + + String desiredQuota = "[\n" + + " {\n" + + " \"api\": \"api-1\",\n" + + " \"method\": \"GET /orders\",\n" + + " \"type\": \"throttle\",\n" + + " \"config\": {\n" + + " \"messages\": \"250\",\n" + + " \"period\": \"minute\",\n" + + " \"per\": \"1\"\n" + + " }\n" + + " },\n" + + " {\n" + + " \"api\": \"api-1\",\n" + + " \"method\": \"GET /orders\",\n" + + " \"type\": \"throttlemb\",\n" + + " \"config\": {\n" + + " \"mb\": \"42\",\n" + + " \"period\": \"day\",\n" + + " \"per\": \"1\"\n" + + " }\n" + + " }\n" + + "]"; + + TypeReference> quotaRestrictionTypeRef = new TypeReference<>() { + }; + List actualQuotaRestriction = objectMapper.readValue(actualQuota, quotaRestrictionTypeRef); + List desiredQuotaRestriction = objectMapper.readValue(desiredQuota, quotaRestrictionTypeRef); + + APIQuotaManager apiQuotaManager = new APIQuotaManager(null, null); + List result = apiQuotaManager.mergeRestriction(actualQuotaRestriction, desiredQuotaRestriction); + + Assert.assertEquals(result.size(), 2); + QuotaRestriction throttle = result.stream() + .filter(restriction -> "GET /orders".equals(restriction.getMethod()) && "throttle".equals(restriction.getType().name())) + .findFirst() + .orElse(null); + QuotaRestriction throttleMb = result.stream() + .filter(restriction -> "GET /orders".equals(restriction.getMethod()) && "throttlemb".equals(restriction.getType().name())) + .findFirst() + .orElse(null); + + Assert.assertNotNull(throttle); + Assert.assertNotNull(throttleMb); + Assert.assertEquals(throttle.getConfig().get("messages"), "250"); + Assert.assertEquals(throttleMb.getConfig().get("mb"), "42"); + } + @Test public void populateMethodIdForNewApi() throws JsonProcessingException { diff --git a/modules/apis/src/test/java/com/axway/apim/changeAction/ChangeBackendTestIT.java b/modules/apis/src/test/java/com/axway/apim/changeAction/ChangeBackendTestIT.java index a13975366..e40390031 100644 --- a/modules/apis/src/test/java/com/axway/apim/changeAction/ChangeBackendTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/changeAction/ChangeBackendTestIT.java @@ -3,7 +3,7 @@ import com.axway.apim.EndpointConfig; import com.axway.apim.test.ImportTestAction; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; @@ -14,11 +14,11 @@ import java.io.IOException; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; import static org.citrusframework.http.actions.HttpActionBuilder.http; import static org.citrusframework.validation.DelegatingPayloadVariableExtractor.Builder.fromBody; -import static org.citrusframework.validation.json.JsonPathMessageValidationContext.Builder.jsonPath; +import static org.citrusframework.validation.context.json.JsonPathMessageValidationContext.Builder.jsonPath; @ContextConfiguration(classes = {EndpointConfig.class}) diff --git a/modules/apis/src/test/java/com/axway/apim/export/test/applications/ApplicationExportTestIT.java b/modules/apis/src/test/java/com/axway/apim/export/test/applications/ApplicationExportTestIT.java index eb001bc01..5e2dab763 100644 --- a/modules/apis/src/test/java/com/axway/apim/export/test/applications/ApplicationExportTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/export/test/applications/ApplicationExportTestIT.java @@ -10,7 +10,7 @@ import org.citrusframework.annotations.CitrusResource; import org.citrusframework.annotations.CitrusTest; import org.citrusframework.context.TestContext; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; @@ -25,7 +25,7 @@ import java.nio.file.Files; import java.util.List; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; import static org.citrusframework.http.actions.HttpActionBuilder.http; import static org.citrusframework.validation.DelegatingPayloadVariableExtractor.Builder.fromBody; @@ -100,7 +100,7 @@ public void run(@Optional @CitrusResource TestContext context) throws IOExceptio assertNull(app.getId(), "The ID of an application shouldn't be exported."); assertNull(app.getAppQuota(), "The application quota should not be exported. It's not supported by the export!"); assertTrue(new File(context.getVariable("exportLocation") + "/" + context.getVariable("exportFolder") + "/swagger.io.crt").exists(), "Certificate swagger.io.crt is missing"); - assertTrue(new File(context.getVariable("exportLocation") + "/" + context.getVariable("exportFolder") + "/AmazonRSA2048M04.crt").exists(), "Certificate StarfieldServicesRootCertificateAuthority-G2.crt is missing"); + assertTrue(new File(context.getVariable("exportLocation") + "/" + context.getVariable("exportFolder") + "/AmazonRSA2048M01.crt").exists(), "Certificate StarfieldServicesRootCertificateAuthority-G2.crt is missing"); assertTrue(new File(context.getVariable("exportLocation") + "/" + context.getVariable("exportFolder") + "/AmazonRootCA1.crt").exists(), "Certificate AmazonRootCA1.crt is missing"); assertTrue(new File(context.getVariable("exportLocation") + "/" + context.getVariable("exportFolder") + "/" + context.getVariable("exportAPIName")).exists(), "Exported Swagger-File is missing"); } diff --git a/modules/apis/src/test/java/com/axway/apim/export/test/basic/CompleteAPIExportTestIT.java b/modules/apis/src/test/java/com/axway/apim/export/test/basic/CompleteAPIExportTestIT.java index 46df6eb86..f8df6d957 100644 --- a/modules/apis/src/test/java/com/axway/apim/export/test/basic/CompleteAPIExportTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/export/test/basic/CompleteAPIExportTestIT.java @@ -10,7 +10,7 @@ import org.citrusframework.annotations.CitrusResource; import org.citrusframework.annotations.CitrusTest; import org.citrusframework.context.TestContext; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; import org.springframework.test.context.ContextConfiguration; import org.testng.annotations.Optional; @@ -22,7 +22,7 @@ import java.util.List; import java.util.Map; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; import static org.citrusframework.actions.SleepAction.Builder.sleep; import static org.testng.Assert.*; diff --git a/modules/apis/src/test/java/com/axway/apim/export/test/basic/DifferentVHostExportTestIT.java b/modules/apis/src/test/java/com/axway/apim/export/test/basic/DifferentVHostExportTestIT.java index a0bc2445c..7e638d222 100644 --- a/modules/apis/src/test/java/com/axway/apim/export/test/basic/DifferentVHostExportTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/export/test/basic/DifferentVHostExportTestIT.java @@ -8,7 +8,7 @@ import org.citrusframework.annotations.CitrusResource; import org.citrusframework.annotations.CitrusTest; import org.citrusframework.context.TestContext; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; import org.springframework.test.context.ContextConfiguration; import org.testng.annotations.Optional; @@ -18,7 +18,7 @@ import java.io.IOException; import java.nio.file.Files; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; import static org.testng.Assert.assertEquals; diff --git a/modules/apis/src/test/java/com/axway/apim/export/test/basic/ImageAPIExportTestIT.java b/modules/apis/src/test/java/com/axway/apim/export/test/basic/ImageAPIExportTestIT.java index b46d0366f..e3cac3d58 100644 --- a/modules/apis/src/test/java/com/axway/apim/export/test/basic/ImageAPIExportTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/export/test/basic/ImageAPIExportTestIT.java @@ -8,7 +8,7 @@ import org.citrusframework.annotations.CitrusResource; import org.citrusframework.annotations.CitrusTest; import org.citrusframework.context.TestContext; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; import org.springframework.test.context.ContextConfiguration; import org.testng.annotations.Optional; @@ -18,7 +18,7 @@ import java.io.IOException; import java.nio.file.Files; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; import static org.testng.Assert.*; @@ -69,7 +69,7 @@ public void run(@Optional @CitrusResource TestContext context) throws IOExceptio assertFalse(exportedAPIConfig.get("caCerts").get(0).get("inbound").asBoolean()); assertTrue(exportedAPIConfig.get("caCerts").get(0).get("outbound").asBoolean()); assertTrue(new File(context.getVariable("exportLocation") + "/" + context.getVariable("exportFolder") + "/swagger.io.crt").exists(), "Certificate swagger.io.crt is missing"); - assertTrue(new File(context.getVariable("exportLocation") + "/" + context.getVariable("exportFolder") + "/AmazonRSA2048M04.crt").exists(), "Certificate StarfieldServicesRootCertificateAuthority-G2.crt is missing"); + assertTrue(new File(context.getVariable("exportLocation") + "/" + context.getVariable("exportFolder") + "/AmazonRSA2048M01.crt").exists(), "Certificate StarfieldServicesRootCertificateAuthority-G2.crt is missing"); assertTrue(new File(context.getVariable("exportLocation") + "/" + context.getVariable("exportFolder") + "/AmazonRootCA1.crt").exists(), "Certificate AmazonRootCA1.crt is missing"); assertTrue(new File(context.getVariable("exportLocation") + "/" + context.getVariable("exportFolder") + "/" + context.getVariable("exportAPIName")).exists(), "Exported Swagger-File is missing"); assertTrue(new File(context.getVariable("exportLocation") + "/" + context.getVariable("exportFolder") + "/api-image.jpg").exists(), "API-Image is missing"); } diff --git a/modules/apis/src/test/java/com/axway/apim/export/test/basic/SimpleAPIExportTestIT.java b/modules/apis/src/test/java/com/axway/apim/export/test/basic/SimpleAPIExportTestIT.java index 6a81ac337..e5583bd43 100644 --- a/modules/apis/src/test/java/com/axway/apim/export/test/basic/SimpleAPIExportTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/export/test/basic/SimpleAPIExportTestIT.java @@ -9,7 +9,7 @@ import org.citrusframework.annotations.CitrusResource; import org.citrusframework.annotations.CitrusTest; import org.citrusframework.context.TestContext; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; @@ -23,9 +23,9 @@ import java.io.IOException; import java.nio.file.Files; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; -import static org.citrusframework.dsl.JsonPathSupport.jsonPath; +import static org.citrusframework.json.dsl.JsonPathSupport.jsonPath; import static org.citrusframework.http.actions.HttpActionBuilder.http; import static org.citrusframework.validation.DelegatingPayloadVariableExtractor.Builder.fromBody; import static org.testng.Assert.*; @@ -99,7 +99,7 @@ public void run(@Optional @CitrusResource TestContext context) throws IOExceptio assertFalse(exportedAPIConfig.get("caCerts").get(0).get("inbound").asBoolean()); assertTrue(exportedAPIConfig.get("caCerts").get(0).get("outbound").asBoolean()); assertTrue(new File(context.getVariable("exportLocation") + "/" + context.getVariable("exportFolder") + "/swagger.io.crt").exists(), "Certificate swagger.io.crt is missing"); - assertTrue(new File(context.getVariable("exportLocation") + "/" + context.getVariable("exportFolder") + "/AmazonRSA2048M04.crt").exists(), "Certificate AmazonRSA2048M04.crt is missing"); + assertTrue(new File(context.getVariable("exportLocation") + "/" + context.getVariable("exportFolder") + "/AmazonRSA2048M01.crt").exists(), "Certificate AmazonRSA2048M04.crt is missing"); assertTrue(new File(context.getVariable("exportLocation") + "/" + context.getVariable("exportFolder") + "/AmazonRootCA1.crt").exists(), "Certificate AmazonRootCA1.crt is missing"); File exportedAPISpecFile = new File(context.getVariable("exportLocation") + "/" + context.getVariable("exportFolder") + "/" + context.getVariable("exportAPIName")); assertTrue(exportedAPISpecFile.exists(), "Exported API-Specification is missing"); diff --git a/modules/apis/src/test/java/com/axway/apim/export/test/basic/WildcardAPIExportTestIT.java b/modules/apis/src/test/java/com/axway/apim/export/test/basic/WildcardAPIExportTestIT.java index b7920b899..c92a3dd72 100644 --- a/modules/apis/src/test/java/com/axway/apim/export/test/basic/WildcardAPIExportTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/export/test/basic/WildcardAPIExportTestIT.java @@ -8,7 +8,7 @@ import org.citrusframework.annotations.CitrusResource; import org.citrusframework.annotations.CitrusTest; import org.citrusframework.context.TestContext; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; import org.springframework.test.context.ContextConfiguration; import org.testng.annotations.Optional; @@ -74,7 +74,6 @@ public void run(@Optional @CitrusResource TestContext context) throws IOExceptio assertEquals(exportedAPIConfig.get("version").asText(), "2.0.0"); assertEquals(exportedAPIConfig.get("organization").asText(), "API Development " + context.getVariable("orgNumber")); - //assertEquals(exportedAPIConfig.get("backendBasepath").asText(), "https://petstore.swagger.io"); assertEquals(exportedAPIConfig.get("state").asText(), "unpublished"); assertEquals(exportedAPIConfig.get("path").asText(), context.getVariable("apiPath1")); assertEquals(exportedAPIConfig.get("name").asText(), context.getVariable("apiName1")); @@ -85,7 +84,7 @@ public void run(@Optional @CitrusResource TestContext context) throws IOExceptio assertTrue(exportedAPIConfig.get("caCerts").get(0).get("outbound").asBoolean()); assertTrue(new File(context.getVariable("exportLocation") + "/" + context.getVariable("exportFolder1") + "/swagger.io.crt").exists(), "Certificate swagger.io.crt is missing"); - assertTrue(new File(context.getVariable("exportLocation") + "/" + context.getVariable("exportFolder1") + "/AmazonRSA2048M04.crt").exists(), "Certificate AmazonRSA2048M04 is missing"); + assertTrue(new File(context.getVariable("exportLocation") + "/" + context.getVariable("exportFolder1") + "/AmazonRSA2048M01.crt").exists(), "Certificate AmazonRSA2048M04 is missing"); assertTrue(new File(context.getVariable("exportLocation") + "/" + context.getVariable("exportFolder1") + "/AmazonRootCA1.crt").exists(), "Certificate AmazonRootCA1.crt is missing"); assertTrue(new File(context.getVariable("exportLocation") + "/" + context.getVariable("exportFolder1") + "/" + context.getVariable("exportAPIName1")).exists(), "Exported Swagger-File is missing"); @@ -106,8 +105,8 @@ public void run(@Optional @CitrusResource TestContext context) throws IOExceptio assertTrue(exportedAPIConfig.get("caCerts").get(0).get("outbound").asBoolean()); assertTrue(new File(context.getVariable("exportLocation") + "/" + context.getVariable("exportFolder2") + "/swagger.io.crt").exists(), "Certificate swagger.io.crt is missing"); - assertTrue(new File(context.getVariable("exportLocation") + "/" + context.getVariable("exportFolder2") + "/AmazonRSA2048M04.crt").exists(), "Certificate StarfieldServicesRootCertificateAuthority-G2.crt is missing"); - assertTrue(new File(context.getVariable("exportLocation") + "/" + context.getVariable("exportFolder2") + "/AmazonRootCA1.crt").exists(), "Certificate AmazonRootCA1.crt is missing"); //assertTrue(new File(context.getVariable("exportLocation")+"/"+context.getVariable("exportFolder2")+"/Amazon.crt").exists(), "Certificate Amazon.crt is missing"); + assertTrue(new File(context.getVariable("exportLocation") + "/" + context.getVariable("exportFolder2") + "/AmazonRSA2048M01.crt").exists(), "Certificate StarfieldServicesRootCertificateAuthority-G2.crt is missing"); + assertTrue(new File(context.getVariable("exportLocation") + "/" + context.getVariable("exportFolder2") + "/AmazonRootCA1.crt").exists(), "Certificate AmazonRootCA1.crt is missing"); assertTrue(new File(context.getVariable("exportLocation") + "/" + context.getVariable("exportFolder2") + "/" + context.getVariable("exportAPIName2")).exists(), "Exported Swagger-File is missing"); } } diff --git a/modules/apis/src/test/java/com/axway/apim/export/test/customPolicies/CustomPoliciesTestIT.java b/modules/apis/src/test/java/com/axway/apim/export/test/customPolicies/CustomPoliciesTestIT.java index 97f004e39..71665656c 100644 --- a/modules/apis/src/test/java/com/axway/apim/export/test/customPolicies/CustomPoliciesTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/export/test/customPolicies/CustomPoliciesTestIT.java @@ -13,7 +13,7 @@ import org.citrusframework.annotations.CitrusResource; import org.citrusframework.annotations.CitrusTest; import org.citrusframework.context.TestContext; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; import org.springframework.test.context.ContextConfiguration; import org.testng.annotations.Optional; @@ -27,7 +27,7 @@ import java.util.List; import java.util.Map; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; import static org.testng.Assert.*; diff --git a/modules/apis/src/test/java/com/axway/apim/export/test/customPolicies/RoutePolicyOnlyTestIT.java b/modules/apis/src/test/java/com/axway/apim/export/test/customPolicies/RoutePolicyOnlyTestIT.java index 3d51b78af..a7009b021 100644 --- a/modules/apis/src/test/java/com/axway/apim/export/test/customPolicies/RoutePolicyOnlyTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/export/test/customPolicies/RoutePolicyOnlyTestIT.java @@ -15,7 +15,7 @@ import org.citrusframework.annotations.CitrusResource; import org.citrusframework.annotations.CitrusTest; import org.citrusframework.context.TestContext; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; import org.springframework.test.context.ContextConfiguration; import org.testng.annotations.Optional; @@ -28,7 +28,7 @@ import java.util.List; import java.util.Map; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; diff --git a/modules/apis/src/test/java/com/axway/apim/export/test/impl/CheckCertificatesTest.java b/modules/apis/src/test/java/com/axway/apim/export/test/impl/CheckCertificatesTest.java index 0ba9fd6ef..5a5f23fb7 100644 --- a/modules/apis/src/test/java/com/axway/apim/export/test/impl/CheckCertificatesTest.java +++ b/modules/apis/src/test/java/com/axway/apim/export/test/impl/CheckCertificatesTest.java @@ -10,8 +10,8 @@ import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.MapperFeature; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.json.JsonMapper; import org.testng.Assert; -import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import java.io.IOException; @@ -22,13 +22,10 @@ public class CheckCertificatesTest { private static final String TEST_PACKAGE = "test/export/files/apiLists/"; - ObjectMapper mapper = new ObjectMapper(); - - - @BeforeClass - public void setTest() { - mapper.disable(MapperFeature.USE_ANNOTATIONS); - } + // ObjectMapper.disable(MapperFeature) was removed in Jackson 2.19+; use builder instead. + ObjectMapper mapper = JsonMapper.builder() + .disable(MapperFeature.USE_ANNOTATIONS) + .build(); @Test public void checkCertNothingAboutToExpire() throws IOException { diff --git a/modules/apis/src/test/java/com/axway/apim/export/test/impl/ConsoleAPIExportTest.java b/modules/apis/src/test/java/com/axway/apim/export/test/impl/ConsoleAPIExportTest.java index 4543040de..8a90d2cc2 100644 --- a/modules/apis/src/test/java/com/axway/apim/export/test/impl/ConsoleAPIExportTest.java +++ b/modules/apis/src/test/java/com/axway/apim/export/test/impl/ConsoleAPIExportTest.java @@ -7,7 +7,7 @@ import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.MapperFeature; import com.fasterxml.jackson.databind.ObjectMapper; -import org.testng.annotations.BeforeClass; +import com.fasterxml.jackson.databind.json.JsonMapper; import org.testng.annotations.Test; import java.io.IOException; @@ -17,13 +17,10 @@ public class ConsoleAPIExportTest { private static final String TEST_PACKAGE = "test/export/files/apiLists/"; - ObjectMapper mapper = new ObjectMapper(); - - - @BeforeClass - public void setTest() { - mapper.disable(MapperFeature.USE_ANNOTATIONS); - } + // ObjectMapper.disable(MapperFeature) was removed in Jackson 2.19+; use builder instead. + ObjectMapper mapper = JsonMapper.builder() + .disable(MapperFeature.USE_ANNOTATIONS) + .build(); @Test public void runStandardConsoleAPIExport() throws IOException { diff --git a/modules/apis/src/test/java/com/axway/apim/export/test/methodLevel/MethodLevelExportTestIT.java b/modules/apis/src/test/java/com/axway/apim/export/test/methodLevel/MethodLevelExportTestIT.java index 96e994a3d..9d44c55fa 100644 --- a/modules/apis/src/test/java/com/axway/apim/export/test/methodLevel/MethodLevelExportTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/export/test/methodLevel/MethodLevelExportTestIT.java @@ -10,7 +10,7 @@ import org.citrusframework.annotations.CitrusResource; import org.citrusframework.annotations.CitrusTest; import org.citrusframework.context.TestContext; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; import org.springframework.test.context.ContextConfiguration; import org.testng.annotations.Optional; @@ -23,7 +23,7 @@ import java.util.List; import java.util.Map; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; import static org.testng.Assert.*; diff --git a/modules/apis/src/test/java/com/axway/apim/test/ApisConfiguration.java b/modules/apis/src/test/java/com/axway/apim/test/ApisConfiguration.java index 1238c1367..174c2eebc 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/ApisConfiguration.java +++ b/modules/apis/src/test/java/com/axway/apim/test/ApisConfiguration.java @@ -1,12 +1,28 @@ package com.axway.apim.test; +import com.axway.apim.EndpointConfig; +import org.citrusframework.container.SequenceBeforeSuite; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Import; @Configuration +@Import(EndpointConfig.class) public class ApisConfiguration { +// @Bean +// public CoreInitializationTestIT coreInitializationTestIT(){ +// return new CoreInitializationTestIT(); +// } + + @Bean + public Setup setup() { + return new Setup(); + } + @Bean - public CoreInitializationTestIT coreInitializationTestIT(){ - return new CoreInitializationTestIT(); + public SequenceBeforeSuite beforeSuite(Setup setup) { + return new SequenceBeforeSuite.Builder() + .actions(setup) + .build(); } } diff --git a/modules/apis/src/test/java/com/axway/apim/test/CoreInitializationTestIT.java b/modules/apis/src/test/java/com/axway/apim/test/CoreInitializationTestIT.java deleted file mode 100644 index 46f3b441b..000000000 --- a/modules/apis/src/test/java/com/axway/apim/test/CoreInitializationTestIT.java +++ /dev/null @@ -1,258 +0,0 @@ -package com.axway.apim.test; - -import com.axway.apim.EndpointConfig; -import com.jayway.jsonpath.DocumentContext; -import com.jayway.jsonpath.JsonPath; -import org.apache.hc.client5.http.classic.HttpClient; -import org.apache.hc.client5.http.classic.methods.HttpGet; -import org.apache.hc.client5.http.classic.methods.HttpPost; -import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse; -import org.apache.hc.core5.http.ContentType; -import org.apache.hc.core5.http.HttpEntity; -import org.apache.hc.core5.http.ParseException; -import org.apache.hc.core5.http.io.entity.EntityUtils; -import org.apache.hc.core5.http.io.entity.StringEntity; -import org.apache.http.client.utils.URIBuilder; -import org.citrusframework.actions.AbstractTestAction; -import org.citrusframework.context.TestContext; -import org.citrusframework.dsl.runner.TestRunner; -import org.citrusframework.dsl.runner.TestRunnerBeforeSuiteSupport; -import org.citrusframework.message.MessageType; -import org.citrusframework.variable.GlobalVariables; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.test.context.ContextConfiguration; - -import java.io.IOException; -import java.net.URI; -import java.net.URISyntaxException; -import java.net.URLEncoder; -import java.nio.charset.StandardCharsets; -import java.util.Base64; - -@ContextConfiguration(classes = {EndpointConfig.class}) - -public class CoreInitializationTestIT extends TestRunnerBeforeSuiteSupport { - - @Autowired - HttpClient httpClient; - - @Autowired - private org.citrusframework.http.client.HttpClient apiManager; - - @Value("${apiManagerHost}") - private String host; - - @Value("${apiManagerPort}") - private int port; - - @Value("${apiManagerUser}") - private String username; - - @Value("${apiManagerPass}") - private String password; - - @Value("${oadminPassword1}") - private String orgAdminPassword; - - @Value("${oadminUsername1}") - private String orgAdminUsername; - - @Autowired - GlobalVariables globalVariables; - - private final static String DEFAULT_PASSWORD = "changeme"; - - - @Override - public void beforeSuite(TestRunner testRunner) { - - String format = username + ":" + DEFAULT_PASSWORD; - String authorizationHeaderValue = "Basic " + Base64.getEncoder().encodeToString(format.getBytes()); - String url = "https://" + host + ":" + port + "/api/portal/v1.4"; - - try { - if (System.getenv("reset_password") != null && System.getenv("reset_password").equalsIgnoreCase("true")) { - testRunner.echo("Change password of user for initial setup"); - postRequest(url + "/currentuser/changepassword", authorizationHeaderValue, password); - format = username + ":" + password; - authorizationHeaderValue = "Basic " + Base64.getEncoder().encodeToString(format.getBytes()); - } - String orgName = URLEncoder.encode((String) globalVariables.getVariables().get("orgName"), StandardCharsets.UTF_8); - String response = getRequest(url + "/organizations?field=name&op=eq&value=" + orgName, authorizationHeaderValue); - DocumentContext documentContext = JsonPath.parse(response); - if (!response.equals("[]")) { - testRunner.echo("Organization ${orgName} Already exists"); - String orgId = documentContext.read("$.[0].id"); - testRunner.variable("orgId", orgId); - } else { - testRunner.echo("Creating Organization ${orgName}"); - testRunner.http(action -> action.client(apiManager) - .send() - .post("/organizations") - .name("orgCreatedRequest") - .header("Content-Type", MediaType.APPLICATION_JSON_VALUE) - .payload("{\"name\": \"${orgName}\", \"description\": \"Test Org ${orgNumber}\", \"enabled\": true, \"development\": true }")); - testRunner.echo("####### Validate Test-Organisation: ${orgName} has been created #######"); - testRunner.http(action -> action.client(apiManager) - .receive() - .response(HttpStatus.CREATED) - .messageType(MessageType.JSON) - .validate("$.name", "${orgName}") - .extractFromPayload("$.id", "orgId")); - testRunner.echo("####### Extracted organization id: ${orgId} as attribute: orgId #######"); - } - - testRunner.echo("Creating second organization"); - String orgName2 = URLEncoder.encode((String) globalVariables.getVariables().get("orgName2"), StandardCharsets.UTF_8); - response = getRequest(url + "/organizations?field=name&op=eq&value=" + orgName2, authorizationHeaderValue); - if (!response.equals("[]")) { - testRunner.echo("Organization ${orgName2} Already exists"); - documentContext = JsonPath.parse(response); - String orgId = documentContext.read("$.[0].id"); - testRunner.variable("orgId2", orgId); - } else { - testRunner.echo("Creating Organization ${orgName2}"); - testRunner.http(action -> action.client(apiManager) - .send() - .post("/organizations") - .name("orgCreatedRequest") - .header("Content-Type", MediaType.APPLICATION_JSON_VALUE) - .payload("{\"name\": \"${orgName2}\", \"description\": \"Test Org 2\", \"enabled\": true, \"development\": true }")); - testRunner.echo("####### Validate Test-Organisation: ${orgName} has been created #######"); - testRunner.http(action -> action.client(apiManager) - .receive() - .response(HttpStatus.CREATED) - .messageType(MessageType.JSON) - .validate("$.name", "${orgName2}") - .extractFromPayload("$.id", "orgId2")); - testRunner.echo("####### Extracted organization id: ${orgId2} as attribute: orgId2 #######"); - } - - testRunner.echo("Creating third organization"); - String orgName3 = URLEncoder.encode((String) globalVariables.getVariables().get("orgName3"), StandardCharsets.UTF_8); - response = getRequest(url + "/organizations?field=name&op=eq&value=" + orgName3, authorizationHeaderValue); - if (!response.equals("[]")) { - testRunner.echo("Organization ${orgName3} Already exists"); - documentContext = JsonPath.parse(response); - String orgId = documentContext.read("$.[0].id"); - testRunner.variable("orgId3", orgId); - } else { - testRunner.echo("Creating Organization ${orgName3}"); - testRunner.http(action -> action.client(apiManager) - .send() - .post("/organizations") - .name("orgCreatedRequest") - .header("Content-Type", MediaType.APPLICATION_JSON_VALUE) - .payload("{\"name\": \"${orgName3}\", \"description\": \"Test Org 3\", \"enabled\": true, \"development\": true }")); - testRunner.echo("####### Validate Test-Organisation: ${orgName} has been created #######"); - testRunner.http(action -> action.client(apiManager) - .receive() - .response(HttpStatus.CREATED) - .messageType(MessageType.JSON) - .validate("$.name", "${orgName3}") - .extractFromPayload("$.id", "orgId3")); - testRunner.echo("####### Extracted organization id: ${orgId3} as attribute: orgId2 #######"); - } - String userName = (String) globalVariables.getVariables().get("oadminUsername1"); - response = getRequest(url + "/users?field=loginName&op=eq&value=" + userName, authorizationHeaderValue); - if (!response.equals("[]")) { - testRunner.echo("User Already exists"); - documentContext = JsonPath.parse(response); - String userId = documentContext.read("$.[0].id"); - testRunner.variable("oadminUserId1", userId); - } else { - testRunner.echo("Creating oadmin user ${oadminUsername1}"); - testRunner.http(action -> action.client(apiManager) - .send() - .post("/users") - .header("Content-Type", "application/json") - .payload("{\"enabled\":true,\"loginName\":\"${oadminUsername1}\",\"name\":\"Anna Owen ${orgNumber}\",\"email\":\"anna-${orgNumber}@axway.com\",\"role\":\"oadmin\",\"organizationId\":\"${orgId}\"}")); - testRunner.http(action -> action.client(apiManager).receive().response(HttpStatus.CREATED).messageType(MessageType.JSON) - .extractFromPayload("$.id", "oadminUserId1") - .extractFromPayload("$.loginName", "oadminUsername1")); - testRunner.echo("Updating password for oadmin user ${oadminUsername1}"); - testRunner.http(action -> action.client(apiManager).send() - .post("/users/${oadminUserId1}/changepassword/") - .header("Content-Type", "application/x-www-form-urlencoded") - .payload("newPassword="+DEFAULT_PASSWORD)); - testRunner.http(action -> action.client(apiManager).receive().response(HttpStatus.NO_CONTENT)); - String orgAdminformat = orgAdminUsername + ":" + DEFAULT_PASSWORD; - String orgAdminAuthorizationHeaderValue = "Basic " + Base64.getEncoder().encodeToString(orgAdminformat.getBytes()); - postRequest(url + "/currentuser/changepassword", orgAdminAuthorizationHeaderValue, orgAdminPassword); - } - String appName = (String) globalVariables.getVariables().get("testAppName"); - response = getRequest(url + "/applications?field=name&op=eq&value=" + appName, authorizationHeaderValue); - if (!response.equals("[]")) { - documentContext = JsonPath.parse(response); - testRunner.echo("Application Already exists"); - String testAppId = documentContext.read("$.[0].id"); - testRunner.variable("testAppId", testAppId); - - } else { - testRunner.http(action -> action.client(apiManager) - .send() - .post("/applications") - .name("createApplication") - .header("Content-Type", "application/json") - .payload("{\"name\":\"${testAppName}\",\"apis\":[],\"organizationId\":\"${orgId}\"}")); - - testRunner.http(action -> action.client(apiManager) - .receive() - .response(HttpStatus.CREATED) - .messageType(MessageType.JSON) - .extractFromPayload("$.id", "testAppId") - .extractFromPayload("$.name", "testAppName")); - testRunner.echo("####### Created a application: '${testAppName}' ID: '${testAppId}' (testAppName/testAppId) #######"); - - } - // Adjusting the API-Manager config in preparation to run integration tests - - testRunner.run(new AbstractTestAction() { - @Override - public void doExecute(TestContext testContext) { - globalVariables.getVariables().put("orgId", testContext.getVariable("orgId")); - globalVariables.getVariables().put("orgId2", testContext.getVariable("orgId2")); - globalVariables.getVariables().put("orgId3", testContext.getVariable("orgId3")); - globalVariables.getVariables().put("testAppId", testContext.getVariable("testAppId")); - globalVariables.getVariables().put("oadminUserId1", testContext.getVariable("oadminUserId1")); - } - }); - - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - public String getRequest(String url, String authorizationHeaderValue) { - HttpGet httpGet = new HttpGet(url); - httpGet.setHeader(HttpHeaders.AUTHORIZATION, authorizationHeaderValue); - try (CloseableHttpResponse response = (CloseableHttpResponse) httpClient.execute(httpGet)) { - return EntityUtils.toString(response.getEntity()); - } catch (IOException | ParseException e) { - throw new RuntimeException(e); - } - } - - public void postRequest(String url, String authorizationHeaderValue, String newPassword) throws URISyntaxException { - URI uri = new URIBuilder(url).build(); - HttpEntity entity = new StringEntity("newPassword=" + newPassword + "&oldPassword=" + DEFAULT_PASSWORD, ContentType.APPLICATION_FORM_URLENCODED); - HttpPost post = new HttpPost(uri); - post.setEntity(entity); - post.setHeader(HttpHeaders.AUTHORIZATION, authorizationHeaderValue); - - try (CloseableHttpResponse response = (CloseableHttpResponse) httpClient.execute(post)) { - int statusCode = response.getCode(); - if (statusCode != 204) { - throw new RuntimeException("Error changing password of user. Response-Code: " + EntityUtils.toString(response.getEntity())); - } - - - } catch (IOException | ParseException e) { - throw new RuntimeException(e); - } - } -} diff --git a/modules/apis/src/test/java/com/axway/apim/test/Setup.java b/modules/apis/src/test/java/com/axway/apim/test/Setup.java new file mode 100644 index 000000000..5c1b05db3 --- /dev/null +++ b/modules/apis/src/test/java/com/axway/apim/test/Setup.java @@ -0,0 +1,191 @@ +package com.axway.apim.test; + +import com.jayway.jsonpath.DocumentContext; +import com.jayway.jsonpath.JsonPath; +import org.apache.hc.client5.http.classic.HttpClient; +import org.apache.hc.client5.http.classic.methods.HttpGet; +import org.apache.hc.client5.http.classic.methods.HttpPost; +import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse; +import org.apache.hc.core5.http.ContentType; +import org.apache.hc.core5.http.HttpEntity; +import org.apache.hc.core5.http.ParseException; +import org.apache.hc.core5.http.io.entity.EntityUtils; +import org.apache.hc.core5.http.io.entity.StringEntity; +import org.apache.hc.core5.net.URIBuilder; +import org.citrusframework.actions.AbstractTestAction; +import org.citrusframework.context.TestContext; +import org.citrusframework.variable.GlobalVariables; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.http.HttpHeaders; + +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.Base64; + +public class Setup extends AbstractTestAction { + + private static final Logger LOG = LoggerFactory.getLogger(Setup.class); + + + @Autowired + HttpClient httpClient; + + @Value("${apiManagerHost}") + private String host; + + @Value("${apiManagerPort}") + private int port; + + @Value("${apiManagerUser}") + private String username; + + @Value("${apiManagerPass}") + private String password; + + @Value("${oadminPassword1}") + private String orgAdminPassword; + + @Value("${oadminUsername1}") + private String orgAdminUsername; + + @Autowired + GlobalVariables globalVariables; + + private static String DEFAULT_PASSWORD = "changeme"; + + + @Override + public void doExecute(TestContext context) { + + + if( System.getenv("reset_password") == null){ + DEFAULT_PASSWORD = password; + } + + String format = username + ":" + DEFAULT_PASSWORD; + String authorizationHeaderValue = "Basic " + Base64.getEncoder().encodeToString(format.getBytes()); + String url = "https://" + host + ":" + port + "/api/portal/v1.4"; + + try { + if (System.getenv("reset_password") != null && System.getenv("reset_password").equalsIgnoreCase("true")) { + LOG.info("Change password of user for initial setup"); + postRequest(url + "/currentuser/changepassword", authorizationHeaderValue, password); + format = username + ":" + password; + authorizationHeaderValue = "Basic " + Base64.getEncoder().encodeToString(format.getBytes()); + } + String orgNumber = (String) globalVariables.getVariables().get("orgNumber"); + String orgName = (String) globalVariables.getVariables().get("orgName"); + String orgId = resolveOrCreateOrganization(url, authorizationHeaderValue, orgName, + "Test Org " + orgNumber); + globalVariables.getVariables().put("orgId", orgId); + + LOG.info("Creating second organization"); + String orgName2 = (String) globalVariables.getVariables().get("orgName2"); + String orgId2 = resolveOrCreateOrganization(url, authorizationHeaderValue, orgName2, "Test Org 2"); + globalVariables.getVariables().put("orgId2", orgId2); + + LOG.info("Creating third organization"); + String orgName3 = (String) globalVariables.getVariables().get("orgName3"); + String orgId3 = resolveOrCreateOrganization(url, authorizationHeaderValue, orgName3, "Test Org 3"); + globalVariables.getVariables().put("orgId3", orgId3); + + String userName = (String) globalVariables.getVariables().get("oadminUsername1"); + String response = getRequest(url + "/users?field=loginName&op=eq&value=" + userName, authorizationHeaderValue); + String oadminUserId1; + if (!response.equals("[]")) { + LOG.info("User Already exists"); + oadminUserId1 = JsonPath.parse(response).read("$.[0].id"); + } else { + LOG.info("Creating oadmin user {}", orgAdminUsername); + String userPayload = "{\"enabled\":true,\"loginName\":\"" + orgAdminUsername + "\",\"name\":\"Anna Owen " + orgNumber + "\"," + + "\"email\":\"anna-" + orgNumber + "@axway.com\",\"role\":\"oadmin\",\"organizationId\":\"" + orgId + "\"}"; + String userResponse = createEntity(url + "/users", authorizationHeaderValue, userPayload, 201); + DocumentContext userDocument = JsonPath.parse(userResponse); + oadminUserId1 = userDocument.read("$.id"); + + LOG.info("Updating password for oadmin user {}", orgAdminUsername); + postRequest(url + "/users/" + oadminUserId1 + "/changepassword/", authorizationHeaderValue, DEFAULT_PASSWORD); + String orgAdminFormat = orgAdminUsername + ":" + DEFAULT_PASSWORD; + String orgAdminAuthorizationHeaderValue = "Basic " + Base64.getEncoder().encodeToString(orgAdminFormat.getBytes()); + postRequest(url + "/currentuser/changepassword", orgAdminAuthorizationHeaderValue, orgAdminPassword); + } + globalVariables.getVariables().put("oadminUserId1", oadminUserId1); + + String appName = (String) globalVariables.getVariables().get("testAppName"); + response = getRequest(url + "/applications?field=name&op=eq&value=" + appName, authorizationHeaderValue); + String testAppId; + if (!response.equals("[]")) { + LOG.info("Application Already exists"); + testAppId = JsonPath.parse(response).read("$.[0].id"); + } else { + String appPayload = "{\"name\":\"" + appName + "\",\"apis\":[],\"organizationId\":\"" + orgId + "\"}"; + String appResponse = createEntity(url + "/applications", authorizationHeaderValue, appPayload, 201); + testAppId = JsonPath.parse(appResponse).read("$.id"); + LOG.info("Created a application: '{}' ID: '{}'", appName, testAppId); + } + globalVariables.getVariables().put("testAppId", testAppId); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + /** + * Looks up an organization by name and returns its ID, creating it first if it doesn't exist yet. + */ + private String resolveOrCreateOrganization(String url, String authorizationHeaderValue, String orgName, String description) throws IOException, ParseException, URISyntaxException { + String encodedOrgName = URLEncoder.encode(orgName, StandardCharsets.UTF_8); + String response = getRequest(url + "/organizations?field=name&op=eq&value=" + encodedOrgName, authorizationHeaderValue); + if (!response.equals("[]")) { + LOG.info("Organization {} already exists", orgName); + return JsonPath.parse(response).read("$.[0].id"); + } + LOG.info("Creating Organization {}", orgName); + String payload = "{\"name\": \"" + orgName + "\", \"description\": \"" + description + "\", \"enabled\": true, \"development\": true }"; + String orgResponse = createEntity(url + "/organizations", authorizationHeaderValue, payload, 201); + return JsonPath.parse(orgResponse).read("$.id"); + } + + private String createEntity(String url, String authorizationHeaderValue, String jsonPayload, int expectedStatusCode) throws IOException, ParseException, URISyntaxException { + URI uri = new URIBuilder(url).build(); + HttpEntity entity = new StringEntity(jsonPayload, ContentType.APPLICATION_JSON); + HttpPost post = new HttpPost(uri); + post.setEntity(entity); + post.setHeader(HttpHeaders.AUTHORIZATION, authorizationHeaderValue); + try (CloseableHttpResponse response = (CloseableHttpResponse) httpClient.execute(post)) { + String body = EntityUtils.toString(response.getEntity()); + if (response.getCode() != expectedStatusCode) { + throw new RuntimeException("Error creating entity at " + url + ". Response-Code: " + response.getCode() + " Response Body: " + body); + } + return body; + } + } + + public String getRequest(String url, String authorizationHeaderValue) throws IOException, ParseException { + HttpGet httpGet = new HttpGet(url); + httpGet.setHeader(HttpHeaders.AUTHORIZATION, authorizationHeaderValue); + try (CloseableHttpResponse response = (CloseableHttpResponse) httpClient.execute(httpGet)) { + return EntityUtils.toString(response.getEntity()); + } + } + + public void postRequest(String url, String authorizationHeaderValue, String newPassword) throws URISyntaxException, IOException, ParseException { + URI uri = new URIBuilder(url).build(); + HttpEntity entity = new StringEntity("newPassword=" + newPassword + "&oldPassword=" + DEFAULT_PASSWORD, ContentType.APPLICATION_FORM_URLENCODED); + HttpPost post = new HttpPost(uri); + post.setEntity(entity); + post.setHeader(HttpHeaders.AUTHORIZATION, authorizationHeaderValue); + + try (CloseableHttpResponse response = (CloseableHttpResponse) httpClient.execute(post)) { + int statusCode = response.getCode(); + if (statusCode != 204) { + throw new RuntimeException("Error changing password of user. Response-Code: " + EntityUtils.toString(response.getEntity())); + } + } + } +} diff --git a/modules/apis/src/test/java/com/axway/apim/test/apimethods/ExportApiMethodsIT.java b/modules/apis/src/test/java/com/axway/apim/test/apimethods/ExportApiMethodsIT.java index 6ec067ae8..a62a5ee90 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/apimethods/ExportApiMethodsIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/apimethods/ExportApiMethodsIT.java @@ -8,7 +8,7 @@ import org.citrusframework.annotations.CitrusResource; import org.citrusframework.annotations.CitrusTest; import org.citrusframework.context.TestContext; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; import org.springframework.beans.factory.annotation.Autowired; @@ -21,7 +21,7 @@ import java.io.IOException; import java.util.ArrayList; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; import static org.testng.Assert.assertEquals; diff --git a/modules/apis/src/test/java/com/axway/apim/test/apimethods/ImportApiMethodsWithTagsIT.java b/modules/apis/src/test/java/com/axway/apim/test/apimethods/ImportApiMethodsWithTagsIT.java index 5f40ca2f3..25067ef84 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/apimethods/ImportApiMethodsWithTagsIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/apimethods/ImportApiMethodsWithTagsIT.java @@ -8,7 +8,7 @@ import org.citrusframework.annotations.CitrusResource; import org.citrusframework.annotations.CitrusTest; import org.citrusframework.context.TestContext; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; import org.springframework.beans.factory.annotation.Autowired; diff --git a/modules/apis/src/test/java/com/axway/apim/test/applications/APIRevokeApplicationTestIT.java b/modules/apis/src/test/java/com/axway/apim/test/applications/APIRevokeApplicationTestIT.java index 3f07dfdfa..9c09b8a33 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/applications/APIRevokeApplicationTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/applications/APIRevokeApplicationTestIT.java @@ -5,7 +5,7 @@ import com.axway.apim.test.ImportTestAction; import org.citrusframework.annotations.CitrusTest; import org.citrusframework.exceptions.ValidationException; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; @@ -16,9 +16,9 @@ import org.springframework.test.context.ContextConfiguration; import org.testng.annotations.Test; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; -import static org.citrusframework.dsl.JsonPathSupport.jsonPath; +import static org.citrusframework.json.dsl.JsonPathSupport.jsonPath; import static org.citrusframework.http.actions.HttpActionBuilder.http; import static org.citrusframework.validation.DelegatingPayloadVariableExtractor.Builder.fromBody; diff --git a/modules/apis/src/test/java/com/axway/apim/test/applications/AppSubModeAddTestIT.java b/modules/apis/src/test/java/com/axway/apim/test/applications/AppSubModeAddTestIT.java index 076595051..bce0f8f53 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/applications/AppSubModeAddTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/applications/AppSubModeAddTestIT.java @@ -4,7 +4,7 @@ import com.axway.apim.lib.CoreParameters.Mode; import com.axway.apim.test.ImportTestAction; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; @@ -12,9 +12,9 @@ import org.springframework.http.HttpStatus; import org.springframework.test.context.ContextConfiguration; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; -import static org.citrusframework.dsl.JsonPathSupport.jsonPath; +import static org.citrusframework.json.dsl.JsonPathSupport.jsonPath; import static org.citrusframework.http.actions.HttpActionBuilder.http; import static org.citrusframework.validation.DelegatingPayloadVariableExtractor.Builder.fromBody; diff --git a/modules/apis/src/test/java/com/axway/apim/test/applications/AppSubscriptionALLOrgsTestIT.java b/modules/apis/src/test/java/com/axway/apim/test/applications/AppSubscriptionALLOrgsTestIT.java index 78683bc0d..e3dfe2650 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/applications/AppSubscriptionALLOrgsTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/applications/AppSubscriptionALLOrgsTestIT.java @@ -3,7 +3,7 @@ import com.axway.apim.EndpointConfig; import com.axway.apim.test.ImportTestAction; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; @@ -12,9 +12,9 @@ import org.springframework.test.context.ContextConfiguration; import org.testng.annotations.Test; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; -import static org.citrusframework.dsl.JsonPathSupport.jsonPath; +import static org.citrusframework.json.dsl.JsonPathSupport.jsonPath; import static org.citrusframework.http.actions.HttpActionBuilder.http; import static org.citrusframework.validation.DelegatingPayloadVariableExtractor.Builder.fromBody; diff --git a/modules/apis/src/test/java/com/axway/apim/test/applications/AppSubscriptionUnpublishedTestIT.java b/modules/apis/src/test/java/com/axway/apim/test/applications/AppSubscriptionUnpublishedTestIT.java index e9bafef2a..1e4253da4 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/applications/AppSubscriptionUnpublishedTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/applications/AppSubscriptionUnpublishedTestIT.java @@ -3,7 +3,7 @@ import com.axway.apim.EndpointConfig; import com.axway.apim.test.ImportTestAction; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; @@ -12,9 +12,9 @@ import org.springframework.test.context.ContextConfiguration; import org.testng.annotations.Test; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; -import static org.citrusframework.dsl.JsonPathSupport.jsonPath; +import static org.citrusframework.json.dsl.JsonPathSupport.jsonPath; import static org.citrusframework.http.actions.HttpActionBuilder.http; import static org.citrusframework.validation.DelegatingPayloadVariableExtractor.Builder.fromBody; diff --git a/modules/apis/src/test/java/com/axway/apim/test/applications/ApplicationSubscriptionNoOrgsTestIT.java b/modules/apis/src/test/java/com/axway/apim/test/applications/ApplicationSubscriptionNoOrgsTestIT.java index ec775cca2..5e7189a13 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/applications/ApplicationSubscriptionNoOrgsTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/applications/ApplicationSubscriptionNoOrgsTestIT.java @@ -3,7 +3,7 @@ import com.axway.apim.EndpointConfig; import com.axway.apim.test.ImportTestAction; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; @@ -12,9 +12,9 @@ import org.springframework.test.context.ContextConfiguration; import org.testng.annotations.Test; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; -import static org.citrusframework.dsl.JsonPathSupport.jsonPath; +import static org.citrusframework.json.dsl.JsonPathSupport.jsonPath; import static org.citrusframework.http.actions.HttpActionBuilder.http; import static org.citrusframework.validation.DelegatingPayloadVariableExtractor.Builder.fromBody; diff --git a/modules/apis/src/test/java/com/axway/apim/test/applications/ApplicationSubscriptionTestIT.java b/modules/apis/src/test/java/com/axway/apim/test/applications/ApplicationSubscriptionTestIT.java index 947665fec..2a635d5e8 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/applications/ApplicationSubscriptionTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/applications/ApplicationSubscriptionTestIT.java @@ -4,7 +4,7 @@ import com.axway.apim.lib.CoreParameters.Mode; import com.axway.apim.test.ImportTestAction; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; @@ -15,9 +15,9 @@ import java.io.IOException; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; -import static org.citrusframework.dsl.JsonPathSupport.jsonPath; +import static org.citrusframework.json.dsl.JsonPathSupport.jsonPath; import static org.citrusframework.http.actions.HttpActionBuilder.http; import static org.citrusframework.validation.DelegatingPayloadVariableExtractor.Builder.fromBody; diff --git a/modules/apis/src/test/java/com/axway/apim/test/applications/DuplicateApplicationSubscriptionTestIT.java b/modules/apis/src/test/java/com/axway/apim/test/applications/DuplicateApplicationSubscriptionTestIT.java index afe7120a1..38cf34995 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/applications/DuplicateApplicationSubscriptionTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/applications/DuplicateApplicationSubscriptionTestIT.java @@ -3,7 +3,7 @@ import com.axway.apim.EndpointConfig; import com.axway.apim.test.ImportTestAction; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; @@ -14,9 +14,9 @@ import java.io.IOException; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; -import static org.citrusframework.dsl.JsonPathSupport.jsonPath; +import static org.citrusframework.json.dsl.JsonPathSupport.jsonPath; import static org.citrusframework.http.actions.HttpActionBuilder.http; import static org.citrusframework.validation.DelegatingPayloadVariableExtractor.Builder.fromBody; diff --git a/modules/apis/src/test/java/com/axway/apim/test/applications/IgnoreClientAppsTestIT.java b/modules/apis/src/test/java/com/axway/apim/test/applications/IgnoreClientAppsTestIT.java index e50000411..aa54c6868 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/applications/IgnoreClientAppsTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/applications/IgnoreClientAppsTestIT.java @@ -4,7 +4,7 @@ import com.axway.apim.lib.CoreParameters.Mode; import com.axway.apim.test.ImportTestAction; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; @@ -13,9 +13,9 @@ import org.springframework.test.context.ContextConfiguration; import org.testng.annotations.Test; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; -import static org.citrusframework.dsl.JsonPathSupport.jsonPath; +import static org.citrusframework.json.dsl.JsonPathSupport.jsonPath; import static org.citrusframework.http.actions.HttpActionBuilder.http; import static org.citrusframework.validation.DelegatingPayloadVariableExtractor.Builder.fromBody; diff --git a/modules/apis/src/test/java/com/axway/apim/test/applications/ReplaceOrgPermissionsWithSubscribedAppsTestIT.java b/modules/apis/src/test/java/com/axway/apim/test/applications/ReplaceOrgPermissionsWithSubscribedAppsTestIT.java index 0a86607a8..6e5e8d5fe 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/applications/ReplaceOrgPermissionsWithSubscribedAppsTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/applications/ReplaceOrgPermissionsWithSubscribedAppsTestIT.java @@ -4,7 +4,7 @@ import com.axway.apim.lib.CoreParameters.Mode; import com.axway.apim.test.ImportTestAction; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; @@ -13,9 +13,9 @@ import org.springframework.test.context.ContextConfiguration; import org.testng.annotations.Test; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; -import static org.citrusframework.dsl.JsonPathSupport.jsonPath; +import static org.citrusframework.json.dsl.JsonPathSupport.jsonPath; import static org.citrusframework.http.actions.HttpActionBuilder.http; import static org.citrusframework.validation.DelegatingPayloadVariableExtractor.Builder.fromBody; diff --git a/modules/apis/src/test/java/com/axway/apim/test/applications/SubscriptionAppInUngrantedOrgTestIT.java b/modules/apis/src/test/java/com/axway/apim/test/applications/SubscriptionAppInUngrantedOrgTestIT.java index eda9ad646..d861caa0a 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/applications/SubscriptionAppInUngrantedOrgTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/applications/SubscriptionAppInUngrantedOrgTestIT.java @@ -3,7 +3,7 @@ import com.axway.apim.EndpointConfig; import com.axway.apim.test.ImportTestAction; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; @@ -12,9 +12,9 @@ import org.springframework.test.context.ContextConfiguration; import org.testng.annotations.Test; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; -import static org.citrusframework.dsl.JsonPathSupport.jsonPath; +import static org.citrusframework.json.dsl.JsonPathSupport.jsonPath; import static org.citrusframework.http.actions.HttpActionBuilder.http; import static org.citrusframework.validation.DelegatingPayloadVariableExtractor.Builder.fromBody; diff --git a/modules/apis/src/test/java/com/axway/apim/test/applications/UpdateOrgsAndAppsDuringReCreationTestIT.java b/modules/apis/src/test/java/com/axway/apim/test/applications/UpdateOrgsAndAppsDuringReCreationTestIT.java index 2f6baca97..1c9c1287b 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/applications/UpdateOrgsAndAppsDuringReCreationTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/applications/UpdateOrgsAndAppsDuringReCreationTestIT.java @@ -3,7 +3,7 @@ import com.axway.apim.EndpointConfig; import com.axway.apim.test.ImportTestAction; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; @@ -12,9 +12,9 @@ import org.springframework.test.context.ContextConfiguration; import org.testng.annotations.Test; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; -import static org.citrusframework.dsl.JsonPathSupport.jsonPath; +import static org.citrusframework.json.dsl.JsonPathSupport.jsonPath; import static org.citrusframework.http.actions.HttpActionBuilder.http; import static org.citrusframework.validation.DelegatingPayloadVariableExtractor.Builder.fromBody; diff --git a/modules/apis/src/test/java/com/axway/apim/test/basic/BackToPublishedFromDeprecatedTestIT.java b/modules/apis/src/test/java/com/axway/apim/test/basic/BackToPublishedFromDeprecatedTestIT.java index f47a652e3..494e01232 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/basic/BackToPublishedFromDeprecatedTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/basic/BackToPublishedFromDeprecatedTestIT.java @@ -3,7 +3,7 @@ import com.axway.apim.EndpointConfig; import com.axway.apim.test.ImportTestAction; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; @@ -20,9 +20,9 @@ import java.util.Locale; import java.util.TimeZone; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; -import static org.citrusframework.dsl.JsonPathSupport.jsonPath; +import static org.citrusframework.json.dsl.JsonPathSupport.jsonPath; import static org.citrusframework.http.actions.HttpActionBuilder.http; import static org.citrusframework.validation.DelegatingPayloadVariableExtractor.Builder.fromBody; diff --git a/modules/apis/src/test/java/com/axway/apim/test/basic/ImportUnpublishedSetToPublishedAPITestIT.java b/modules/apis/src/test/java/com/axway/apim/test/basic/ImportUnpublishedSetToPublishedAPITestIT.java index 8ed5e57e2..fd0f4e881 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/basic/ImportUnpublishedSetToPublishedAPITestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/basic/ImportUnpublishedSetToPublishedAPITestIT.java @@ -3,7 +3,7 @@ import com.axway.apim.EndpointConfig; import com.axway.apim.test.ImportTestAction; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; @@ -14,9 +14,9 @@ import java.io.IOException; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; -import static org.citrusframework.dsl.JsonPathSupport.jsonPath; +import static org.citrusframework.json.dsl.JsonPathSupport.jsonPath; import static org.citrusframework.http.actions.HttpActionBuilder.http; import static org.citrusframework.validation.DelegatingPayloadVariableExtractor.Builder.fromBody; diff --git a/modules/apis/src/test/java/com/axway/apim/test/basic/IntiallyPublishedAPITestIT.java b/modules/apis/src/test/java/com/axway/apim/test/basic/IntiallyPublishedAPITestIT.java index 87b0319d7..9e7d59bfc 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/basic/IntiallyPublishedAPITestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/basic/IntiallyPublishedAPITestIT.java @@ -3,7 +3,7 @@ import com.axway.apim.EndpointConfig; import com.axway.apim.test.ImportTestAction; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; @@ -14,9 +14,9 @@ import java.io.IOException; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; -import static org.citrusframework.dsl.JsonPathSupport.jsonPath; +import static org.citrusframework.json.dsl.JsonPathSupport.jsonPath; import static org.citrusframework.http.actions.HttpActionBuilder.http; diff --git a/modules/apis/src/test/java/com/axway/apim/test/basic/NoAPIDefinitionConfiguredIT.java b/modules/apis/src/test/java/com/axway/apim/test/basic/NoAPIDefinitionConfiguredIT.java index 04bc2d0d6..11ec961eb 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/basic/NoAPIDefinitionConfiguredIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/basic/NoAPIDefinitionConfiguredIT.java @@ -4,14 +4,14 @@ import com.axway.apim.lib.error.ErrorCode; import com.axway.apim.test.ImportTestAction; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; import org.springframework.test.context.ContextConfiguration; import org.testng.annotations.Test; import java.io.IOException; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; diff --git a/modules/apis/src/test/java/com/axway/apim/test/basic/NoChangeAPITestIT.java b/modules/apis/src/test/java/com/axway/apim/test/basic/NoChangeAPITestIT.java index 327bec805..57612e432 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/basic/NoChangeAPITestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/basic/NoChangeAPITestIT.java @@ -3,7 +3,7 @@ import com.axway.apim.EndpointConfig; import com.axway.apim.test.ImportTestAction; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; @@ -15,11 +15,11 @@ import java.io.IOException; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; import static org.citrusframework.http.actions.HttpActionBuilder.http; import static org.citrusframework.validation.DelegatingPayloadVariableExtractor.Builder.fromBody; -import static org.citrusframework.validation.json.JsonPathMessageValidationContext.Builder.jsonPath; +import static org.citrusframework.validation.context.json.JsonPathMessageValidationContext.Builder.jsonPath; @ContextConfiguration(classes = {EndpointConfig.class}) diff --git a/modules/apis/src/test/java/com/axway/apim/test/basic/PublishedSubscribeUpgradeAccessAPITestIT.java b/modules/apis/src/test/java/com/axway/apim/test/basic/PublishedSubscribeUpgradeAccessAPITestIT.java index c07f9952f..8aad4817c 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/basic/PublishedSubscribeUpgradeAccessAPITestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/basic/PublishedSubscribeUpgradeAccessAPITestIT.java @@ -3,7 +3,7 @@ import com.axway.apim.EndpointConfig; import com.axway.apim.test.ImportTestAction; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; @@ -14,9 +14,9 @@ import java.io.IOException; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; -import static org.citrusframework.dsl.JsonPathSupport.jsonPath; +import static org.citrusframework.json.dsl.JsonPathSupport.jsonPath; import static org.citrusframework.http.actions.HttpActionBuilder.http; import static org.citrusframework.validation.DelegatingPayloadVariableExtractor.Builder.fromBody; diff --git a/modules/apis/src/test/java/com/axway/apim/test/basic/SpecialCharactersAPITestIT.java b/modules/apis/src/test/java/com/axway/apim/test/basic/SpecialCharactersAPITestIT.java index ea2f3fa01..b41ff0d3e 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/basic/SpecialCharactersAPITestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/basic/SpecialCharactersAPITestIT.java @@ -3,11 +3,11 @@ import com.axway.apim.EndpointConfig; import com.axway.apim.test.ImportTestAction; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; -import org.citrusframework.validation.json.JsonPathMessageValidationContext; +import org.citrusframework.validation.context.json.JsonPathMessageValidationContext; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.test.context.ContextConfiguration; @@ -15,7 +15,7 @@ import java.io.IOException; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; import static org.citrusframework.http.actions.HttpActionBuilder.http; import static org.citrusframework.validation.DelegatingPayloadVariableExtractor.Builder.fromBody; diff --git a/modules/apis/src/test/java/com/axway/apim/test/basic/SwaggerFromFileInConfigurationTestIT.java b/modules/apis/src/test/java/com/axway/apim/test/basic/SwaggerFromFileInConfigurationTestIT.java index 70bddcd2e..b41396e0a 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/basic/SwaggerFromFileInConfigurationTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/basic/SwaggerFromFileInConfigurationTestIT.java @@ -3,7 +3,7 @@ import com.axway.apim.EndpointConfig; import com.axway.apim.test.ImportTestAction; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; @@ -14,9 +14,9 @@ import java.io.IOException; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; -import static org.citrusframework.dsl.JsonPathSupport.jsonPath; +import static org.citrusframework.json.dsl.JsonPathSupport.jsonPath; import static org.citrusframework.http.actions.HttpActionBuilder.http; import static org.citrusframework.validation.DelegatingPayloadVariableExtractor.Builder.fromBody; diff --git a/modules/apis/src/test/java/com/axway/apim/test/basic/SwaggerFromURLDirectTestIT.java b/modules/apis/src/test/java/com/axway/apim/test/basic/SwaggerFromURLDirectTestIT.java index 8af513663..f01d65aaf 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/basic/SwaggerFromURLDirectTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/basic/SwaggerFromURLDirectTestIT.java @@ -3,7 +3,7 @@ import com.axway.apim.EndpointConfig; import com.axway.apim.test.ImportTestAction; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; @@ -14,10 +14,10 @@ import java.io.IOException; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; import static org.citrusframework.actions.TraceVariablesAction.Builder.traceVariables; -import static org.citrusframework.dsl.JsonPathSupport.jsonPath; +import static org.citrusframework.json.dsl.JsonPathSupport.jsonPath; import static org.citrusframework.http.actions.HttpActionBuilder.http; import static org.citrusframework.validation.DelegatingPayloadVariableExtractor.Builder.fromBody; diff --git a/modules/apis/src/test/java/com/axway/apim/test/basic/SwaggerFromURLInConfigurationDirectTestIT.java b/modules/apis/src/test/java/com/axway/apim/test/basic/SwaggerFromURLInConfigurationDirectTestIT.java index 974f53bed..b7944e0ab 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/basic/SwaggerFromURLInConfigurationDirectTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/basic/SwaggerFromURLInConfigurationDirectTestIT.java @@ -3,7 +3,7 @@ import com.axway.apim.EndpointConfig; import com.axway.apim.test.ImportTestAction; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; @@ -14,9 +14,9 @@ import java.io.IOException; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; -import static org.citrusframework.dsl.JsonPathSupport.jsonPath; +import static org.citrusframework.json.dsl.JsonPathSupport.jsonPath; import static org.citrusframework.http.actions.HttpActionBuilder.http; import static org.citrusframework.validation.DelegatingPayloadVariableExtractor.Builder.fromBody; diff --git a/modules/apis/src/test/java/com/axway/apim/test/basic/SwaggerFromURLRefFileInConfigurationTestIT.java b/modules/apis/src/test/java/com/axway/apim/test/basic/SwaggerFromURLRefFileInConfigurationTestIT.java index 86e0cd785..cdc3edd64 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/basic/SwaggerFromURLRefFileInConfigurationTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/basic/SwaggerFromURLRefFileInConfigurationTestIT.java @@ -3,7 +3,7 @@ import com.axway.apim.EndpointConfig; import com.axway.apim.test.ImportTestAction; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; @@ -14,9 +14,9 @@ import java.io.IOException; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; -import static org.citrusframework.dsl.JsonPathSupport.jsonPath; +import static org.citrusframework.json.dsl.JsonPathSupport.jsonPath; import static org.citrusframework.http.actions.HttpActionBuilder.http; diff --git a/modules/apis/src/test/java/com/axway/apim/test/basic/SwaggerFromURLRefFileTestIT.java b/modules/apis/src/test/java/com/axway/apim/test/basic/SwaggerFromURLRefFileTestIT.java index 699e24671..e4c714c64 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/basic/SwaggerFromURLRefFileTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/basic/SwaggerFromURLRefFileTestIT.java @@ -3,7 +3,7 @@ import com.axway.apim.EndpointConfig; import com.axway.apim.test.ImportTestAction; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; @@ -14,9 +14,9 @@ import java.io.IOException; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; -import static org.citrusframework.dsl.JsonPathSupport.jsonPath; +import static org.citrusframework.json.dsl.JsonPathSupport.jsonPath; import static org.citrusframework.http.actions.HttpActionBuilder.http; diff --git a/modules/apis/src/test/java/com/axway/apim/test/basic/UnpublishDeleteMustBeBreakingTestIT.java b/modules/apis/src/test/java/com/axway/apim/test/basic/UnpublishDeleteMustBeBreakingTestIT.java index a3c62e934..6b38578cc 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/basic/UnpublishDeleteMustBeBreakingTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/basic/UnpublishDeleteMustBeBreakingTestIT.java @@ -3,14 +3,14 @@ import com.axway.apim.EndpointConfig; import com.axway.apim.test.ImportTestAction; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; import org.springframework.test.context.ContextConfiguration; import org.testng.annotations.Test; import java.io.IOException; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; diff --git a/modules/apis/src/test/java/com/axway/apim/test/basic/UnpublishedPublishedDeprecatedAPITestIT.java b/modules/apis/src/test/java/com/axway/apim/test/basic/UnpublishedPublishedDeprecatedAPITestIT.java index 1d475feff..eeb4ad1a3 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/basic/UnpublishedPublishedDeprecatedAPITestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/basic/UnpublishedPublishedDeprecatedAPITestIT.java @@ -3,7 +3,7 @@ import com.axway.apim.EndpointConfig; import com.axway.apim.test.ImportTestAction; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; @@ -14,9 +14,9 @@ import java.io.IOException; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; -import static org.citrusframework.dsl.JsonPathSupport.jsonPath; +import static org.citrusframework.json.dsl.JsonPathSupport.jsonPath; import static org.citrusframework.http.actions.HttpActionBuilder.http; import static org.citrusframework.validation.DelegatingPayloadVariableExtractor.Builder.fromBody; diff --git a/modules/apis/src/test/java/com/axway/apim/test/basic/UnpublishedSummaryAPITestIT.java b/modules/apis/src/test/java/com/axway/apim/test/basic/UnpublishedSummaryAPITestIT.java index cc1ed256c..271e75f1e 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/basic/UnpublishedSummaryAPITestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/basic/UnpublishedSummaryAPITestIT.java @@ -3,7 +3,7 @@ import com.axway.apim.EndpointConfig; import com.axway.apim.test.ImportTestAction; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; @@ -14,9 +14,9 @@ import java.io.IOException; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; -import static org.citrusframework.dsl.JsonPathSupport.jsonPath; +import static org.citrusframework.json.dsl.JsonPathSupport.jsonPath; import static org.citrusframework.http.actions.HttpActionBuilder.http; import static org.citrusframework.validation.DelegatingPayloadVariableExtractor.Builder.fromBody; diff --git a/modules/apis/src/test/java/com/axway/apim/test/basic/UnpublishedSwaggerChangeTestIT.java b/modules/apis/src/test/java/com/axway/apim/test/basic/UnpublishedSwaggerChangeTestIT.java index a1b266c75..06e3e78e6 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/basic/UnpublishedSwaggerChangeTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/basic/UnpublishedSwaggerChangeTestIT.java @@ -3,7 +3,7 @@ import com.axway.apim.EndpointConfig; import com.axway.apim.test.ImportTestAction; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; @@ -14,10 +14,10 @@ import java.io.IOException; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; import static org.citrusframework.actions.SleepAction.Builder.sleep; -import static org.citrusframework.dsl.JsonPathSupport.jsonPath; +import static org.citrusframework.json.dsl.JsonPathSupport.jsonPath; import static org.citrusframework.http.actions.HttpActionBuilder.http; import static org.citrusframework.validation.DelegatingPayloadVariableExtractor.Builder.fromBody; diff --git a/modules/apis/src/test/java/com/axway/apim/test/basic/YamlAPITestIT.java b/modules/apis/src/test/java/com/axway/apim/test/basic/YamlAPITestIT.java index fcfcde2ba..4cf3bb89a 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/basic/YamlAPITestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/basic/YamlAPITestIT.java @@ -3,7 +3,7 @@ import com.axway.apim.EndpointConfig; import com.axway.apim.test.ImportTestAction; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; @@ -14,9 +14,9 @@ import java.io.IOException; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; -import static org.citrusframework.dsl.JsonPathSupport.jsonPath; +import static org.citrusframework.json.dsl.JsonPathSupport.jsonPath; import static org.citrusframework.http.actions.HttpActionBuilder.http; import static org.citrusframework.validation.DelegatingPayloadVariableExtractor.Builder.fromBody; diff --git a/modules/apis/src/test/java/com/axway/apim/test/cacerts/BasicCaCertTestIT.java b/modules/apis/src/test/java/com/axway/apim/test/cacerts/BasicCaCertTestIT.java index 99f895892..5e50ce18f 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/cacerts/BasicCaCertTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/cacerts/BasicCaCertTestIT.java @@ -3,7 +3,7 @@ import com.axway.apim.EndpointConfig; import com.axway.apim.test.ImportTestAction; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; @@ -12,9 +12,9 @@ import org.springframework.test.context.ContextConfiguration; import org.testng.annotations.Test; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; -import static org.citrusframework.dsl.JsonPathSupport.jsonPath; +import static org.citrusframework.json.dsl.JsonPathSupport.jsonPath; import static org.citrusframework.http.actions.HttpActionBuilder.http; import static org.citrusframework.validation.DelegatingPayloadVariableExtractor.Builder.fromBody; diff --git a/modules/apis/src/test/java/com/axway/apim/test/cors/CorsProfileBasicTestIT.java b/modules/apis/src/test/java/com/axway/apim/test/cors/CorsProfileBasicTestIT.java index 10d0ffed4..931c4f693 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/cors/CorsProfileBasicTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/cors/CorsProfileBasicTestIT.java @@ -3,7 +3,7 @@ import com.axway.apim.EndpointConfig; import com.axway.apim.test.ImportTestAction; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; @@ -12,9 +12,9 @@ import org.springframework.test.context.ContextConfiguration; import org.testng.annotations.Test; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; -import static org.citrusframework.dsl.JsonPathSupport.jsonPath; +import static org.citrusframework.json.dsl.JsonPathSupport.jsonPath; import static org.citrusframework.http.actions.HttpActionBuilder.http; diff --git a/modules/apis/src/test/java/com/axway/apim/test/customproperties/CustomPropertiesBasicTestIT.java b/modules/apis/src/test/java/com/axway/apim/test/customproperties/CustomPropertiesBasicTestIT.java index a5fe16c20..da9e8e1fb 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/customproperties/CustomPropertiesBasicTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/customproperties/CustomPropertiesBasicTestIT.java @@ -3,7 +3,7 @@ import com.axway.apim.EndpointConfig; import com.axway.apim.test.ImportTestAction; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; @@ -12,9 +12,9 @@ import org.springframework.test.context.ContextConfiguration; import org.testng.annotations.Test; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; -import static org.citrusframework.dsl.JsonPathSupport.jsonPath; +import static org.citrusframework.json.dsl.JsonPathSupport.jsonPath; import static org.citrusframework.http.actions.HttpActionBuilder.http; import static org.citrusframework.validation.DelegatingPayloadVariableExtractor.Builder.fromBody; diff --git a/modules/apis/src/test/java/com/axway/apim/test/description/APIDescriptionBasicTestIT.java b/modules/apis/src/test/java/com/axway/apim/test/description/APIDescriptionBasicTestIT.java index 594f2f328..4ff6cddb2 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/description/APIDescriptionBasicTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/description/APIDescriptionBasicTestIT.java @@ -3,7 +3,7 @@ import com.axway.apim.EndpointConfig; import com.axway.apim.test.ImportTestAction; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; @@ -12,9 +12,9 @@ import org.springframework.test.context.ContextConfiguration; import org.testng.annotations.Test; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; -import static org.citrusframework.dsl.JsonPathSupport.jsonPath; +import static org.citrusframework.json.dsl.JsonPathSupport.jsonPath; import static org.citrusframework.http.actions.HttpActionBuilder.http; import static org.citrusframework.validation.DelegatingPayloadVariableExtractor.Builder.fromBody; diff --git a/modules/apis/src/test/java/com/axway/apim/test/description/APIDescriptionChangeTypeTestIT.java b/modules/apis/src/test/java/com/axway/apim/test/description/APIDescriptionChangeTypeTestIT.java index 908c2738c..02ece263f 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/description/APIDescriptionChangeTypeTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/description/APIDescriptionChangeTypeTestIT.java @@ -3,7 +3,7 @@ import com.axway.apim.EndpointConfig; import com.axway.apim.test.ImportTestAction; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; @@ -12,9 +12,9 @@ import org.springframework.test.context.ContextConfiguration; import org.testng.annotations.Test; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; -import static org.citrusframework.dsl.JsonPathSupport.jsonPath; +import static org.citrusframework.json.dsl.JsonPathSupport.jsonPath; import static org.citrusframework.http.actions.HttpActionBuilder.http; import static org.citrusframework.validation.DelegatingPayloadVariableExtractor.Builder.fromBody; diff --git a/modules/apis/src/test/java/com/axway/apim/test/description/LocalMarkdownDescriptionTestIT.java b/modules/apis/src/test/java/com/axway/apim/test/description/LocalMarkdownDescriptionTestIT.java index 35789863d..6b4e7af17 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/description/LocalMarkdownDescriptionTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/description/LocalMarkdownDescriptionTestIT.java @@ -3,7 +3,7 @@ import com.axway.apim.EndpointConfig; import com.axway.apim.test.ImportTestAction; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; @@ -13,9 +13,9 @@ import org.springframework.test.context.ContextConfiguration; import org.testng.annotations.Test; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; -import static org.citrusframework.dsl.JsonPathSupport.jsonPath; +import static org.citrusframework.json.dsl.JsonPathSupport.jsonPath; import static org.citrusframework.http.actions.HttpActionBuilder.http; diff --git a/modules/apis/src/test/java/com/axway/apim/test/envProperties/UsingEnvironmentTestIT.java b/modules/apis/src/test/java/com/axway/apim/test/envProperties/UsingEnvironmentTestIT.java index e78e8498f..f1fcd1246 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/envProperties/UsingEnvironmentTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/envProperties/UsingEnvironmentTestIT.java @@ -3,12 +3,12 @@ import com.axway.apim.EndpointConfig; import com.axway.apim.test.ImportTestAction; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; import org.springframework.test.context.ContextConfiguration; import org.testng.annotations.Test; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; @ContextConfiguration(classes = {EndpointConfig.class}) diff --git a/modules/apis/src/test/java/com/axway/apim/test/image/APIImageTestIT.java b/modules/apis/src/test/java/com/axway/apim/test/image/APIImageTestIT.java index 72826b3b5..4efed45db 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/image/APIImageTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/image/APIImageTestIT.java @@ -3,7 +3,7 @@ import com.axway.apim.EndpointConfig; import com.axway.apim.test.ImportTestAction; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; @@ -12,9 +12,9 @@ import org.springframework.test.context.ContextConfiguration; import org.testng.annotations.Test; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; -import static org.citrusframework.dsl.JsonPathSupport.jsonPath; +import static org.citrusframework.json.dsl.JsonPathSupport.jsonPath; import static org.citrusframework.http.actions.HttpActionBuilder.http; import static org.citrusframework.validation.DelegatingPayloadVariableExtractor.Builder.fromBody; diff --git a/modules/apis/src/test/java/com/axway/apim/test/image/PublishedAPIChangeImageTestIT.java b/modules/apis/src/test/java/com/axway/apim/test/image/PublishedAPIChangeImageTestIT.java index 74b7d18df..cb1d71a71 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/image/PublishedAPIChangeImageTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/image/PublishedAPIChangeImageTestIT.java @@ -3,7 +3,7 @@ import com.axway.apim.EndpointConfig; import com.axway.apim.test.ImportTestAction; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; @@ -12,9 +12,9 @@ import org.springframework.test.context.ContextConfiguration; import org.testng.annotations.Test; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; -import static org.citrusframework.dsl.JsonPathSupport.jsonPath; +import static org.citrusframework.json.dsl.JsonPathSupport.jsonPath; import static org.citrusframework.http.actions.HttpActionBuilder.http; import static org.citrusframework.validation.DelegatingPayloadVariableExtractor.Builder.fromBody; diff --git a/modules/apis/src/test/java/com/axway/apim/test/image/UpdateUnpublishedExistingWithImageTestIT.java b/modules/apis/src/test/java/com/axway/apim/test/image/UpdateUnpublishedExistingWithImageTestIT.java index 53e806256..a9cac4749 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/image/UpdateUnpublishedExistingWithImageTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/image/UpdateUnpublishedExistingWithImageTestIT.java @@ -3,7 +3,7 @@ import com.axway.apim.EndpointConfig; import com.axway.apim.test.ImportTestAction; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; @@ -11,9 +11,9 @@ import org.springframework.http.HttpStatus; import org.springframework.test.context.ContextConfiguration; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; -import static org.citrusframework.dsl.JsonPathSupport.jsonPath; +import static org.citrusframework.json.dsl.JsonPathSupport.jsonPath; import static org.citrusframework.http.actions.HttpActionBuilder.http; import static org.citrusframework.validation.DelegatingPayloadVariableExtractor.Builder.fromBody; diff --git a/modules/apis/src/test/java/com/axway/apim/test/methodLevel/InboundMethodLevelInvalidOperationTestIT.java b/modules/apis/src/test/java/com/axway/apim/test/methodLevel/InboundMethodLevelInvalidOperationTestIT.java index 5663b38ad..b251b758c 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/methodLevel/InboundMethodLevelInvalidOperationTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/methodLevel/InboundMethodLevelInvalidOperationTestIT.java @@ -3,7 +3,7 @@ import com.axway.apim.EndpointConfig; import com.axway.apim.test.ImportTestAction; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; import org.springframework.beans.factory.annotation.Autowired; @@ -12,7 +12,7 @@ import java.io.IOException; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; diff --git a/modules/apis/src/test/java/com/axway/apim/test/methodLevel/InboundMethodLevelTestIT.java b/modules/apis/src/test/java/com/axway/apim/test/methodLevel/InboundMethodLevelTestIT.java index 4c558fb13..d7c885ea7 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/methodLevel/InboundMethodLevelTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/methodLevel/InboundMethodLevelTestIT.java @@ -3,7 +3,7 @@ import com.axway.apim.EndpointConfig; import com.axway.apim.test.ImportTestAction; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; @@ -14,9 +14,9 @@ import java.io.IOException; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; -import static org.citrusframework.dsl.JsonPathSupport.jsonPath; +import static org.citrusframework.json.dsl.JsonPathSupport.jsonPath; import static org.citrusframework.http.actions.HttpActionBuilder.http; import static org.citrusframework.validation.DelegatingPayloadVariableExtractor.Builder.fromBody; diff --git a/modules/apis/src/test/java/com/axway/apim/test/methodLevel/MethodLevelInvalidProfileTestIT.java b/modules/apis/src/test/java/com/axway/apim/test/methodLevel/MethodLevelInvalidProfileTestIT.java index e1abefb7d..3f7fe3a33 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/methodLevel/MethodLevelInvalidProfileTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/methodLevel/MethodLevelInvalidProfileTestIT.java @@ -3,12 +3,12 @@ import com.axway.apim.EndpointConfig; import com.axway.apim.test.ImportTestAction; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; import org.springframework.test.context.ContextConfiguration; import org.testng.annotations.Test; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; diff --git a/modules/apis/src/test/java/com/axway/apim/test/methodLevel/MethodLvlRecreationTestIT.java b/modules/apis/src/test/java/com/axway/apim/test/methodLevel/MethodLvlRecreationTestIT.java index 9ba680900..28ffd694b 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/methodLevel/MethodLvlRecreationTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/methodLevel/MethodLvlRecreationTestIT.java @@ -3,7 +3,7 @@ import com.axway.apim.EndpointConfig; import com.axway.apim.test.ImportTestAction; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; @@ -14,9 +14,9 @@ import java.io.IOException; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; -import static org.citrusframework.dsl.JsonPathSupport.jsonPath; +import static org.citrusframework.json.dsl.JsonPathSupport.jsonPath; import static org.citrusframework.http.actions.HttpActionBuilder.http; import static org.citrusframework.validation.DelegatingPayloadVariableExtractor.Builder.fromBody; diff --git a/modules/apis/src/test/java/com/axway/apim/test/methodLevel/OutboundMethodLevelTestIT.java b/modules/apis/src/test/java/com/axway/apim/test/methodLevel/OutboundMethodLevelTestIT.java index f48d920ed..71b4cd866 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/methodLevel/OutboundMethodLevelTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/methodLevel/OutboundMethodLevelTestIT.java @@ -3,7 +3,7 @@ import com.axway.apim.EndpointConfig; import com.axway.apim.test.ImportTestAction; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; @@ -14,9 +14,9 @@ import java.io.IOException; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; -import static org.citrusframework.dsl.JsonPathSupport.jsonPath; +import static org.citrusframework.json.dsl.JsonPathSupport.jsonPath; import static org.citrusframework.http.actions.HttpActionBuilder.http; import static org.citrusframework.validation.DelegatingPayloadVariableExtractor.Builder.fromBody; diff --git a/modules/apis/src/test/java/com/axway/apim/test/odata/ODataV2ImportTestIT.java b/modules/apis/src/test/java/com/axway/apim/test/odata/ODataV2ImportTestIT.java index 230aecb82..79faf76de 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/odata/ODataV2ImportTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/odata/ODataV2ImportTestIT.java @@ -3,7 +3,7 @@ import com.axway.apim.EndpointConfig; import com.axway.apim.test.ImportTestAction; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; @@ -14,9 +14,9 @@ import java.io.IOException; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; -import static org.citrusframework.dsl.JsonPathSupport.jsonPath; +import static org.citrusframework.json.dsl.JsonPathSupport.jsonPath; import static org.citrusframework.http.actions.HttpActionBuilder.http; diff --git a/modules/apis/src/test/java/com/axway/apim/test/odata/ODataV4ImportTestIT.java b/modules/apis/src/test/java/com/axway/apim/test/odata/ODataV4ImportTestIT.java index 3189728a6..df388cd7d 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/odata/ODataV4ImportTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/odata/ODataV4ImportTestIT.java @@ -3,7 +3,7 @@ import com.axway.apim.EndpointConfig; import com.axway.apim.test.ImportTestAction; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; @@ -14,9 +14,9 @@ import java.io.IOException; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; -import static org.citrusframework.dsl.JsonPathSupport.jsonPath; +import static org.citrusframework.json.dsl.JsonPathSupport.jsonPath; import static org.citrusframework.http.actions.HttpActionBuilder.http; diff --git a/modules/apis/src/test/java/com/axway/apim/test/orgadmin/OrgAdminCustomPoliciesTestIT.java b/modules/apis/src/test/java/com/axway/apim/test/orgadmin/OrgAdminCustomPoliciesTestIT.java index 64b54056e..ef77c2c1a 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/orgadmin/OrgAdminCustomPoliciesTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/orgadmin/OrgAdminCustomPoliciesTestIT.java @@ -3,7 +3,7 @@ import com.axway.apim.EndpointConfig; import com.axway.apim.test.ImportTestAction; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; @@ -12,9 +12,9 @@ import org.springframework.test.context.ContextConfiguration; import org.testng.annotations.Test; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; -import static org.citrusframework.dsl.JsonPathSupport.jsonPath; +import static org.citrusframework.json.dsl.JsonPathSupport.jsonPath; import static org.citrusframework.http.actions.HttpActionBuilder.http; diff --git a/modules/apis/src/test/java/com/axway/apim/test/orgadmin/OrgAdminCustomPropertiesTestIT.java b/modules/apis/src/test/java/com/axway/apim/test/orgadmin/OrgAdminCustomPropertiesTestIT.java index 6bf078114..2519dc919 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/orgadmin/OrgAdminCustomPropertiesTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/orgadmin/OrgAdminCustomPropertiesTestIT.java @@ -3,12 +3,12 @@ import com.axway.apim.EndpointConfig; import com.axway.apim.test.ImportTestAction; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; import org.springframework.test.context.ContextConfiguration; import org.testng.annotations.Test; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; diff --git a/modules/apis/src/test/java/com/axway/apim/test/orgadmin/OrgAdminOAuthExternalTestIT.java b/modules/apis/src/test/java/com/axway/apim/test/orgadmin/OrgAdminOAuthExternalTestIT.java index 5fc6c8bd3..4a38aa121 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/orgadmin/OrgAdminOAuthExternalTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/orgadmin/OrgAdminOAuthExternalTestIT.java @@ -3,7 +3,7 @@ import com.axway.apim.EndpointConfig; import com.axway.apim.test.ImportTestAction; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; @@ -12,9 +12,9 @@ import org.springframework.test.context.ContextConfiguration; import org.testng.annotations.Test; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; -import static org.citrusframework.dsl.JsonPathSupport.jsonPath; +import static org.citrusframework.json.dsl.JsonPathSupport.jsonPath; import static org.citrusframework.http.actions.HttpActionBuilder.http; import static org.citrusframework.validation.DelegatingPayloadVariableExtractor.Builder.fromBody; diff --git a/modules/apis/src/test/java/com/axway/apim/test/orgadmin/OrgAdminTriesToPublishTestIT.java b/modules/apis/src/test/java/com/axway/apim/test/orgadmin/OrgAdminTriesToPublishTestIT.java index 371caf433..85adcc6f4 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/orgadmin/OrgAdminTriesToPublishTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/orgadmin/OrgAdminTriesToPublishTestIT.java @@ -3,12 +3,12 @@ import com.axway.apim.EndpointConfig; import com.axway.apim.test.ImportTestAction; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; import org.springframework.test.context.ContextConfiguration; import org.testng.annotations.Test; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; diff --git a/modules/apis/src/test/java/com/axway/apim/test/orgadmin/OrgAdminUnpublishedTestIT.java b/modules/apis/src/test/java/com/axway/apim/test/orgadmin/OrgAdminUnpublishedTestIT.java index f20f34301..d7798d787 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/orgadmin/OrgAdminUnpublishedTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/orgadmin/OrgAdminUnpublishedTestIT.java @@ -3,7 +3,7 @@ import com.axway.apim.EndpointConfig; import com.axway.apim.test.ImportTestAction; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; @@ -12,9 +12,9 @@ import org.springframework.test.context.ContextConfiguration; import org.testng.annotations.Test; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; -import static org.citrusframework.dsl.JsonPathSupport.jsonPath; +import static org.citrusframework.json.dsl.JsonPathSupport.jsonPath; import static org.citrusframework.http.actions.HttpActionBuilder.http; diff --git a/modules/apis/src/test/java/com/axway/apim/test/organizations/APIGrantOrganizationsTestIT.java b/modules/apis/src/test/java/com/axway/apim/test/organizations/APIGrantOrganizationsTestIT.java index 4815a9cb4..adfa3360c 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/organizations/APIGrantOrganizationsTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/organizations/APIGrantOrganizationsTestIT.java @@ -3,7 +3,7 @@ import com.axway.apim.EndpointConfig; import com.axway.apim.test.ImportTestAction; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; @@ -12,10 +12,10 @@ import org.springframework.test.context.ContextConfiguration; import org.testng.annotations.Test; -import static org.citrusframework.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; -import static org.citrusframework.dsl.JsonPathSupport.jsonPath; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.http.actions.HttpActionBuilder.http; +import static org.citrusframework.json.dsl.JsonPathSupport.jsonPath; import static org.citrusframework.validation.DelegatingPayloadVariableExtractor.Builder.fromBody; @ContextConfiguration(classes = {EndpointConfig.class}) diff --git a/modules/apis/src/test/java/com/axway/apim/test/organizations/APIGrantToAllOrgsTestIT.java b/modules/apis/src/test/java/com/axway/apim/test/organizations/APIGrantToAllOrgsTestIT.java index a30f32089..661007b61 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/organizations/APIGrantToAllOrgsTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/organizations/APIGrantToAllOrgsTestIT.java @@ -3,7 +3,7 @@ import com.axway.apim.EndpointConfig; import com.axway.apim.test.ImportTestAction; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; @@ -12,10 +12,10 @@ import org.springframework.test.context.ContextConfiguration; import org.testng.annotations.Test; -import static org.citrusframework.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; -import static org.citrusframework.dsl.JsonPathSupport.jsonPath; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.http.actions.HttpActionBuilder.http; +import static org.citrusframework.json.dsl.JsonPathSupport.jsonPath; import static org.citrusframework.validation.DelegatingPayloadVariableExtractor.Builder.fromBody; @ContextConfiguration(classes = {EndpointConfig.class}) diff --git a/modules/apis/src/test/java/com/axway/apim/test/organizations/APIGrantToInvalidOrgTestIT.java b/modules/apis/src/test/java/com/axway/apim/test/organizations/APIGrantToInvalidOrgTestIT.java index 282aea652..a7f9e2615 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/organizations/APIGrantToInvalidOrgTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/organizations/APIGrantToInvalidOrgTestIT.java @@ -3,14 +3,14 @@ import com.axway.apim.EndpointConfig; import com.axway.apim.test.ImportTestAction; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.testng.annotations.Test; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; @ContextConfiguration(classes = {EndpointConfig.class}) diff --git a/modules/apis/src/test/java/com/axway/apim/test/organizations/APIRemoveAccessForAnOrgTestIT.java b/modules/apis/src/test/java/com/axway/apim/test/organizations/APIRemoveAccessForAnOrgTestIT.java index ce7c19b6b..8ac2c24e2 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/organizations/APIRemoveAccessForAnOrgTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/organizations/APIRemoveAccessForAnOrgTestIT.java @@ -4,7 +4,7 @@ import com.axway.apim.lib.CoreParameters.Mode; import com.axway.apim.test.ImportTestAction; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; @@ -13,9 +13,9 @@ import org.springframework.test.context.ContextConfiguration; import org.testng.annotations.Test; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; -import static org.citrusframework.dsl.JsonPathSupport.jsonPath; +import static org.citrusframework.json.dsl.JsonPathSupport.jsonPath; import static org.citrusframework.http.actions.HttpActionBuilder.http; import static org.citrusframework.validation.DelegatingPayloadVariableExtractor.Builder.fromBody; diff --git a/modules/apis/src/test/java/com/axway/apim/test/organizations/APIRevokeOrganizationTestIT.java b/modules/apis/src/test/java/com/axway/apim/test/organizations/APIRevokeOrganizationTestIT.java index fe8f274cc..05702ee62 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/organizations/APIRevokeOrganizationTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/organizations/APIRevokeOrganizationTestIT.java @@ -7,7 +7,7 @@ import org.citrusframework.annotations.CitrusTest; import org.citrusframework.context.TestContext; import org.citrusframework.exceptions.ValidationException; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; @@ -19,9 +19,9 @@ import org.testng.annotations.Optional; import org.testng.annotations.Test; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; -import static org.citrusframework.dsl.JsonPathSupport.jsonPath; +import static org.citrusframework.json.dsl.JsonPathSupport.jsonPath; import static org.citrusframework.http.actions.HttpActionBuilder.http; import static org.citrusframework.validation.DelegatingPayloadVariableExtractor.Builder.fromBody; diff --git a/modules/apis/src/test/java/com/axway/apim/test/organizations/ChangeDevelopmentOrgTestIT.java b/modules/apis/src/test/java/com/axway/apim/test/organizations/ChangeDevelopmentOrgTestIT.java index fd971f035..7f2e751ed 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/organizations/ChangeDevelopmentOrgTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/organizations/ChangeDevelopmentOrgTestIT.java @@ -3,7 +3,7 @@ import com.axway.apim.EndpointConfig; import com.axway.apim.test.ImportTestAction; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; @@ -14,9 +14,9 @@ import java.io.IOException; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; -import static org.citrusframework.dsl.JsonPathSupport.jsonPath; +import static org.citrusframework.json.dsl.JsonPathSupport.jsonPath; import static org.citrusframework.http.actions.HttpActionBuilder.http; import static org.citrusframework.validation.DelegatingPayloadVariableExtractor.Builder.fromBody; diff --git a/modules/apis/src/test/java/com/axway/apim/test/organizations/ClientOrgModeAddTestIT.java b/modules/apis/src/test/java/com/axway/apim/test/organizations/ClientOrgModeAddTestIT.java index b95a7c4de..0b3d6c996 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/organizations/ClientOrgModeAddTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/organizations/ClientOrgModeAddTestIT.java @@ -3,7 +3,7 @@ import com.axway.apim.EndpointConfig; import com.axway.apim.test.ImportTestAction; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; @@ -12,9 +12,9 @@ import org.springframework.test.context.ContextConfiguration; import org.testng.annotations.Test; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; -import static org.citrusframework.dsl.JsonPathSupport.jsonPath; +import static org.citrusframework.json.dsl.JsonPathSupport.jsonPath; import static org.citrusframework.http.actions.HttpActionBuilder.http; import static org.citrusframework.validation.DelegatingPayloadVariableExtractor.Builder.fromBody; diff --git a/modules/apis/src/test/java/com/axway/apim/test/organizations/IgnoreClientOrgsTestIT.java b/modules/apis/src/test/java/com/axway/apim/test/organizations/IgnoreClientOrgsTestIT.java index 1e75602d3..8af25b31b 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/organizations/IgnoreClientOrgsTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/organizations/IgnoreClientOrgsTestIT.java @@ -4,7 +4,7 @@ import com.axway.apim.lib.CoreParameters.Mode; import com.axway.apim.test.ImportTestAction; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; @@ -13,9 +13,9 @@ import org.springframework.test.context.ContextConfiguration; import org.testng.annotations.Test; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; -import static org.citrusframework.dsl.JsonPathSupport.jsonPath; +import static org.citrusframework.json.dsl.JsonPathSupport.jsonPath; import static org.citrusframework.http.actions.HttpActionBuilder.http; import static org.citrusframework.validation.DelegatingPayloadVariableExtractor.Builder.fromBody; diff --git a/modules/apis/src/test/java/com/axway/apim/test/organizations/InvalidDevelopmentOrgTestIT.java b/modules/apis/src/test/java/com/axway/apim/test/organizations/InvalidDevelopmentOrgTestIT.java index e23fd50b9..281d46d72 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/organizations/InvalidDevelopmentOrgTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/organizations/InvalidDevelopmentOrgTestIT.java @@ -2,7 +2,7 @@ import com.axway.apim.EndpointConfig; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; @@ -13,9 +13,9 @@ import org.testng.annotations.Test; import com.axway.apim.test.ImportTestAction; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; -import static org.citrusframework.dsl.JsonPathSupport.jsonPath; +import static org.citrusframework.json.dsl.JsonPathSupport.jsonPath; import static org.citrusframework.http.actions.HttpActionBuilder.http; import static org.citrusframework.validation.DelegatingPayloadVariableExtractor.Builder.fromBody; diff --git a/modules/apis/src/test/java/com/axway/apim/test/organizations/NoChangedOrgsUnpublishedAPITestIT.java b/modules/apis/src/test/java/com/axway/apim/test/organizations/NoChangedOrgsUnpublishedAPITestIT.java index c0c6d42c4..d2874f58d 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/organizations/NoChangedOrgsUnpublishedAPITestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/organizations/NoChangedOrgsUnpublishedAPITestIT.java @@ -3,7 +3,7 @@ import com.axway.apim.EndpointConfig; import com.axway.apim.test.ImportTestAction; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; import org.springframework.beans.factory.annotation.Autowired; @@ -12,7 +12,7 @@ import java.io.IOException; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; @ContextConfiguration(classes = {EndpointConfig.class}) diff --git a/modules/apis/src/test/java/com/axway/apim/test/policies/AllOutboundPoliciesTestIT.java b/modules/apis/src/test/java/com/axway/apim/test/policies/AllOutboundPoliciesTestIT.java index 2b8dc0ee5..0e1292d52 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/policies/AllOutboundPoliciesTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/policies/AllOutboundPoliciesTestIT.java @@ -3,7 +3,7 @@ import com.axway.apim.EndpointConfig; import com.axway.apim.test.ImportTestAction; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; @@ -12,9 +12,9 @@ import org.springframework.test.context.ContextConfiguration; import org.testng.annotations.Test; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; -import static org.citrusframework.dsl.JsonPathSupport.jsonPath; +import static org.citrusframework.json.dsl.JsonPathSupport.jsonPath; import static org.citrusframework.http.actions.HttpActionBuilder.http; @ContextConfiguration(classes = {EndpointConfig.class}) diff --git a/modules/apis/src/test/java/com/axway/apim/test/policies/RequestPolicyTestIT.java b/modules/apis/src/test/java/com/axway/apim/test/policies/RequestPolicyTestIT.java index d5f05b83d..86af9f7d1 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/policies/RequestPolicyTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/policies/RequestPolicyTestIT.java @@ -2,7 +2,7 @@ import com.axway.apim.EndpointConfig; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; @@ -13,9 +13,9 @@ import com.axway.apim.test.ImportTestAction; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; -import static org.citrusframework.dsl.JsonPathSupport.jsonPath; +import static org.citrusframework.json.dsl.JsonPathSupport.jsonPath; import static org.citrusframework.http.actions.HttpActionBuilder.http; import static org.citrusframework.validation.DelegatingPayloadVariableExtractor.Builder.fromBody; diff --git a/modules/apis/src/test/java/com/axway/apim/test/policies/ResponsePolicyEmptyStringTestIT.java b/modules/apis/src/test/java/com/axway/apim/test/policies/ResponsePolicyEmptyStringTestIT.java index 5b9f3c365..b36b65e91 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/policies/ResponsePolicyEmptyStringTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/policies/ResponsePolicyEmptyStringTestIT.java @@ -3,7 +3,7 @@ import com.axway.apim.EndpointConfig; import com.axway.apim.test.ImportTestAction; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; @@ -14,9 +14,9 @@ import java.io.IOException; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; -import static org.citrusframework.dsl.JsonPathSupport.jsonPath; +import static org.citrusframework.json.dsl.JsonPathSupport.jsonPath; import static org.citrusframework.http.actions.HttpActionBuilder.http; import static org.citrusframework.validation.DelegatingPayloadVariableExtractor.Builder.fromBody; diff --git a/modules/apis/src/test/java/com/axway/apim/test/policies/RoutingPolicyTestIT.java b/modules/apis/src/test/java/com/axway/apim/test/policies/RoutingPolicyTestIT.java index d41b778ee..63876954f 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/policies/RoutingPolicyTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/policies/RoutingPolicyTestIT.java @@ -3,7 +3,7 @@ import com.axway.apim.EndpointConfig; import com.axway.apim.test.ImportTestAction; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; @@ -14,9 +14,9 @@ import java.io.IOException; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; -import static org.citrusframework.dsl.JsonPathSupport.jsonPath; +import static org.citrusframework.json.dsl.JsonPathSupport.jsonPath; import static org.citrusframework.http.actions.HttpActionBuilder.http; import static org.citrusframework.validation.DelegatingPayloadVariableExtractor.Builder.fromBody; diff --git a/modules/apis/src/test/java/com/axway/apim/test/policies/UnkownPolicyConfiguredTestIT.java b/modules/apis/src/test/java/com/axway/apim/test/policies/UnkownPolicyConfiguredTestIT.java index d6251c80c..02aab90ce 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/policies/UnkownPolicyConfiguredTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/policies/UnkownPolicyConfiguredTestIT.java @@ -3,14 +3,14 @@ import com.axway.apim.EndpointConfig; import com.axway.apim.test.ImportTestAction; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.testng.annotations.Test; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; @ContextConfiguration(classes = {EndpointConfig.class}) diff --git a/modules/apis/src/test/java/com/axway/apim/test/queryStringRouting/ValidateQueryStringTestIT.java b/modules/apis/src/test/java/com/axway/apim/test/queryStringRouting/ValidateQueryStringTestIT.java index e5a0ee406..ddc0707ab 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/queryStringRouting/ValidateQueryStringTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/queryStringRouting/ValidateQueryStringTestIT.java @@ -8,7 +8,7 @@ import org.citrusframework.annotations.CitrusResource; import org.citrusframework.annotations.CitrusTest; import org.citrusframework.context.TestContext; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; @@ -20,9 +20,9 @@ import java.io.IOException; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; -import static org.citrusframework.dsl.JsonPathSupport.jsonPath; +import static org.citrusframework.json.dsl.JsonPathSupport.jsonPath; import static org.citrusframework.http.actions.HttpActionBuilder.http; import static org.citrusframework.validation.DelegatingPayloadVariableExtractor.Builder.fromBody; diff --git a/modules/apis/src/test/java/com/axway/apim/test/quota/APIBasicQuotaTestIT.java b/modules/apis/src/test/java/com/axway/apim/test/quota/APIBasicQuotaTestIT.java index c0de8add3..70a071403 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/quota/APIBasicQuotaTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/quota/APIBasicQuotaTestIT.java @@ -4,7 +4,7 @@ import com.axway.apim.adapter.APIManagerAdapter; import com.axway.apim.test.ImportTestAction; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; @@ -15,10 +15,10 @@ import java.io.IOException; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; import static org.citrusframework.actions.SleepAction.Builder.sleep; -import static org.citrusframework.dsl.JsonPathSupport.jsonPath; +import static org.citrusframework.json.dsl.JsonPathSupport.jsonPath; import static org.citrusframework.http.actions.HttpActionBuilder.http; import static org.citrusframework.validation.DelegatingPayloadVariableExtractor.Builder.fromBody; diff --git a/modules/apis/src/test/java/com/axway/apim/test/quota/APIQuotaIgnoredTestIT.java b/modules/apis/src/test/java/com/axway/apim/test/quota/APIQuotaIgnoredTestIT.java index 243890f33..fdbc156c2 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/quota/APIQuotaIgnoredTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/quota/APIQuotaIgnoredTestIT.java @@ -4,7 +4,7 @@ import com.axway.apim.adapter.APIManagerAdapter; import com.axway.apim.test.ImportTestAction; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; @@ -13,9 +13,9 @@ import org.springframework.test.context.ContextConfiguration; import org.testng.annotations.Test; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; -import static org.citrusframework.dsl.JsonPathSupport.jsonPath; +import static org.citrusframework.json.dsl.JsonPathSupport.jsonPath; import static org.citrusframework.http.actions.HttpActionBuilder.http; import static org.citrusframework.validation.DelegatingPayloadVariableExtractor.Builder.fromBody; diff --git a/modules/apis/src/test/java/com/axway/apim/test/quota/AppOrSystemQuotaOnlyTestIT.java b/modules/apis/src/test/java/com/axway/apim/test/quota/AppOrSystemQuotaOnlyTestIT.java index 210c397ff..4b15214d1 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/quota/AppOrSystemQuotaOnlyTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/quota/AppOrSystemQuotaOnlyTestIT.java @@ -3,7 +3,7 @@ import com.axway.apim.EndpointConfig; import com.axway.apim.test.ImportTestAction; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; @@ -14,10 +14,10 @@ import java.io.IOException; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; import static org.citrusframework.actions.SleepAction.Builder.sleep; -import static org.citrusframework.dsl.JsonPathSupport.jsonPath; +import static org.citrusframework.json.dsl.JsonPathSupport.jsonPath; import static org.citrusframework.http.actions.HttpActionBuilder.http; import static org.citrusframework.validation.DelegatingPayloadVariableExtractor.Builder.fromBody; diff --git a/modules/apis/src/test/java/com/axway/apim/test/quota/CreateAndUpdateQuotaWithNewMethodAndSpecIT.java b/modules/apis/src/test/java/com/axway/apim/test/quota/CreateAndUpdateQuotaWithNewMethodAndSpecIT.java index c1a249323..955315c73 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/quota/CreateAndUpdateQuotaWithNewMethodAndSpecIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/quota/CreateAndUpdateQuotaWithNewMethodAndSpecIT.java @@ -14,7 +14,7 @@ import java.io.IOException; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; import static org.citrusframework.actions.SleepAction.Builder.sleep; import static org.citrusframework.http.actions.HttpActionBuilder.http; diff --git a/modules/apis/src/test/java/com/axway/apim/test/quota/DontOverwriteManualQuotaTestIT.java b/modules/apis/src/test/java/com/axway/apim/test/quota/DontOverwriteManualQuotaTestIT.java index 3e433f884..8f401349a 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/quota/DontOverwriteManualQuotaTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/quota/DontOverwriteManualQuotaTestIT.java @@ -4,7 +4,7 @@ import com.axway.apim.adapter.APIManagerAdapter; import com.axway.apim.test.ImportTestAction; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; @@ -15,10 +15,10 @@ import java.io.IOException; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; import static org.citrusframework.actions.SleepAction.Builder.sleep; -import static org.citrusframework.dsl.JsonPathSupport.jsonPath; +import static org.citrusframework.json.dsl.JsonPathSupport.jsonPath; import static org.citrusframework.http.actions.HttpActionBuilder.http; import static org.citrusframework.validation.DelegatingPayloadVariableExtractor.Builder.fromBody; diff --git a/modules/apis/src/test/java/com/axway/apim/test/quota/InvalidQuotaConfigTestIT.java b/modules/apis/src/test/java/com/axway/apim/test/quota/InvalidQuotaConfigTestIT.java index 809ed1011..ce8ddbd37 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/quota/InvalidQuotaConfigTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/quota/InvalidQuotaConfigTestIT.java @@ -3,14 +3,14 @@ import com.axway.apim.EndpointConfig; import com.axway.apim.test.ImportTestAction; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; import org.springframework.test.context.ContextConfiguration; import org.testng.annotations.Test; import java.io.IOException; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; @ContextConfiguration(classes = {EndpointConfig.class}) diff --git a/modules/apis/src/test/java/com/axway/apim/test/quota/MultiRestrictionQuotaTestIT.java b/modules/apis/src/test/java/com/axway/apim/test/quota/MultiRestrictionQuotaTestIT.java index 2c6568315..cfc474bb1 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/quota/MultiRestrictionQuotaTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/quota/MultiRestrictionQuotaTestIT.java @@ -3,7 +3,7 @@ import com.axway.apim.EndpointConfig; import com.axway.apim.test.ImportTestAction; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; @@ -14,10 +14,10 @@ import java.io.IOException; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; import static org.citrusframework.actions.SleepAction.Builder.sleep; -import static org.citrusframework.dsl.JsonPathSupport.jsonPath; +import static org.citrusframework.json.dsl.JsonPathSupport.jsonPath; import static org.citrusframework.http.actions.HttpActionBuilder.http; import static org.citrusframework.validation.DelegatingPayloadVariableExtractor.Builder.fromBody; diff --git a/modules/apis/src/test/java/com/axway/apim/test/quota/QuotaConstraintScopeChangeTestIT.java b/modules/apis/src/test/java/com/axway/apim/test/quota/QuotaConstraintScopeChangeTestIT.java new file mode 100644 index 000000000..d888a1f90 --- /dev/null +++ b/modules/apis/src/test/java/com/axway/apim/test/quota/QuotaConstraintScopeChangeTestIT.java @@ -0,0 +1,130 @@ +package com.axway.apim.test.quota; + +import com.axway.apim.EndpointConfig; +import com.axway.apim.test.ImportTestAction; +import org.citrusframework.annotations.CitrusResource; +import org.citrusframework.annotations.CitrusTest; +import org.citrusframework.context.TestContext; +import org.citrusframework.base.functions.core.RandomNumberFunction; +import org.citrusframework.http.client.HttpClient; +import org.citrusframework.message.MessageType; +import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.test.context.ContextConfiguration; +import org.testng.annotations.Optional; +import org.testng.annotations.Test; + +import java.io.IOException; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import static org.citrusframework.actions.EchoAction.Builder.echo; +import static org.citrusframework.actions.SleepAction.Builder.sleep; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; +import static org.citrusframework.http.actions.HttpActionBuilder.http; +import static org.citrusframework.json.dsl.JsonPathSupport.jsonPath; +import static org.citrusframework.validation.DelegatingPayloadVariableExtractor.Builder.fromBody; + +/** + * Proves that a quota update is surgical rather than a replacement of the complete quota document. + *

+ * Each restriction of a quota is addressable below /quotas/{id}/constraints and carries an ID assigned by the + * API-Manager. This test records those IDs and verifies that importing another API, and changing the quota of an + * API, leaves the identity of every other restriction untouched. A replace-all update cannot guarantee that. + */ +@ContextConfiguration(classes = {EndpointConfig.class}) +public class QuotaConstraintScopeChangeTestIT extends TestNGCitrusSpringSupport { + + private static final String SYSTEM_QUOTA = "/quotas/00000000-0000-0000-0000-000000000000"; + + @Autowired + HttpClient apiManager; + + @CitrusTest + @Test + public void run(@Optional @CitrusResource TestContext context) throws IOException { + ImportTestAction swaggerImport = new ImportTestAction(); + description("Make sure updating the quota of one API does not disturb the restrictions of other APIs"); + variable("oadminUsername1", "${apiManagerUser}"); + variable("oadminPassword1", "${apiManagerPass}"); + variable("apiNumber", RandomNumberFunction.getRandomNumber(3, true)); + variable("apiPath", "/quota-constraint-api-1-${apiNumber}"); + variable("apiName", "Quota-Constraint-API-1-${apiNumber}"); + variable("apiPath2", "/quota-constraint-api-2-${apiNumber}"); + variable("apiName2", "Quota-Constraint-API-2-${apiNumber}"); + + $(echo("####### Importing the first API: '${apiName}' on path: '${apiPath}' #######")); + variable(ImportTestAction.API_DEFINITION, "/com/axway/apim/test/files/basic/petstore.json"); + variable(ImportTestAction.API_CONFIG, "/com/axway/apim/test/files/quota/1_api-with-quota.json"); + variable("state", "unpublished"); + variable("expectedReturnCode", "0"); + variable("systemPeriod", "hour"); + variable("systemMessages", "1000"); + variable("applicationPeriod", "day"); + variable("applicationMb", "100"); + $(action(swaggerImport)); + + $(http().client(apiManager).send().get("/proxies")); + $(http().client(apiManager).receive().response(HttpStatus.OK).message().type(MessageType.JSON) + .validate(jsonPath().expression("$.[?(@.path=='${apiPath}')].name", "${apiName}")) + .extract(fromBody().expression("$.[?(@.path=='${apiPath}')].id", "apiId"))); + $(sleep().seconds(5)); + + $(http().client(apiManager).send().get("/config")); + $(http().client(apiManager).receive().response(HttpStatus.OK).message().type(MessageType.JSON) + .extract(fromBody().expression("$.productVersion", "productVersion"))); + + // Read the extracted test variable into a Java variable, e.g. "7.7-20260228" -> 20260228 + String productVersion = context.getVariable("productVersion"); + $(echo("####### Product version is: " + productVersion + " #######")); + Matcher matcher = Pattern.compile("(\\d{8})$").matcher(productVersion); + if (matcher.find() && Integer.parseInt(matcher.group(1)) < 20261130) { + $(echo("Skipping the Quota constraint test, API-Manager " + productVersion + " does not support it")); + return; + } + + $(echo("####### Record the constraint ID the API-Manager assigned to the restriction of API 1 #######")); + $(http().client(apiManager).send().get(SYSTEM_QUOTA + "/constraints")); + $(http().client(apiManager).receive().response(HttpStatus.OK).message().type(MessageType.JSON) + .validate(jsonPath() + .expression("$.[?(@.api=='${apiId}')].type", "throttle") + .expression("$.[?(@.api=='${apiId}')].config.messages", "${systemMessages}")) + .extract(fromBody().expression("$.[?(@.api=='${apiId}')].id", "api1ConstraintId"))); + + $(echo("####### Importing a second API, which must not touch the restriction of API 1 #######")); + variable(ImportTestAction.API_DEFINITION, "/com/axway/apim/test/files/basic/petstore.json"); + variable(ImportTestAction.API_CONFIG, "/com/axway/apim/test/files/quota/1_api-with-quota.json"); + variable("apiPath", "${apiPath2}"); + variable("apiName", "${apiName2}"); + variable("state", "unpublished"); + variable("expectedReturnCode", "0"); + variable("systemMessages", "2000"); + $(action(swaggerImport)); + $(sleep().seconds(5)); + + $(echo("####### The restriction of API 1 must still carry the very same constraint ID #######")); + $(http().client(apiManager).send().get(SYSTEM_QUOTA + "/constraints")); + $(http().client(apiManager).receive().response(HttpStatus.OK).message().type(MessageType.JSON) + .validate(jsonPath() + .expression("$.[?(@.api=='${apiId}')].id", "${api1ConstraintId}") + .expression("$.[?(@.api=='${apiId}')].config.messages", "1000"))); + + $(echo("####### Changing the quota of API 1 must update the restriction in place, keeping its ID #######")); + variable(ImportTestAction.API_DEFINITION, "/com/axway/apim/test/files/basic/petstore.json"); + variable(ImportTestAction.API_CONFIG, "/com/axway/apim/test/files/quota/1_api-with-quota.json"); + variable("apiPath", "/quota-constraint-api-1-${apiNumber}"); + variable("apiName", "Quota-Constraint-API-1-${apiNumber}"); + variable("state", "unpublished"); + variable("expectedReturnCode", "0"); + variable("systemMessages", "3000"); + $(action(swaggerImport)); + $(sleep().seconds(5)); + + $(http().client(apiManager).send().get(SYSTEM_QUOTA + "/constraints")); + $(http().client(apiManager).receive().response(HttpStatus.OK).message().type(MessageType.JSON) + .validate(jsonPath() + .expression("$.[?(@.api=='${apiId}')].id", "${api1ConstraintId}") + .expression("$.[?(@.api=='${apiId}')].config.messages", "3000"))); + } +} diff --git a/modules/apis/src/test/java/com/axway/apim/test/quota/QuotaModeReplaceTestIT.java b/modules/apis/src/test/java/com/axway/apim/test/quota/QuotaModeReplaceTestIT.java index 2bb250535..801b7e13e 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/quota/QuotaModeReplaceTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/quota/QuotaModeReplaceTestIT.java @@ -5,7 +5,7 @@ import com.axway.apim.lib.CoreParameters.Mode; import com.axway.apim.test.ImportTestAction; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; @@ -16,10 +16,10 @@ import java.io.IOException; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; import static org.citrusframework.actions.SleepAction.Builder.sleep; -import static org.citrusframework.dsl.JsonPathSupport.jsonPath; +import static org.citrusframework.json.dsl.JsonPathSupport.jsonPath; import static org.citrusframework.http.actions.HttpActionBuilder.http; import static org.citrusframework.validation.DelegatingPayloadVariableExtractor.Builder.fromBody; diff --git a/modules/apis/src/test/java/com/axway/apim/test/quota/QuotaStays4OtherAPIsTestIT.java b/modules/apis/src/test/java/com/axway/apim/test/quota/QuotaStays4OtherAPIsTestIT.java index 7c0d6b038..3d9002e99 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/quota/QuotaStays4OtherAPIsTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/quota/QuotaStays4OtherAPIsTestIT.java @@ -3,7 +3,7 @@ import com.axway.apim.EndpointConfig; import com.axway.apim.test.ImportTestAction; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; @@ -14,10 +14,10 @@ import java.io.IOException; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; import static org.citrusframework.actions.SleepAction.Builder.sleep; -import static org.citrusframework.dsl.JsonPathSupport.jsonPath; +import static org.citrusframework.json.dsl.JsonPathSupport.jsonPath; import static org.citrusframework.http.actions.HttpActionBuilder.http; import static org.citrusframework.validation.DelegatingPayloadVariableExtractor.Builder.fromBody; diff --git a/modules/apis/src/test/java/com/axway/apim/test/quota/ReCreateAPIQuotaStaysTestIT.java b/modules/apis/src/test/java/com/axway/apim/test/quota/ReCreateAPIQuotaStaysTestIT.java index 3cbc61be9..eb3df52d8 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/quota/ReCreateAPIQuotaStaysTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/quota/ReCreateAPIQuotaStaysTestIT.java @@ -3,7 +3,7 @@ import com.axway.apim.EndpointConfig; import com.axway.apim.test.ImportTestAction; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; @@ -14,10 +14,10 @@ import java.io.IOException; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; import static org.citrusframework.actions.SleepAction.Builder.sleep; -import static org.citrusframework.dsl.JsonPathSupport.jsonPath; +import static org.citrusframework.json.dsl.JsonPathSupport.jsonPath; import static org.citrusframework.http.actions.HttpActionBuilder.http; import static org.citrusframework.validation.DelegatingPayloadVariableExtractor.Builder.fromBody; diff --git a/modules/apis/src/test/java/com/axway/apim/test/quota/ValidateAppQuotaStaysTestIT.java b/modules/apis/src/test/java/com/axway/apim/test/quota/ValidateAppQuotaStaysTestIT.java index c0d732b80..d472035c8 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/quota/ValidateAppQuotaStaysTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/quota/ValidateAppQuotaStaysTestIT.java @@ -3,7 +3,7 @@ import com.axway.apim.EndpointConfig; import com.axway.apim.test.ImportTestAction; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; @@ -14,10 +14,10 @@ import java.io.IOException; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; import static org.citrusframework.actions.SleepAction.Builder.sleep; -import static org.citrusframework.dsl.JsonPathSupport.jsonPath; +import static org.citrusframework.json.dsl.JsonPathSupport.jsonPath; import static org.citrusframework.http.actions.HttpActionBuilder.http; import static org.citrusframework.validation.DelegatingPayloadVariableExtractor.Builder.fromBody; diff --git a/modules/apis/src/test/java/com/axway/apim/test/security/InvokeAuthPolicyTestIT.java b/modules/apis/src/test/java/com/axway/apim/test/security/InvokeAuthPolicyTestIT.java index 43bcaa234..bf7ae46ce 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/security/InvokeAuthPolicyTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/security/InvokeAuthPolicyTestIT.java @@ -3,7 +3,7 @@ import com.axway.apim.EndpointConfig; import com.axway.apim.test.ImportTestAction; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; @@ -12,9 +12,9 @@ import org.springframework.test.context.ContextConfiguration; import org.testng.annotations.Test; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; -import static org.citrusframework.dsl.JsonPathSupport.jsonPath; +import static org.citrusframework.json.dsl.JsonPathSupport.jsonPath; import static org.citrusframework.http.actions.HttpActionBuilder.http; import static org.citrusframework.validation.DelegatingPayloadVariableExtractor.Builder.fromBody; diff --git a/modules/apis/src/test/java/com/axway/apim/test/security/NoAuthenticationGivenTestIT.java b/modules/apis/src/test/java/com/axway/apim/test/security/NoAuthenticationGivenTestIT.java index 20e898e89..a85449aaf 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/security/NoAuthenticationGivenTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/security/NoAuthenticationGivenTestIT.java @@ -3,7 +3,7 @@ import com.axway.apim.EndpointConfig; import com.axway.apim.test.ImportTestAction; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; @@ -12,9 +12,9 @@ import org.springframework.test.context.ContextConfiguration; import org.testng.annotations.Test; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; -import static org.citrusframework.dsl.JsonPathSupport.jsonPath; +import static org.citrusframework.json.dsl.JsonPathSupport.jsonPath; import static org.citrusframework.http.actions.HttpActionBuilder.http; @ContextConfiguration(classes = {EndpointConfig.class}) diff --git a/modules/apis/src/test/java/com/axway/apim/test/security/OutboundBasicAuthTestIT.java b/modules/apis/src/test/java/com/axway/apim/test/security/OutboundBasicAuthTestIT.java index 2d431c9f9..c00a9e98d 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/security/OutboundBasicAuthTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/security/OutboundBasicAuthTestIT.java @@ -3,7 +3,7 @@ import com.axway.apim.EndpointConfig; import com.axway.apim.test.ImportTestAction; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; @@ -14,9 +14,9 @@ import java.io.IOException; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; -import static org.citrusframework.dsl.JsonPathSupport.jsonPath; +import static org.citrusframework.json.dsl.JsonPathSupport.jsonPath; import static org.citrusframework.http.actions.HttpActionBuilder.http; import static org.citrusframework.validation.DelegatingPayloadVariableExtractor.Builder.fromBody; diff --git a/modules/apis/src/test/java/com/axway/apim/test/security/OutboundNoAuthWithPoliciesTestIT.java b/modules/apis/src/test/java/com/axway/apim/test/security/OutboundNoAuthWithPoliciesTestIT.java index e0310e884..0b8b80450 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/security/OutboundNoAuthWithPoliciesTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/security/OutboundNoAuthWithPoliciesTestIT.java @@ -3,7 +3,7 @@ import com.axway.apim.EndpointConfig; import com.axway.apim.test.ImportTestAction; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; @@ -14,9 +14,9 @@ import java.io.IOException; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; -import static org.citrusframework.dsl.JsonPathSupport.jsonPath; +import static org.citrusframework.json.dsl.JsonPathSupport.jsonPath; import static org.citrusframework.http.actions.HttpActionBuilder.http; diff --git a/modules/apis/src/test/java/com/axway/apim/test/security/OutboundOAuthTestIT.java b/modules/apis/src/test/java/com/axway/apim/test/security/OutboundOAuthTestIT.java index a599754e6..e4b0db5f9 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/security/OutboundOAuthTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/security/OutboundOAuthTestIT.java @@ -3,7 +3,7 @@ import com.axway.apim.EndpointConfig; import com.axway.apim.test.ImportTestAction; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; @@ -14,9 +14,9 @@ import java.io.IOException; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; -import static org.citrusframework.dsl.JsonPathSupport.jsonPath; +import static org.citrusframework.json.dsl.JsonPathSupport.jsonPath; import static org.citrusframework.http.actions.HttpActionBuilder.http; diff --git a/modules/apis/src/test/java/com/axway/apim/test/security/OutboundSSLTestIT.java b/modules/apis/src/test/java/com/axway/apim/test/security/OutboundSSLTestIT.java index e50cf1a02..24eb34dda 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/security/OutboundSSLTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/security/OutboundSSLTestIT.java @@ -3,7 +3,7 @@ import com.axway.apim.EndpointConfig; import com.axway.apim.test.ImportTestAction; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; @@ -14,9 +14,9 @@ import java.io.IOException; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; -import static org.citrusframework.dsl.JsonPathSupport.jsonPath; +import static org.citrusframework.json.dsl.JsonPathSupport.jsonPath; import static org.citrusframework.http.actions.HttpActionBuilder.http; import static org.citrusframework.validation.DelegatingPayloadVariableExtractor.Builder.fromBody; diff --git a/modules/apis/src/test/java/com/axway/apim/test/security/UnpublishedApiKeyTestIT.java b/modules/apis/src/test/java/com/axway/apim/test/security/UnpublishedApiKeyTestIT.java index 9b28f8036..ee00c6e08 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/security/UnpublishedApiKeyTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/security/UnpublishedApiKeyTestIT.java @@ -3,7 +3,7 @@ import com.axway.apim.EndpointConfig; import com.axway.apim.test.ImportTestAction; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; @@ -12,9 +12,9 @@ import org.springframework.test.context.ContextConfiguration; import org.testng.annotations.Test; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; -import static org.citrusframework.dsl.JsonPathSupport.jsonPath; +import static org.citrusframework.json.dsl.JsonPathSupport.jsonPath; import static org.citrusframework.http.actions.HttpActionBuilder.http; import static org.citrusframework.validation.DelegatingPayloadVariableExtractor.Builder.fromBody; diff --git a/modules/apis/src/test/java/com/axway/apim/test/security/UnpublishedOAuthExternalTestIT.java b/modules/apis/src/test/java/com/axway/apim/test/security/UnpublishedOAuthExternalTestIT.java index 142325dff..5f7c6ad70 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/security/UnpublishedOAuthExternalTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/security/UnpublishedOAuthExternalTestIT.java @@ -3,7 +3,7 @@ import com.axway.apim.EndpointConfig; import com.axway.apim.test.ImportTestAction; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; @@ -12,9 +12,9 @@ import org.springframework.test.context.ContextConfiguration; import org.testng.annotations.Test; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; -import static org.citrusframework.dsl.JsonPathSupport.jsonPath; +import static org.citrusframework.json.dsl.JsonPathSupport.jsonPath; import static org.citrusframework.http.actions.HttpActionBuilder.http; import static org.citrusframework.validation.DelegatingPayloadVariableExtractor.Builder.fromBody; diff --git a/modules/apis/src/test/java/com/axway/apim/test/security/UnpublishedOAuthTestIT.java b/modules/apis/src/test/java/com/axway/apim/test/security/UnpublishedOAuthTestIT.java index 736f32f09..42b21b688 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/security/UnpublishedOAuthTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/security/UnpublishedOAuthTestIT.java @@ -3,7 +3,7 @@ import com.axway.apim.EndpointConfig; import com.axway.apim.test.ImportTestAction; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; @@ -12,9 +12,9 @@ import org.springframework.test.context.ContextConfiguration; import org.testng.annotations.Test; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; -import static org.citrusframework.dsl.JsonPathSupport.jsonPath; +import static org.citrusframework.json.dsl.JsonPathSupport.jsonPath; import static org.citrusframework.http.actions.HttpActionBuilder.http; import static org.citrusframework.validation.DelegatingPayloadVariableExtractor.Builder.fromBody; diff --git a/modules/apis/src/test/java/com/axway/apim/test/security/UnpublishedPublishedApiKeyTestIT.java b/modules/apis/src/test/java/com/axway/apim/test/security/UnpublishedPublishedApiKeyTestIT.java index 34dfa93bf..10e741830 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/security/UnpublishedPublishedApiKeyTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/security/UnpublishedPublishedApiKeyTestIT.java @@ -2,7 +2,7 @@ import com.axway.apim.EndpointConfig; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; @@ -13,9 +13,9 @@ import com.axway.apim.test.ImportTestAction; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; -import static org.citrusframework.dsl.JsonPathSupport.jsonPath; +import static org.citrusframework.json.dsl.JsonPathSupport.jsonPath; import static org.citrusframework.http.actions.HttpActionBuilder.http; import static org.citrusframework.validation.DelegatingPayloadVariableExtractor.Builder.fromBody; diff --git a/modules/apis/src/test/java/com/axway/apim/test/serviceprofile/BackendBasepathChangeInSwaggerTestIT.java b/modules/apis/src/test/java/com/axway/apim/test/serviceprofile/BackendBasepathChangeInSwaggerTestIT.java index f23ef8e50..87386e159 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/serviceprofile/BackendBasepathChangeInSwaggerTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/serviceprofile/BackendBasepathChangeInSwaggerTestIT.java @@ -2,9 +2,9 @@ import com.axway.apim.EndpointConfig; import com.axway.apim.test.ImportTestAction; -import org.citrusframework.DefaultTestActionBuilder; +import org.citrusframework.dsl.DefaultTestActionBuilder; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; import org.springframework.beans.factory.annotation.Autowired; diff --git a/modules/apis/src/test/java/com/axway/apim/test/staging/NestedPropertyStagingTestIT.java b/modules/apis/src/test/java/com/axway/apim/test/staging/NestedPropertyStagingTestIT.java index d53bcc40f..9115a8fa1 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/staging/NestedPropertyStagingTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/staging/NestedPropertyStagingTestIT.java @@ -2,7 +2,7 @@ import com.axway.apim.EndpointConfig; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; @@ -12,9 +12,9 @@ import org.testng.annotations.Test; import com.axway.apim.test.ImportTestAction; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; -import static org.citrusframework.dsl.JsonPathSupport.jsonPath; +import static org.citrusframework.json.dsl.JsonPathSupport.jsonPath; import static org.citrusframework.http.actions.HttpActionBuilder.http; import static org.citrusframework.validation.DelegatingPayloadVariableExtractor.Builder.fromBody; diff --git a/modules/apis/src/test/java/com/axway/apim/test/staging/SimpleStagingTestIT.java b/modules/apis/src/test/java/com/axway/apim/test/staging/SimpleStagingTestIT.java index 31435c5fe..846a88610 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/staging/SimpleStagingTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/staging/SimpleStagingTestIT.java @@ -2,7 +2,7 @@ import com.axway.apim.EndpointConfig; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; @@ -12,9 +12,9 @@ import org.testng.annotations.Test; import com.axway.apim.test.ImportTestAction; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; -import static org.citrusframework.dsl.JsonPathSupport.jsonPath; +import static org.citrusframework.json.dsl.JsonPathSupport.jsonPath; import static org.citrusframework.http.actions.HttpActionBuilder.http; import static org.citrusframework.validation.DelegatingPayloadVariableExtractor.Builder.fromBody; diff --git a/modules/apis/src/test/java/com/axway/apim/test/tags/APINoTagsChangedTestIT.java b/modules/apis/src/test/java/com/axway/apim/test/tags/APINoTagsChangedTestIT.java index 501a26c21..6ae2ba6ea 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/tags/APINoTagsChangedTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/tags/APINoTagsChangedTestIT.java @@ -2,7 +2,7 @@ import com.axway.apim.EndpointConfig; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; @@ -12,9 +12,9 @@ import org.testng.annotations.Test; import com.axway.apim.test.ImportTestAction; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; -import static org.citrusframework.dsl.JsonPathSupport.jsonPath; +import static org.citrusframework.json.dsl.JsonPathSupport.jsonPath; import static org.citrusframework.http.actions.HttpActionBuilder.http; import static org.citrusframework.validation.DelegatingPayloadVariableExtractor.Builder.fromBody; diff --git a/modules/apis/src/test/java/com/axway/apim/test/tags/APITagsTestIT.java b/modules/apis/src/test/java/com/axway/apim/test/tags/APITagsTestIT.java index 02d23f7cb..728269353 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/tags/APITagsTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/tags/APITagsTestIT.java @@ -2,7 +2,7 @@ import com.axway.apim.EndpointConfig; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; @@ -12,9 +12,9 @@ import org.testng.annotations.Test; import com.axway.apim.test.ImportTestAction; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; -import static org.citrusframework.dsl.JsonPathSupport.jsonPath; +import static org.citrusframework.json.dsl.JsonPathSupport.jsonPath; import static org.citrusframework.http.actions.HttpActionBuilder.http; import static org.citrusframework.validation.DelegatingPayloadVariableExtractor.Builder.fromBody; diff --git a/modules/apis/src/test/java/com/axway/apim/test/version/UnpublishedAPIVersionTestIT.java b/modules/apis/src/test/java/com/axway/apim/test/version/UnpublishedAPIVersionTestIT.java index 7353a38b1..e8d0087fd 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/version/UnpublishedAPIVersionTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/version/UnpublishedAPIVersionTestIT.java @@ -3,7 +3,7 @@ import com.axway.apim.EndpointConfig; import com.axway.apim.test.ImportTestAction; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; @@ -11,9 +11,9 @@ import org.springframework.http.HttpStatus; import org.springframework.test.context.ContextConfiguration; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; -import static org.citrusframework.dsl.JsonPathSupport.jsonPath; +import static org.citrusframework.json.dsl.JsonPathSupport.jsonPath; import static org.citrusframework.http.actions.HttpActionBuilder.http; import static org.citrusframework.validation.DelegatingPayloadVariableExtractor.Builder.fromBody; diff --git a/modules/apis/src/test/java/com/axway/apim/test/vhost/VhostConfigOrgWithVHostTestIT.java b/modules/apis/src/test/java/com/axway/apim/test/vhost/VhostConfigOrgWithVHostTestIT.java index a5bb8a2ef..d9113b8fc 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/vhost/VhostConfigOrgWithVHostTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/vhost/VhostConfigOrgWithVHostTestIT.java @@ -5,7 +5,7 @@ import org.citrusframework.annotations.CitrusResource; import org.citrusframework.annotations.CitrusTest; import org.citrusframework.context.TestContext; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; @@ -19,7 +19,7 @@ import java.io.IOException; import static org.citrusframework.actions.EchoAction.Builder.echo; -import static org.citrusframework.dsl.JsonPathSupport.jsonPath; +import static org.citrusframework.json.dsl.JsonPathSupport.jsonPath; import static org.citrusframework.http.actions.HttpActionBuilder.http; import static org.citrusframework.validation.DelegatingPayloadVariableExtractor.Builder.fromBody; diff --git a/modules/apis/src/test/java/com/axway/apim/test/vhost/VhostConfigTestIT.java b/modules/apis/src/test/java/com/axway/apim/test/vhost/VhostConfigTestIT.java index 479e8f159..72793aac5 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/vhost/VhostConfigTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/vhost/VhostConfigTestIT.java @@ -5,7 +5,7 @@ import org.citrusframework.annotations.CitrusResource; import org.citrusframework.annotations.CitrusTest; import org.citrusframework.context.TestContext; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; @@ -18,7 +18,7 @@ import java.io.IOException; import static org.citrusframework.actions.EchoAction.Builder.echo; -import static org.citrusframework.dsl.JsonPathSupport.jsonPath; +import static org.citrusframework.json.dsl.JsonPathSupport.jsonPath; import static org.citrusframework.http.actions.HttpActionBuilder.http; import static org.citrusframework.validation.DelegatingPayloadVariableExtractor.Builder.fromBody; diff --git a/modules/apis/src/test/java/com/axway/apim/test/wsdl/WSDLFromURLDirectTestIT.java b/modules/apis/src/test/java/com/axway/apim/test/wsdl/WSDLFromURLDirectTestIT.java index 9ae74ea87..97e243152 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/wsdl/WSDLFromURLDirectTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/wsdl/WSDLFromURLDirectTestIT.java @@ -5,7 +5,7 @@ import org.citrusframework.annotations.CitrusResource; import org.citrusframework.annotations.CitrusTest; import org.citrusframework.context.TestContext; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; @@ -20,7 +20,7 @@ import static org.citrusframework.actions.EchoAction.Builder.echo; import static org.citrusframework.http.actions.HttpActionBuilder.http; import static org.citrusframework.validation.DelegatingPayloadVariableExtractor.Builder.fromBody; -import static org.citrusframework.validation.json.JsonPathMessageValidationContext.Builder.jsonPath; +import static org.citrusframework.validation.context.json.JsonPathMessageValidationContext.Builder.jsonPath; @ContextConfiguration(classes = {EndpointConfig.class}) public class WSDLFromURLDirectTestIT extends TestNGCitrusSpringSupport { diff --git a/modules/apis/src/test/java/com/axway/apim/test/wsdl/WSDLFromURLInConfigurationDirectTestIT.java b/modules/apis/src/test/java/com/axway/apim/test/wsdl/WSDLFromURLInConfigurationDirectTestIT.java index 1ffdbefc1..836a49a72 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/wsdl/WSDLFromURLInConfigurationDirectTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/wsdl/WSDLFromURLInConfigurationDirectTestIT.java @@ -3,7 +3,7 @@ import com.axway.apim.EndpointConfig; import com.axway.apim.test.ImportTestAction; import org.citrusframework.annotations.CitrusTest; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; @@ -14,11 +14,11 @@ import java.io.IOException; -import static org.citrusframework.DefaultTestActionBuilder.action; +import static org.citrusframework.dsl.DefaultTestActionBuilder.action; import static org.citrusframework.actions.EchoAction.Builder.echo; import static org.citrusframework.http.actions.HttpActionBuilder.http; import static org.citrusframework.validation.DelegatingPayloadVariableExtractor.Builder.fromBody; -import static org.citrusframework.validation.json.JsonPathMessageValidationContext.Builder.jsonPath; +import static org.citrusframework.validation.context.json.JsonPathMessageValidationContext.Builder.jsonPath; @ContextConfiguration(classes = {EndpointConfig.class}) public class WSDLFromURLInConfigurationDirectTestIT extends TestNGCitrusSpringSupport { diff --git a/modules/apis/src/test/java/com/axway/apim/test/wsdl/WSDLFromURLRefFileInConfigurationTestIT.java b/modules/apis/src/test/java/com/axway/apim/test/wsdl/WSDLFromURLRefFileInConfigurationTestIT.java index e24d62314..cb62387c1 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/wsdl/WSDLFromURLRefFileInConfigurationTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/wsdl/WSDLFromURLRefFileInConfigurationTestIT.java @@ -5,7 +5,7 @@ import org.citrusframework.annotations.CitrusResource; import org.citrusframework.annotations.CitrusTest; import org.citrusframework.context.TestContext; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; @@ -20,7 +20,7 @@ import static org.citrusframework.actions.EchoAction.Builder.echo; import static org.citrusframework.http.actions.HttpActionBuilder.http; import static org.citrusframework.validation.DelegatingPayloadVariableExtractor.Builder.fromBody; -import static org.citrusframework.validation.json.JsonPathMessageValidationContext.Builder.jsonPath; +import static org.citrusframework.validation.context.json.JsonPathMessageValidationContext.Builder.jsonPath; @ContextConfiguration(classes = {EndpointConfig.class}) public class WSDLFromURLRefFileInConfigurationTestIT extends TestNGCitrusSpringSupport { diff --git a/modules/apis/src/test/java/com/axway/apim/test/wsdl/WSDLFromURLRefFileTestIT.java b/modules/apis/src/test/java/com/axway/apim/test/wsdl/WSDLFromURLRefFileTestIT.java index e3d502b27..5bdc247b9 100644 --- a/modules/apis/src/test/java/com/axway/apim/test/wsdl/WSDLFromURLRefFileTestIT.java +++ b/modules/apis/src/test/java/com/axway/apim/test/wsdl/WSDLFromURLRefFileTestIT.java @@ -5,7 +5,7 @@ import org.citrusframework.annotations.CitrusResource; import org.citrusframework.annotations.CitrusTest; import org.citrusframework.context.TestContext; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; @@ -20,7 +20,7 @@ import static org.citrusframework.actions.EchoAction.Builder.echo; import static org.citrusframework.http.actions.HttpActionBuilder.http; import static org.citrusframework.validation.DelegatingPayloadVariableExtractor.Builder.fromBody; -import static org.citrusframework.validation.json.JsonPathMessageValidationContext.Builder.jsonPath; +import static org.citrusframework.validation.context.json.JsonPathMessageValidationContext.Builder.jsonPath; @ContextConfiguration(classes = {EndpointConfig.class}) public class WSDLFromURLRefFileTestIT extends TestNGCitrusSpringSupport { diff --git a/modules/apps/src/main/java/com/axway/apim/appexport/impl/JsonApplicationExporter.java b/modules/apps/src/main/java/com/axway/apim/appexport/impl/JsonApplicationExporter.java index e0dd42b00..fdf7f0c0f 100644 --- a/modules/apps/src/main/java/com/axway/apim/appexport/impl/JsonApplicationExporter.java +++ b/modules/apps/src/main/java/com/axway/apim/appexport/impl/JsonApplicationExporter.java @@ -94,11 +94,11 @@ public void saveApplicationLocally(ObjectMapper mapper, ExportApplication app, S public void writeContent(ExportApplication app, ObjectMapper mapper, File localFolder, String configFile) throws AppException { try { - mapper.enable(SerializationFeature.INDENT_OUTPUT); + // Use ObjectWriter to avoid mutating the shared mapper instance if (EnvironmentProperties.PRINT_CONFIG_CONSOLE) { - mapper.writeValue(System.out, app); + mapper.writer().with(SerializationFeature.INDENT_OUTPUT).writeValue(System.out, app); } else { - mapper.writeValue(new File(localFolder.getCanonicalPath() + configFile), app); + mapper.writer().with(SerializationFeature.INDENT_OUTPUT).writeValue(new File(localFolder.getCanonicalPath() + configFile), app); } } catch (Exception e) { throw new AppException("Can't write Application-Configuration file for application: '" + app.getName() + "'", ErrorCode.UNXPECTED_ERROR, e); diff --git a/modules/apps/src/test/java/com/axway/apim/appimport/it/appQuota/ImportAppWithQuotasTestIT.java b/modules/apps/src/test/java/com/axway/apim/appimport/it/appQuota/ImportAppWithQuotasTestIT.java index 2af61c7d0..4daa050b6 100644 --- a/modules/apps/src/test/java/com/axway/apim/appimport/it/appQuota/ImportAppWithQuotasTestIT.java +++ b/modules/apps/src/test/java/com/axway/apim/appimport/it/appQuota/ImportAppWithQuotasTestIT.java @@ -15,9 +15,9 @@ import org.citrusframework.annotations.CitrusResource; import org.citrusframework.annotations.CitrusTest; import org.citrusframework.context.TestContext; -import org.citrusframework.dsl.JsonPathSupport; +import org.citrusframework.json.dsl.JsonPathSupport; import org.citrusframework.exceptions.ValidationException; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; diff --git a/modules/apps/src/test/java/com/axway/apim/appimport/it/basic/ImportAppInvalidAPITestIT.java b/modules/apps/src/test/java/com/axway/apim/appimport/it/basic/ImportAppInvalidAPITestIT.java index 6cf950a6c..3a964db65 100644 --- a/modules/apps/src/test/java/com/axway/apim/appimport/it/basic/ImportAppInvalidAPITestIT.java +++ b/modules/apps/src/test/java/com/axway/apim/appimport/it/basic/ImportAppInvalidAPITestIT.java @@ -6,7 +6,7 @@ import org.citrusframework.annotations.CitrusTest; import org.citrusframework.context.TestContext; import org.citrusframework.exceptions.ValidationException; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; import org.testng.annotations.Optional; import org.testng.annotations.Test; diff --git a/modules/apps/src/test/java/com/axway/apim/appimport/it/basic/ImportApplicationWithAPIAccessTestIT.java b/modules/apps/src/test/java/com/axway/apim/appimport/it/basic/ImportApplicationWithAPIAccessTestIT.java index 597623ee1..3f9de8ff9 100644 --- a/modules/apps/src/test/java/com/axway/apim/appimport/it/basic/ImportApplicationWithAPIAccessTestIT.java +++ b/modules/apps/src/test/java/com/axway/apim/appimport/it/basic/ImportApplicationWithAPIAccessTestIT.java @@ -7,9 +7,9 @@ import org.citrusframework.annotations.CitrusResource; import org.citrusframework.annotations.CitrusTest; import org.citrusframework.context.TestContext; -import org.citrusframework.dsl.JsonPathSupport; +import org.citrusframework.json.dsl.JsonPathSupport; import org.citrusframework.exceptions.ValidationException; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; diff --git a/modules/apps/src/test/java/com/axway/apim/appimport/it/basic/ImportCompleteApplicationTestIT.java b/modules/apps/src/test/java/com/axway/apim/appimport/it/basic/ImportCompleteApplicationTestIT.java index 4c298e7ef..695d4ee20 100644 --- a/modules/apps/src/test/java/com/axway/apim/appimport/it/basic/ImportCompleteApplicationTestIT.java +++ b/modules/apps/src/test/java/com/axway/apim/appimport/it/basic/ImportCompleteApplicationTestIT.java @@ -6,9 +6,9 @@ import org.citrusframework.annotations.CitrusResource; import org.citrusframework.annotations.CitrusTest; import org.citrusframework.context.TestContext; -import org.citrusframework.dsl.JsonPathSupport; +import org.citrusframework.json.dsl.JsonPathSupport; import org.citrusframework.exceptions.ValidationException; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; diff --git a/modules/apps/src/test/java/com/axway/apim/appimport/it/basic/ImportCompleteApplicationWithOauthResourcesTestIT.java b/modules/apps/src/test/java/com/axway/apim/appimport/it/basic/ImportCompleteApplicationWithOauthResourcesTestIT.java index a8af16816..96ecb8ac0 100644 --- a/modules/apps/src/test/java/com/axway/apim/appimport/it/basic/ImportCompleteApplicationWithOauthResourcesTestIT.java +++ b/modules/apps/src/test/java/com/axway/apim/appimport/it/basic/ImportCompleteApplicationWithOauthResourcesTestIT.java @@ -6,9 +6,9 @@ import org.citrusframework.annotations.CitrusResource; import org.citrusframework.annotations.CitrusTest; import org.citrusframework.context.TestContext; -import org.citrusframework.dsl.JsonPathSupport; +import org.citrusframework.json.dsl.JsonPathSupport; import org.citrusframework.exceptions.ValidationException; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; diff --git a/modules/apps/src/test/java/com/axway/apim/appimport/it/basic/ImportSimpleApplicationTestIT.java b/modules/apps/src/test/java/com/axway/apim/appimport/it/basic/ImportSimpleApplicationTestIT.java index ca418d1bb..a67e9471f 100644 --- a/modules/apps/src/test/java/com/axway/apim/appimport/it/basic/ImportSimpleApplicationTestIT.java +++ b/modules/apps/src/test/java/com/axway/apim/appimport/it/basic/ImportSimpleApplicationTestIT.java @@ -6,9 +6,9 @@ import org.citrusframework.annotations.CitrusResource; import org.citrusframework.annotations.CitrusTest; import org.citrusframework.context.TestContext; -import org.citrusframework.dsl.JsonPathSupport; +import org.citrusframework.json.dsl.JsonPathSupport; import org.citrusframework.exceptions.ValidationException; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; diff --git a/modules/apps/src/test/java/com/axway/apim/appimport/it/customProperties/ImportExportWithCustomPropsTestIT.java b/modules/apps/src/test/java/com/axway/apim/appimport/it/customProperties/ImportExportWithCustomPropsTestIT.java index ee017b81c..a0ca87356 100644 --- a/modules/apps/src/test/java/com/axway/apim/appimport/it/customProperties/ImportExportWithCustomPropsTestIT.java +++ b/modules/apps/src/test/java/com/axway/apim/appimport/it/customProperties/ImportExportWithCustomPropsTestIT.java @@ -9,9 +9,9 @@ import org.citrusframework.annotations.CitrusResource; import org.citrusframework.annotations.CitrusTest; import org.citrusframework.context.TestContext; -import org.citrusframework.dsl.JsonPathSupport; +import org.citrusframework.json.dsl.JsonPathSupport; import org.citrusframework.exceptions.ValidationException; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; diff --git a/modules/apps/src/test/java/com/axway/apim/appimport/it/share/ImportAppWithPermissionsTestIT.java b/modules/apps/src/test/java/com/axway/apim/appimport/it/share/ImportAppWithPermissionsTestIT.java index fe3152351..7b6adbb27 100644 --- a/modules/apps/src/test/java/com/axway/apim/appimport/it/share/ImportAppWithPermissionsTestIT.java +++ b/modules/apps/src/test/java/com/axway/apim/appimport/it/share/ImportAppWithPermissionsTestIT.java @@ -10,9 +10,9 @@ import org.citrusframework.annotations.CitrusResource; import org.citrusframework.annotations.CitrusTest; import org.citrusframework.context.TestContext; -import org.citrusframework.dsl.JsonPathSupport; +import org.citrusframework.json.dsl.JsonPathSupport; import org.citrusframework.exceptions.ValidationException; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; diff --git a/modules/organizations/src/main/java/com/axway/apim/organization/impl/JsonOrgExporter.java b/modules/organizations/src/main/java/com/axway/apim/organization/impl/JsonOrgExporter.java index bb91dd8e3..e68ded1b0 100644 --- a/modules/organizations/src/main/java/com/axway/apim/organization/impl/JsonOrgExporter.java +++ b/modules/organizations/src/main/java/com/axway/apim/organization/impl/JsonOrgExporter.java @@ -76,11 +76,11 @@ public void saveOrganizationLocally(ObjectMapper mapper, ExportOrganization org, public void writeContent(ExportOrganization org, ObjectMapper mapper, File localFolder, String configFile) throws AppException { try { - mapper.enable(SerializationFeature.INDENT_OUTPUT); + // Use ObjectWriter to avoid mutating the shared mapper instance if (EnvironmentProperties.PRINT_CONFIG_CONSOLE) { - mapper.writeValue(System.out, org); + mapper.writer().with(SerializationFeature.INDENT_OUTPUT).writeValue(System.out, org); } else { - mapper.writeValue(new File(localFolder.getCanonicalPath() + configFile), org); + mapper.writer().with(SerializationFeature.INDENT_OUTPUT).writeValue(new File(localFolder.getCanonicalPath() + configFile), org); } this.result.addExportedFile((localFolder != null ? localFolder.getCanonicalPath() : null) + configFile); } catch (Exception e) { diff --git a/modules/organizations/src/test/java/com/axway/apim/organization/it/tests/ImportExportOrgWithCustomPropsTestIT.java b/modules/organizations/src/test/java/com/axway/apim/organization/it/tests/ImportExportOrgWithCustomPropsTestIT.java index de0457587..206b9c39b 100644 --- a/modules/organizations/src/test/java/com/axway/apim/organization/it/tests/ImportExportOrgWithCustomPropsTestIT.java +++ b/modules/organizations/src/test/java/com/axway/apim/organization/it/tests/ImportExportOrgWithCustomPropsTestIT.java @@ -25,7 +25,7 @@ import static org.citrusframework.actions.EchoAction.Builder.echo; import static org.citrusframework.http.actions.HttpActionBuilder.http; import static org.citrusframework.validation.DelegatingPayloadVariableExtractor.Builder.fromBody; -import static org.citrusframework.validation.json.JsonPathMessageValidationContext.Builder.jsonPath; +import static org.citrusframework.validation.context.json.JsonPathMessageValidationContext.Builder.jsonPath; @ContextConfiguration(classes = {EndpointConfig.class}) public class ImportExportOrgWithCustomPropsTestIT extends TestNGCitrusSpringSupport { diff --git a/modules/organizations/src/test/java/com/axway/apim/organization/it/tests/ImportSimpleOrgAPIAccessTestIT.java b/modules/organizations/src/test/java/com/axway/apim/organization/it/tests/ImportSimpleOrgAPIAccessTestIT.java index 55be8aac5..d4813203f 100644 --- a/modules/organizations/src/test/java/com/axway/apim/organization/it/tests/ImportSimpleOrgAPIAccessTestIT.java +++ b/modules/organizations/src/test/java/com/axway/apim/organization/it/tests/ImportSimpleOrgAPIAccessTestIT.java @@ -7,9 +7,9 @@ import org.citrusframework.annotations.CitrusResource; import org.citrusframework.annotations.CitrusTest; import org.citrusframework.context.TestContext; -import org.citrusframework.dsl.JsonPathSupport; +import org.citrusframework.json.dsl.JsonPathSupport; import org.citrusframework.exceptions.ValidationException; -import org.citrusframework.functions.core.RandomNumberFunction; +import org.citrusframework.base.functions.core.RandomNumberFunction; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; import org.citrusframework.testng.spring.TestNGCitrusSpringSupport; diff --git a/modules/organizations/src/test/java/com/axway/apim/organization/it/tests/ImportSimpleOrganizationTestIT.java b/modules/organizations/src/test/java/com/axway/apim/organization/it/tests/ImportSimpleOrganizationTestIT.java index 71be17074..500495ddc 100644 --- a/modules/organizations/src/test/java/com/axway/apim/organization/it/tests/ImportSimpleOrganizationTestIT.java +++ b/modules/organizations/src/test/java/com/axway/apim/organization/it/tests/ImportSimpleOrganizationTestIT.java @@ -6,7 +6,7 @@ import org.citrusframework.annotations.CitrusResource; import org.citrusframework.annotations.CitrusTest; import org.citrusframework.context.TestContext; -import org.citrusframework.dsl.JsonPathSupport; +import org.citrusframework.json.dsl.JsonPathSupport; import org.citrusframework.exceptions.ValidationException; import org.citrusframework.http.client.HttpClient; import org.citrusframework.message.MessageType; diff --git a/modules/settings/src/main/java/com/axway/apim/setup/impl/JsonAPIManagerSetupExporter.java b/modules/settings/src/main/java/com/axway/apim/setup/impl/JsonAPIManagerSetupExporter.java index b82243c91..4da0908ee 100644 --- a/modules/settings/src/main/java/com/axway/apim/setup/impl/JsonAPIManagerSetupExporter.java +++ b/modules/settings/src/main/java/com/axway/apim/setup/impl/JsonAPIManagerSetupExporter.java @@ -62,7 +62,6 @@ public void exportToFile(ObjectMapper mapper, APIManagerConfig apimanagerConfig, } } try { - mapper.enable(SerializationFeature.INDENT_OUTPUT); mapper.registerModule(new SimpleModule().setSerializerModifier(new PolicySerializerModifier(true))); mapper.registerModule(new SimpleModule().setSerializerModifier(new UserSerializerModifier(true))); FilterProvider filters = new SimpleFilterProvider() @@ -71,10 +70,11 @@ public void exportToFile(ObjectMapper mapper, APIManagerConfig apimanagerConfig, .addFilter("QuotaRestrictionFilter", SimpleBeanPropertyFilter.serializeAllExcept("apiId")) // Is handled in ExportApplication .setFailOnUnknownId(false); mapper.setFilterProvider(filters); + // Use ObjectWriter to avoid mutating the shared mapper instance if (EnvironmentProperties.PRINT_CONFIG_CONSOLE) { - mapper.writeValue(System.out, apimanagerConfig); + mapper.writer().with(SerializationFeature.INDENT_OUTPUT).writeValue(System.out, apimanagerConfig); } else { - mapper.writeValue(new File(localFolder.getCanonicalPath() + configFile), apimanagerConfig); + mapper.writer().with(SerializationFeature.INDENT_OUTPUT).writeValue(new File(localFolder.getCanonicalPath() + configFile), apimanagerConfig); result.addExportedFile(localFolder.getCanonicalPath() + configFile); } } catch (Exception e) { diff --git a/modules/settings/src/test/java/com/axway/apim/setup/it/tests/ImportAndExportAlertsTestIT.java b/modules/settings/src/test/java/com/axway/apim/setup/it/tests/ImportAndExportAlertsTestIT.java index 10354f4af..535fe1a3d 100644 --- a/modules/settings/src/test/java/com/axway/apim/setup/it/tests/ImportAndExportAlertsTestIT.java +++ b/modules/settings/src/test/java/com/axway/apim/setup/it/tests/ImportAndExportAlertsTestIT.java @@ -21,7 +21,7 @@ import static org.citrusframework.actions.EchoAction.Builder.echo; import static org.citrusframework.http.actions.HttpActionBuilder.http; -import static org.citrusframework.validation.json.JsonPathMessageValidationContext.Builder.jsonPath; +import static org.citrusframework.validation.context.json.JsonPathMessageValidationContext.Builder.jsonPath; @ContextConfiguration(classes = {EndpointConfig.class}) public class ImportAndExportAlertsTestIT extends TestNGCitrusSpringSupport { diff --git a/modules/settings/src/test/java/com/axway/apim/setup/it/tests/ImportAndExportConfigTestIT.java b/modules/settings/src/test/java/com/axway/apim/setup/it/tests/ImportAndExportConfigTestIT.java index 4aa327015..280788846 100644 --- a/modules/settings/src/test/java/com/axway/apim/setup/it/tests/ImportAndExportConfigTestIT.java +++ b/modules/settings/src/test/java/com/axway/apim/setup/it/tests/ImportAndExportConfigTestIT.java @@ -23,7 +23,7 @@ import static org.citrusframework.actions.EchoAction.Builder.echo; import static org.citrusframework.http.actions.HttpActionBuilder.http; -import static org.citrusframework.validation.json.JsonPathMessageValidationContext.Builder.jsonPath; +import static org.citrusframework.validation.context.json.JsonPathMessageValidationContext.Builder.jsonPath; @ContextConfiguration(classes = {EndpointConfig.class}) @Test diff --git a/modules/settings/src/test/java/com/axway/apim/setup/it/tests/ImportAndExportRemoteHostsTestIT.java b/modules/settings/src/test/java/com/axway/apim/setup/it/tests/ImportAndExportRemoteHostsTestIT.java index 6c477b775..2933ed93a 100644 --- a/modules/settings/src/test/java/com/axway/apim/setup/it/tests/ImportAndExportRemoteHostsTestIT.java +++ b/modules/settings/src/test/java/com/axway/apim/setup/it/tests/ImportAndExportRemoteHostsTestIT.java @@ -22,7 +22,7 @@ import static org.citrusframework.actions.EchoAction.Builder.echo; import static org.citrusframework.http.actions.HttpActionBuilder.http; import static org.citrusframework.validation.DelegatingPayloadVariableExtractor.Builder.fromBody; -import static org.citrusframework.validation.json.JsonPathMessageValidationContext.Builder.jsonPath; +import static org.citrusframework.validation.context.json.JsonPathMessageValidationContext.Builder.jsonPath; @ContextConfiguration(classes = {EndpointConfig.class}) public class ImportAndExportRemoteHostsTestIT extends TestNGCitrusSpringSupport { diff --git a/modules/spectoconfig/src/main/java/com/axway/apim/config/GenerateTemplate.java b/modules/spectoconfig/src/main/java/com/axway/apim/config/GenerateTemplate.java index 2ee414a14..6a445799a 100644 --- a/modules/spectoconfig/src/main/java/com/axway/apim/config/GenerateTemplate.java +++ b/modules/spectoconfig/src/main/java/com/axway/apim/config/GenerateTemplate.java @@ -31,7 +31,7 @@ import io.swagger.v3.parser.core.models.ParseOptions; import io.swagger.v3.parser.core.models.SwaggerParseResult; import org.apache.commons.io.IOUtils; -import org.apache.http.HttpHeaders; +import org.apache.hc.core5.http.HttpHeaders; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/modules/users/src/main/java/com/axway/apim/users/impl/JsonUserExporter.java b/modules/users/src/main/java/com/axway/apim/users/impl/JsonUserExporter.java index 217cf234a..43036402f 100644 --- a/modules/users/src/main/java/com/axway/apim/users/impl/JsonUserExporter.java +++ b/modules/users/src/main/java/com/axway/apim/users/impl/JsonUserExporter.java @@ -76,11 +76,11 @@ public void saveUserLocally(ObjectMapper mapper, ExportUser user, String configF public void writeContent(ObjectMapper mapper, ExportUser user, String configFile, File localFolder) throws AppException { try { - mapper.enable(SerializationFeature.INDENT_OUTPUT); + // Use ObjectWriter to avoid mutating the shared mapper instance if (EnvironmentProperties.PRINT_CONFIG_CONSOLE) { - mapper.writeValue(System.out, user); + mapper.writer().with(SerializationFeature.INDENT_OUTPUT).writeValue(System.out, user); } else { - mapper.writeValue(new File(localFolder.getCanonicalPath() + configFile), user); + mapper.writer().with(SerializationFeature.INDENT_OUTPUT).writeValue(new File(localFolder.getCanonicalPath() + configFile), user); } this.result.addExportedFile((localFolder != null ? localFolder.getCanonicalPath() : null) + configFile); } catch (Exception e) { diff --git a/modules/users/src/test/java/com/axway/apim/user/it/tests/ImportExportUserTestIT.java b/modules/users/src/test/java/com/axway/apim/user/it/tests/ImportExportUserTestIT.java index 200af9fea..03367b8cd 100644 --- a/modules/users/src/test/java/com/axway/apim/user/it/tests/ImportExportUserTestIT.java +++ b/modules/users/src/test/java/com/axway/apim/user/it/tests/ImportExportUserTestIT.java @@ -19,7 +19,7 @@ import static org.citrusframework.actions.EchoAction.Builder.echo; import static org.citrusframework.http.actions.HttpActionBuilder.http; import static org.citrusframework.validation.DelegatingPayloadVariableExtractor.Builder.fromBody; -import static org.citrusframework.validation.json.JsonPathMessageValidationContext.Builder.jsonPath; +import static org.citrusframework.validation.context.json.JsonPathMessageValidationContext.Builder.jsonPath; @ContextConfiguration(classes = {EndpointConfig.class}) diff --git a/pom.xml b/pom.xml index c4c46255f..0d414aaa0 100644 --- a/pom.xml +++ b/pom.xml @@ -60,8 +60,12 @@ java:S106 **/*.java https://sonarcloud.io - 4.1.1 - 2.15.3 + 5.1.0 + 2.26.1 + 2.0.20 + 2.22.4 + + 2.22 3.3.2 21.5 4.10.0 @@ -99,15 +103,9 @@ - org.apache.httpcomponents - httpclient - 4.5.14 - - - commons-codec - commons-codec - - + org.apache.httpcomponents.client5 + httpclient5 + 5.6.4 commons-cli @@ -129,10 +127,11 @@ commons-text 1.10.0 + - org.apache.httpcomponents - httpmime - 4.5.14 + com.fasterxml.jackson.core + jackson-annotations + ${jackson.version.annotations} com.fasterxml.jackson.core @@ -154,6 +153,11 @@ jackson-dataformat-xml ${jackson.version} + + com.fasterxml.jackson.datatype + jackson-datatype-jsr310 + ${jackson.version} + org.apache.commons commons-csv @@ -215,12 +219,24 @@ org.slf4j slf4j-api - 1.7.36 + ${slf4j.version} + + + org.apache.logging.log4j + log4j-api + ${log4j.version} + + + org.apache.logging.log4j + log4j-core + ${log4j.version} org.apache.logging.log4j - log4j-slf4j-impl - 2.20.0 + + log4j-slf4j2-impl + ${log4j.version} com.github.freva