Skip to content

Commit

Permalink
Merge branch 'master' into transaction-counter
Browse files Browse the repository at this point in the history
  • Loading branch information
IsuruMaduranga authored Dec 6, 2023
2 parents 162a00e + d49c71a commit 3373fb5
Show file tree
Hide file tree
Showing 27 changed files with 1,581 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
with:
node-version: '10.x'
- name: Build product-apim with Test.
run: mvn clean install --file pom.xml -DskipBenchMarkTest=true
run: mvn clean install --file pom.xml -DskipBenchMarkTest=true -DskipRestartTests=true
env:
PRODUCT_APIM_TEST_GROUPS: ${{ matrix.segment }}
- name: Prepare upload testng report
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,16 @@ For additional support information please refer to http://wso2.com/support

For more information on WSO2 API Manager please visit https://wso2.com/api-management/

Survey On Open Source Community Communication
==================================

WSO2 wants to learn more about our open source software (OSS) community and your communication preferences to serve you better.

In addition, we may reach out to a small number of respondents to ask additional questions and offer a small gift.

Link to survey: https://forms.gle/h5q4M3K7vyXba3bK6


Known Issues of WSO2 API Manager
==================================

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10187,7 +10187,10 @@ paths:
style: simple
responses:
"200":
content: {}
content:
application/json:
schema:
type: string
description: |
OK.
Requested swagger document of the API is returned
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ Name | Type | Description | Notes

<a name="getAPIProductSwagger"></a>
# **getAPIProductSwagger**
> getAPIProductSwagger(apiProductId, accept, ifNoneMatch)
> String getAPIProductSwagger(apiProductId, accept, ifNoneMatch)
Get Swagger Definition

