-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
120 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
...test/resources/artifacts/apk-confs/grpc/grpc_with_mtls_mandatory_oauth2_disabled.apk-conf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
--- | ||
name: "demo-grpc-api" | ||
basePath: "/dineth.grpc.api" | ||
version: "v1" | ||
type: "GRPC" | ||
id: "grpc-mtls-mandatory-oauth2-disabled" | ||
endpointConfigurations: | ||
production: | ||
endpoint: "http://grpc-backend:6565" | ||
defaultVersion: false | ||
subscriptionValidation: false | ||
operations: | ||
- target: "student.StudentService" | ||
verb: "GetStudent" | ||
secured: true | ||
scopes: [] | ||
- target: "student.StudentService" | ||
verb: "GetStudentStream" | ||
secured: true | ||
scopes: [] | ||
- target: "student.StudentService" | ||
verb: "SendStudentStream" | ||
secured: true | ||
scopes: [] | ||
- target: "student.StudentService" | ||
verb: "SendAndGetStudentStream" | ||
secured: true | ||
scopes: [] | ||
authentication: | ||
- authType: OAuth2 | ||
enabled: false | ||
- authType: mTLS | ||
required: mandatory | ||
certificates: | ||
- name: mtls-test-configmap | ||
key: tls.crt |
36 changes: 36 additions & 0 deletions
36
.../test/resources/artifacts/apk-confs/grpc/grpc_with_mtls_optional_oauth2_optional.apk-conf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
--- | ||
name: "demo-grpc-api" | ||
basePath: "/dineth.grpc.api" | ||
version: "v1" | ||
type: "GRPC" | ||
id: "grpc-mtls-optional-oauth2-optional" | ||
endpointConfigurations: | ||
production: | ||
endpoint: "http://grpc-backend:6565" | ||
defaultVersion: false | ||
subscriptionValidation: false | ||
operations: | ||
- target: "student.StudentService" | ||
verb: "GetStudent" | ||
secured: true | ||
scopes: [] | ||
- target: "student.StudentService" | ||
verb: "GetStudentStream" | ||
secured: true | ||
scopes: [] | ||
- target: "student.StudentService" | ||
verb: "SendStudentStream" | ||
secured: true | ||
scopes: [] | ||
- target: "student.StudentService" | ||
verb: "SendAndGetStudentStream" | ||
secured: true | ||
scopes: [] | ||
authentication: | ||
- authType: OAuth2 | ||
required: optional | ||
- authType: mTLS | ||
required: optional | ||
certificates: | ||
- name: mtls-test-configmap | ||
key: tls.crt |
39 changes: 39 additions & 0 deletions
39
test/cucumber-tests/src/test/resources/tests/api/GRPCMTLS.feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
Feature: Test mTLS between client and gateway with client certificate sent in header | ||
Scenario: Test API with mandatory mTLS and OAuth2 disabled | ||
Given The system is ready | ||
And I have a valid token with a client certificate "invalid-cert.txt" | ||
When I use the APK Conf file "artifacts/apk-confs/grpc/grpc_with_mtls_mandatory_oauth2_disabled.apk-conf" | ||
And the definition file "artifacts/definitions/student.proto" | ||
And make the API deployment request | ||
Then the response status code should be 200 | ||
Then I set headers | ||
| X-WSO2-CLIENT-CERTIFICATE | ${clientCertificate} | | ||
And I make grpc request GetStudent to "default.gw.wso2.com" with port 9095 | ||
And I eventually receive 200 response code, not accepting | ||
| 401 | | ||
And the student response body should contain name: "Dineth" age: 10 | ||
|
||
Scenario: Undeploy API | ||
Given The system is ready | ||
And I have a valid subscription | ||
When I undeploy the API whose ID is "grpc-mtls-mandatory-oauth2-disabled" | ||
Then the response status code should be 202 | ||
|
||
Scenario: Test optional mTLS and optional OAuth2 with an invalid client certificate and invalid token in header | ||
Given The system is ready | ||
And I have a valid token with a client certificate "invalid-cert.txt" | ||
When I use the APK Conf file "artifacts/apk-confs/grpc/grpc_with_mtls_optional_oauth2_optional.apk-conf" | ||
And the definition file "artifacts/definitions/student.proto" | ||
And make the API deployment request | ||
Then the response status code should be 200 | ||
Then I set headers | ||
| X-WSO2-CLIENT-CERTIFICATE | ${clientCertificate} | | ||
| Authorization | bearer {accessToken} | | ||
And I make grpc request GetStudent to "default.gw.wso2.com" with port 9095 | ||
And the grpc error response status code should be 401 | ||
|
||
Scenario: Undeploy API | ||
Given The system is ready | ||
And I have a valid subscription | ||
When I undeploy the API whose ID is "grpc-mtls-optional-oauth2-optional" | ||
Then the response status code should be 202 |