Skip to content

Commit

Permalink
Add integration tests for blocking condition search feature
Browse files Browse the repository at this point in the history
  • Loading branch information
YasasRangika committed Jun 5, 2024
1 parent f9e0982 commit 3021788
Show file tree
Hide file tree
Showing 8 changed files with 257 additions and 9 deletions.
15 changes: 15 additions & 0 deletions modules/integration/tests-common/clients/admin/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3219,6 +3219,21 @@ paths:
schema:
type: string
style: simple
- description: |
**Search condition**.
You can search in attributes by using **"conditionType:"** modifier and **"conditionValue:"** modifier.
Eg.
The entry "conditionType:API" will result in a match with blocking conditions only if the conditionType is "API". Similarly, "conditionValue:test/1.0.0" will result in a match with blocking conditions only if the conditionValue is "test/1.0.0".
When you use "conditionType:API & conditionValue:test/1.0.0" as a combination, it will result in a match with blocking conditions only if both the conditionType is "API" and the conditionValue is "test/1.0.0".
If query attribute is provided, this returns the blocking conditions that match the specified attributes.
Please note that you need to use encoded URL (URL encoding) if you are using a client which does not support URL encoding (such as curl)
explode: true
in: query
name: query
required: false
schema:
type: string
style: form
responses:
"200":
content:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public void setApiClient(ApiClient apiClient) {
* @param accept Media types acceptable for the response. Default is application/json. (optional, default to "application/json")
* @param ifNoneMatch Validator for conditional requests; based on the ETag of the formerly retrieved variant of the resource (Will be supported in future). (optional)
* @param ifModifiedSince Validator for conditional requests; based on Last Modified header of the formerly retrieved variant of the resource (Will be supported in future). (optional)
* @param query **Search condition**. You can search in attributes by using **\"conditionType:\"** modifier and **\"conditionValue:\"** modifier. Eg. The entry \"conditionType:API\" will result in a match with blocking conditions only if the conditionType is \"API\". Similarly, \"conditionValue:test/1.0.0\" will result in a match with blocking conditions only if the conditionValue is \"test/1.0.0\". When you use \"conditionType:API & conditionValue:test/1.0.0\" as a combination, it will result in a match with blocking conditions only if both the conditionType is \"API\" and the conditionValue is \"test/1.0.0\". If query attribute is provided, this returns the blocking conditions that match the specified attributes. Please note that you need to use encoded URL (URL encoding) if you are using a client which does not support URL encoding (such as curl) (optional)
* @param _callback Callback for upload/download progress
* @return Call to execute
* @throws ApiException If fail to serialize the request body object
Expand All @@ -72,14 +73,18 @@ public void setApiClient(ApiClient apiClient) {
<tr><td> 406 </td><td> Not Acceptable. The requested media type is not supported. </td><td> - </td></tr>
</table>
*/
public okhttp3.Call throttlingDenyPoliciesGetCall(String accept, String ifNoneMatch, String ifModifiedSince, final ApiCallback _callback) throws ApiException {
public okhttp3.Call throttlingDenyPoliciesGetCall(String accept, String ifNoneMatch, String ifModifiedSince, String query, final ApiCallback _callback) throws ApiException {
Object localVarPostBody = null;

// create path and map variables
String localVarPath = "/throttling/deny-policies";

List<Pair> localVarQueryParams = new ArrayList<Pair>();
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
if (query != null) {
localVarQueryParams.addAll(localVarApiClient.parameterToPair("query", query));
}

Map<String, String> localVarHeaderParams = new HashMap<String, String>();
if (accept != null) {
localVarHeaderParams.put("Accept", localVarApiClient.parameterToString(accept));
Expand Down Expand Up @@ -114,10 +119,10 @@ public okhttp3.Call throttlingDenyPoliciesGetCall(String accept, String ifNoneMa
}

@SuppressWarnings("rawtypes")
private okhttp3.Call throttlingDenyPoliciesGetValidateBeforeCall(String accept, String ifNoneMatch, String ifModifiedSince, final ApiCallback _callback) throws ApiException {
private okhttp3.Call throttlingDenyPoliciesGetValidateBeforeCall(String accept, String ifNoneMatch, String ifModifiedSince, String query, final ApiCallback _callback) throws ApiException {


okhttp3.Call localVarCall = throttlingDenyPoliciesGetCall(accept, ifNoneMatch, ifModifiedSince, _callback);
okhttp3.Call localVarCall = throttlingDenyPoliciesGetCall(accept, ifNoneMatch, ifModifiedSince, query, _callback);
return localVarCall;

}
Expand All @@ -128,6 +133,7 @@ private okhttp3.Call throttlingDenyPoliciesGetValidateBeforeCall(String accept,
* @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 (Will be supported in future). (optional)
* @param ifModifiedSince Validator for conditional requests; based on Last Modified header of the formerly retrieved variant of the resource (Will be supported in future). (optional)
* @param query **Search condition**. You can search in attributes by using **\&quot;conditionType:\&quot;** modifier and **\&quot;conditionValue:\&quot;** modifier. Eg. The entry \&quot;conditionType:API\&quot; will result in a match with blocking conditions only if the conditionType is \&quot;API\&quot;. Similarly, \&quot;conditionValue:test/1.0.0\&quot; will result in a match with blocking conditions only if the conditionValue is \&quot;test/1.0.0\&quot;. When you use \&quot;conditionType:API &amp; conditionValue:test/1.0.0\&quot; as a combination, it will result in a match with blocking conditions only if both the conditionType is \&quot;API\&quot; and the conditionValue is \&quot;test/1.0.0\&quot;. If query attribute is provided, this returns the blocking conditions that match the specified attributes. Please note that you need to use encoded URL (URL encoding) if you are using a client which does not support URL encoding (such as curl) (optional)
* @return BlockingConditionListDTO
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
* @http.response.details
Expand All @@ -138,8 +144,8 @@ private okhttp3.Call throttlingDenyPoliciesGetValidateBeforeCall(String accept,
<tr><td> 406 </td><td> Not Acceptable. The requested media type is not supported. </td><td> - </td></tr>
</table>
*/
public BlockingConditionListDTO throttlingDenyPoliciesGet(String accept, String ifNoneMatch, String ifModifiedSince) throws ApiException {
ApiResponse<BlockingConditionListDTO> localVarResp = throttlingDenyPoliciesGetWithHttpInfo(accept, ifNoneMatch, ifModifiedSince);
public BlockingConditionListDTO throttlingDenyPoliciesGet(String accept, String ifNoneMatch, String ifModifiedSince, String query) throws ApiException {
ApiResponse<BlockingConditionListDTO> localVarResp = throttlingDenyPoliciesGetWithHttpInfo(accept, ifNoneMatch, ifModifiedSince, query);
return localVarResp.getData();
}

Expand All @@ -149,6 +155,7 @@ public BlockingConditionListDTO throttlingDenyPoliciesGet(String accept, String
* @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 (Will be supported in future). (optional)
* @param ifModifiedSince Validator for conditional requests; based on Last Modified header of the formerly retrieved variant of the resource (Will be supported in future). (optional)
* @param query **Search condition**. You can search in attributes by using **\&quot;conditionType:\&quot;** modifier and **\&quot;conditionValue:\&quot;** modifier. Eg. The entry \&quot;conditionType:API\&quot; will result in a match with blocking conditions only if the conditionType is \&quot;API\&quot;. Similarly, \&quot;conditionValue:test/1.0.0\&quot; will result in a match with blocking conditions only if the conditionValue is \&quot;test/1.0.0\&quot;. When you use \&quot;conditionType:API &amp; conditionValue:test/1.0.0\&quot; as a combination, it will result in a match with blocking conditions only if both the conditionType is \&quot;API\&quot; and the conditionValue is \&quot;test/1.0.0\&quot;. If query attribute is provided, this returns the blocking conditions that match the specified attributes. Please note that you need to use encoded URL (URL encoding) if you are using a client which does not support URL encoding (such as curl) (optional)
* @return ApiResponse&lt;BlockingConditionListDTO&gt;
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
* @http.response.details
Expand All @@ -159,8 +166,8 @@ public BlockingConditionListDTO throttlingDenyPoliciesGet(String accept, String
<tr><td> 406 </td><td> Not Acceptable. The requested media type is not supported. </td><td> - </td></tr>
</table>
*/
public ApiResponse<BlockingConditionListDTO> throttlingDenyPoliciesGetWithHttpInfo(String accept, String ifNoneMatch, String ifModifiedSince) throws ApiException {
okhttp3.Call localVarCall = throttlingDenyPoliciesGetValidateBeforeCall(accept, ifNoneMatch, ifModifiedSince, null);
public ApiResponse<BlockingConditionListDTO> throttlingDenyPoliciesGetWithHttpInfo(String accept, String ifNoneMatch, String ifModifiedSince, String query) throws ApiException {
okhttp3.Call localVarCall = throttlingDenyPoliciesGetValidateBeforeCall(accept, ifNoneMatch, ifModifiedSince, query, null);
Type localVarReturnType = new TypeToken<BlockingConditionListDTO>(){}.getType();
return localVarApiClient.execute(localVarCall, localVarReturnType);
}
Expand All @@ -171,6 +178,7 @@ public ApiResponse<BlockingConditionListDTO> throttlingDenyPoliciesGetWithHttpIn
* @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 (Will be supported in future). (optional)
* @param ifModifiedSince Validator for conditional requests; based on Last Modified header of the formerly retrieved variant of the resource (Will be supported in future). (optional)
* @param query **Search condition**. You can search in attributes by using **\&quot;conditionType:\&quot;** modifier and **\&quot;conditionValue:\&quot;** modifier. Eg. The entry \&quot;conditionType:API\&quot; will result in a match with blocking conditions only if the conditionType is \&quot;API\&quot;. Similarly, \&quot;conditionValue:test/1.0.0\&quot; will result in a match with blocking conditions only if the conditionValue is \&quot;test/1.0.0\&quot;. When you use \&quot;conditionType:API &amp; conditionValue:test/1.0.0\&quot; as a combination, it will result in a match with blocking conditions only if both the conditionType is \&quot;API\&quot; and the conditionValue is \&quot;test/1.0.0\&quot;. If query attribute is provided, this returns the blocking conditions that match the specified attributes. Please note that you need to use encoded URL (URL encoding) if you are using a client which does not support URL encoding (such as curl) (optional)
* @param _callback The callback to be executed when the API call finishes
* @return The request call
* @throws ApiException If fail to process the API call, e.g. serializing the request body object
Expand All @@ -182,9 +190,9 @@ public ApiResponse<BlockingConditionListDTO> throttlingDenyPoliciesGetWithHttpIn
<tr><td> 406 </td><td> Not Acceptable. The requested media type is not supported. </td><td> - </td></tr>
</table>
*/
public okhttp3.Call throttlingDenyPoliciesGetAsync(String accept, String ifNoneMatch, String ifModifiedSince, final ApiCallback<BlockingConditionListDTO> _callback) throws ApiException {
public okhttp3.Call throttlingDenyPoliciesGetAsync(String accept, String ifNoneMatch, String ifModifiedSince, String query, final ApiCallback<BlockingConditionListDTO> _callback) throws ApiException {

okhttp3.Call localVarCall = throttlingDenyPoliciesGetValidateBeforeCall(accept, ifNoneMatch, ifModifiedSince, _callback);
okhttp3.Call localVarCall = throttlingDenyPoliciesGetValidateBeforeCall(accept, ifNoneMatch, ifModifiedSince, query, _callback);
Type localVarReturnType = new TypeToken<BlockingConditionListDTO>(){}.getType();
localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
return localVarCall;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1834,6 +1834,18 @@ paths:
- $ref: '#/components/parameters/Accept'
- $ref: '#/components/parameters/If-None-Match'
- $ref: '#/components/parameters/If-Modified-Since'
- name: query
in: query
description: |
**Search condition**.
You can search in attributes by using **"conditionType:"** modifier and **"conditionValue:"** modifier.
Eg.
The entry "conditionType:API" will result in a match with blocking conditions only if the conditionType is "API". Similarly, "conditionValue:test/1.0.0" will result in a match with blocking conditions only if the conditionValue is "test/1.0.0".
When you use "conditionType:API & conditionValue:test/1.0.0" as a combination, it will result in a match with blocking conditions only if both the conditionType is "API" and the conditionValue is "test/1.0.0".
If query attribute is provided, this returns the blocking conditions that match the specified attributes.
Please note that you need to use encoded URL (URL encoding) if you are using a client which does not support URL encoding (such as curl)
schema:
type: string
responses:
200:
description: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,23 @@ public static CustomRuleDTO createCustomThrottlePolicyDTO(String policyName, Str
return ruleDTO;
}

/**
* Creates a blacklist policy DTO using the given parameters.
*
* @param conditionType Blocking condition type
* @param conditionValue Blocking condition value
* @param conditionStatus Activation status of the blocking condition
* @return Created blocking conditions DTO.
*/
public static BlockingConditionDTO createBlockingConditionDTO(BlockingConditionDTO.ConditionTypeEnum conditionType,
String conditionValue, boolean conditionStatus) {

return new BlockingConditionDTO().
conditionType(conditionType).
conditionValue(conditionValue).
conditionStatus(conditionStatus);
}

/**
* Creates a header condition DTO using the given parameters.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,18 @@ public ApiResponse<BlockingConditionDTO> getDenyThrottlingPolicy(String policyId
.throttlingDenyPolicyConditionIdGetWithHttpInfo(policyId, null, null);
}

/**
* This method is used to retrieve blocking conditions by condition type and condition value.
*
* @return API response returned by API call.
* @throws ApiException if an error occurs while retrieving the blocking conditions.
*/
public BlockingConditionListDTO getBlockingConditionsByConditionTypeAndValue(String query) throws ApiException {

return denyPolicyCollectionApi.throttlingDenyPoliciesGet(Constants.APPLICATION_JSON, null, null, query);
}


/**
* Deletes a deny throttling policy.
*
Expand Down
Loading

0 comments on commit 3021788

Please sign in to comment.