Expand Down Expand Up @@ -261,7 +261,8 @@ public class Example {
String accept = "\"application/json\""; // String | Media types acceptable for the response. Default is application/json.
String ifNoneMatch = "ifNoneMatch_example"; // String | Validator for conditional requests; based on the ETag of the formerly retrieved variant of the resource.
try {
apiInstance.getAPIProductSwagger(apiProductId, accept, ifNoneMatch);
String result = apiInstance.getAPIProductSwagger(apiProductId, accept, ifNoneMatch);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling ApiProductsApi#getAPIProductSwagger");
System.err.println("Status code: " + e.getCode());
Expand All @@ -283,7 +284,7 @@ Name | Type | Description | Notes

### Return type

null (empty response body)
**String**

### Authorization

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,7 @@ private okhttp3.Call getAPIProductSwaggerValidateBeforeCall(String apiProductId,
* @param apiProductId **API Product ID** consisting of the **UUID** of the API Product. Using the **UUID** in the API call is recommended. (required)
* @param accept Media types acceptable for the response. Default is application/json. (optional, default to &quot;application/json&quot;)
* @param ifNoneMatch Validator for conditional requests; based on the ETag of the formerly retrieved variant of the resource. (optional)
* @return String
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
* @http.response.details
<table summary="Response Details" border="1">
Expand All @@ -528,8 +529,9 @@ private okhttp3.Call getAPIProductSwaggerValidateBeforeCall(String apiProductId,
<tr><td> 406 </td><td> Not Acceptable. The requested media type is not supported. </td><td> - </td></tr>
</table>
*/
public void getAPIProductSwagger(String apiProductId, String accept, String ifNoneMatch) throws ApiException {
getAPIProductSwaggerWithHttpInfo(apiProductId, accept, ifNoneMatch);
public String getAPIProductSwagger(String apiProductId, String accept, String ifNoneMatch) throws ApiException {
ApiResponse<String> localVarResp = getAPIProductSwaggerWithHttpInfo(apiProductId, accept, ifNoneMatch);
return localVarResp.getData();
}

/**
Expand All @@ -538,7 +540,7 @@ public void getAPIProductSwagger(String apiProductId, String accept, String ifNo
* @param apiProductId **API Product ID** consisting of the **UUID** of the API Product. Using the **UUID** in the API call is recommended. (required)
* @param accept Media types acceptable for the response. Default is application/json. (optional, default to &quot;application/json&quot;)
* @param ifNoneMatch Validator for conditional requests; based on the ETag of the formerly retrieved variant of the resource. (optional)
* @return ApiResponse&lt;Void&gt;
* @return ApiResponse&lt;String&gt;
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
* @http.response.details
<table summary="Response Details" border="1">
Expand All @@ -549,9 +551,10 @@ public void getAPIProductSwagger(String apiProductId, String accept, String ifNo
<tr><td> 406 </td><td> Not Acceptable. The requested media type is not supported. </td><td> - </td></tr>
</table>
*/
public ApiResponse<Void> getAPIProductSwaggerWithHttpInfo(String apiProductId, String accept, String ifNoneMatch) throws ApiException {
public ApiResponse<String> getAPIProductSwaggerWithHttpInfo(String apiProductId, String accept, String ifNoneMatch) throws ApiException {
okhttp3.Call localVarCall = getAPIProductSwaggerValidateBeforeCall(apiProductId, accept, ifNoneMatch, null);
return localVarApiClient.execute(localVarCall);
Type localVarReturnType = new TypeToken<String>(){}.getType();
return localVarApiClient.execute(localVarCall, localVarReturnType);
}

/**
Expand All @@ -572,10 +575,11 @@ public ApiResponse<Void> getAPIProductSwaggerWithHttpInfo(String apiProductId, S
<tr><td> 406 </td><td> Not Acceptable. The requested media type is not supported. </td><td> - </td></tr>
</table>
*/
public okhttp3.Call getAPIProductSwaggerAsync(String apiProductId, String accept, String ifNoneMatch, final ApiCallback<Void> _callback) throws ApiException {
public okhttp3.Call getAPIProductSwaggerAsync(String apiProductId, String accept, String ifNoneMatch, final ApiCallback<String> _callback) throws ApiException {

okhttp3.Call localVarCall = getAPIProductSwaggerValidateBeforeCall(apiProductId, accept, ifNoneMatch, _callback);
localVarApiClient.executeAsync(localVarCall, _callback);
Type localVarReturnType = new TypeToken<String>(){}.getType();
localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
return localVarCall;
}
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5693,7 +5693,11 @@ paths:
The content type of the body.
schema:
type: string
content: {}
content:
application/json:
schema:
type: string
example: ""
304:
description: |
Not Modified.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,11 @@ public RestAPIAdminImpl(String username, String password, String tenantDomain, S
"apim:api_workflow_view " +
"apim:api_workflow_approve " +
"apim:admin_operation " +
"apim:policies_import_export" +
"apim:policies_import_export " +
"apim:keymanagers_manage " +
"apim:api_category " +
"apim:admin_tier_view " +
"apim:admin_tier_manage " +
"apim:scope_manage";

String accessToken = ClientAuthenticator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1124,6 +1124,13 @@ public String getSwaggerByID(String apiId) throws ApiException {
return response.getData();
}

public String getAPIProductSwaggerByID(String apiProductId) throws ApiException {

ApiResponse<String> response = apiProductsApi.getAPIProductSwaggerWithHttpInfo(apiProductId, null, null);
Assert.assertEquals(HttpStatus.SC_OK, response.getStatusCode());
return response.getData();
}

public String updateSwagger(String apiId, String definition) throws ApiException {

ApiResponse<String> apiResponse = apIsApi.updateAPISwaggerWithHttpInfo(apiId, null, definition, null, null);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
/*
* Copyright (c) 2023, WSO2 LLC. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package org.wso2.am.integration.test.utils;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import java.io.IOException;
import java.net.Socket;
import java.util.Random;

public class MockServerUtils {
private static final Log log = LogFactory.getLog(MockServerUtils.class);
public static String LOCALHOST = "localhost";
public static final int httpPortLowerRange = 8080;
public static final int httpPortUpperRange = 8099;
public static final int httpsPortLowerRange = 9950;
public static final int httpsPortUpperRange = 9999;
private static final int[] reservedPorts = new int[]{ 9960 };
private static int httpOffset = 0;
private static int httpsOffset = 0;
static {
Random random = new Random();
httpOffset = random.nextInt(httpPortUpperRange - httpPortLowerRange + 1) + httpPortLowerRange;
httpsOffset = random.nextInt(httpsPortUpperRange - httpsPortLowerRange + 1) + httpsPortLowerRange;
}
private static final Object lock = new Object();

/**
* Check whether give port is available
*
* @param port Port Number
* @return status
*/
private static boolean isPortFree(int port, String host) {
if (isPortReserved(port)) {
return false;
}
Socket s = null;
try {
s = new Socket(host, port);
// something is using the port and has responded.
return false;
} catch (IOException e) {
//port available
return true;
} finally {
if (s != null) {
try {
s.close();
} catch (IOException e) {
throw new RuntimeException("Unable to close connection ", e);
}
}
}
}

/**
* Find a free port to start backend WebSocket server in given port range
*
* @param isHttps
* @return Available Port Number
*/
public static int getAvailablePort(String host, boolean isHttps) {
synchronized (lock) {
int offset;
int upperPortLimit;
int lowerPortLimit;
if (isHttps) {
offset = httpsOffset;
upperPortLimit = httpsPortUpperRange;
lowerPortLimit = httpsPortLowerRange;
} else {
offset = httpOffset;
upperPortLimit = httpPortUpperRange;
lowerPortLimit = httpPortLowerRange;
}
int portRangeLen = upperPortLimit - lowerPortLimit;
int targetPort = lowerPortLimit + (offset % (portRangeLen + 1));
for (int i = 0; i < portRangeLen; i++) {
if (MockServerUtils.isPortFree(targetPort, host)) {
if (isHttps) {
httpsOffset = (httpsOffset + i + 1) % (portRangeLen + 1);
} else {
httpOffset = (httpOffset + i + 1) % (portRangeLen + 1);
}
log.info("Port " + targetPort + " selected for mock server.");
return targetPort;
}
targetPort ++;
if (targetPort > upperPortLimit) {
targetPort = lowerPortLimit;
}
}
return -1;
}
}

private static boolean isPortReserved(int port) {
for (int prohibitedPort : reservedPorts) {
if (port == prohibitedPort) {
return true;
}
}
return false;
}
}
Loading

0 comments on commit 3373fb5

Please sign in to comment.