-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add integration test to verify old CR versions of the API
- Loading branch information
Showing
2 changed files
with
148 additions
and
0 deletions.
There are no files selected for viewing
80 changes: 80 additions & 0 deletions
80
test/integration/integration/tests/resources/tests/verify-old-apis.yaml
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,80 @@ | ||
# Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com) All Rights Reserved. | ||
# | ||
# WSO2 LLC. 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. | ||
|
||
apiVersion: dp.wso2.com/v1alpha1 | ||
kind: API | ||
metadata: | ||
name: verify-old-apis | ||
namespace: gateway-integration-test-infra | ||
spec: | ||
apiName: Backend with no basepath | ||
apiType: REST | ||
apiVersion: v1 | ||
basePath: /verify-old-apis/v1 | ||
#definitionFileRef: definition-file | ||
production: | ||
- httpRouteRefs: | ||
- prod-httproute-1 | ||
organization: wso2-org | ||
--- | ||
apiVersion: gateway.networking.k8s.io/v1beta1 | ||
kind: HTTPRoute | ||
metadata: | ||
name: prod-httproute-1 | ||
namespace: gateway-integration-test-infra | ||
spec: | ||
parentRefs: | ||
- group: gateway.networking.k8s.io | ||
kind: Gateway | ||
name: wso2-apk-default | ||
namespace: apk-integration-test | ||
sectionName: httpslistener | ||
hostnames: | ||
- prod-api.test.gw.wso2.com | ||
rules: | ||
- matches: | ||
- path: | ||
type: PathPrefix | ||
value: / | ||
method: GET | ||
backendRefs: | ||
- group: dp.wso2.com | ||
kind: Backend | ||
name: infra-backend-v1 | ||
--- | ||
apiVersion: dp.wso2.com/v1alpha1 | ||
kind: Authentication | ||
metadata: | ||
name: disable-sand-api-security | ||
namespace: gateway-integration-test-infra | ||
spec: | ||
override: | ||
disabled: true | ||
targetRef: | ||
group: gateway.networking.k8s.io | ||
kind: API | ||
namespace: gateway-integration-test-infra | ||
name: prod-and-sand-apis | ||
--- | ||
apiVersion: dp.wso2.com/v1alpha1 | ||
kind: Backend | ||
metadata: | ||
name: infra-backend-v1 | ||
namespace: gateway-integration-test-infra | ||
spec: | ||
services: | ||
- host: infra-backend-v1.gateway-integration-test-infra | ||
port: 8080 |
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,68 @@ | ||
/* | ||
* Copyright (c) 2024, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. | ||
* | ||
* Licensed 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 tests | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/wso2/apk/test/integration/integration/utils/http" | ||
"github.com/wso2/apk/test/integration/integration/utils/suite" | ||
) | ||
|
||
func init() { | ||
IntegrationTests = append(IntegrationTests, VerifyOldAPIs) | ||
} | ||
|
||
// VerifyOldAPIs test | ||
var VerifyOldAPIs = suite.IntegrationTest{ | ||
ShortName: "VerifyOldAPIs", | ||
Description: "Verify Old APIs with different CR versions", | ||
Manifests: []string{"tests/verify-old-apis.yaml"}, | ||
Test: func(t *testing.T, suite *suite.IntegrationTestSuite) { | ||
ns := "gateway-integration-test-infra" | ||
gwAddr1 := "prod-api.test.gw.wso2.com:9095" | ||
token := http.GetTestToken(t) | ||
|
||
testCases1 := []http.ExpectedResponse{ | ||
// invoke prod api using prod domain name, invokes prod backend | ||
{ | ||
Request: http.Request{ | ||
Host: "prod-api.test.gw.wso2.com", | ||
Path: "/verify-old-apis/v1", | ||
}, | ||
ExpectedRequest: &http.ExpectedRequest{ | ||
Request: http.Request{ | ||
Path: "/", | ||
}, | ||
}, | ||
Backend: "infra-backend-v1", | ||
Namespace: ns, | ||
}, | ||
} | ||
|
||
for i := range testCases1 { | ||
tc := testCases1[i] | ||
tc.Request.Headers = http.AddBearerTokenToHeader(token, tc.Request.Headers) | ||
t.Run(tc.GetTestCaseName(i), func(t *testing.T) { | ||
t.Parallel() | ||
http.MakeRequestAndExpectEventuallyConsistentResponse(t, suite.RoundTripper, suite.TimeoutConfig, gwAddr1, tc) | ||
}) | ||
} | ||
|
||
}, | ||
} |