Skip to content

Commit

Permalink
Merge pull request #1217 from RusJaI/4.2.x
Browse files Browse the repository at this point in the history
Modify integration tests regarding to the improvement that allowing an API and  a Common policy to have  same name and version
  • Loading branch information
npamudika authored Oct 14, 2024
2 parents 48aa1f5 + 2101686 commit ce629d3
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 11 deletions.
19 changes: 14 additions & 5 deletions import-export-cli/integration/testutils/devFirst_testUtils.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ package testutils
import (
"io/ioutil"
"log"
"os"
"path/filepath"
"strconv"
"strings"
Expand Down Expand Up @@ -149,7 +150,7 @@ func ValidateInitializeProject(t *testing.T, args *InitTestArgs) {
})
}

//Function to initialize a project using API definition
// Function to initialize a project using API definition
func ValidateInitializeProjectWithOASFlag(t *testing.T, args *InitTestArgs) {
t.Helper()

Expand All @@ -168,7 +169,7 @@ func ValidateInitializeProjectWithOASFlag(t *testing.T, args *InitTestArgs) {
})
}

//Function to initialize a project using API definition
// Function to initialize a project using API definition
func ValidateInitializeProjectWithOASFlagWithoutCleaning(t *testing.T, args *InitTestArgs) {
t.Helper()

Expand All @@ -182,7 +183,7 @@ func ValidateInitializeProjectWithOASFlagWithoutCleaning(t *testing.T, args *Ini

}

//Function to initialize a project using API definition using --definition flag
// Function to initialize a project using API definition using --definition flag
func ValidateInitializeProjectWithDefinitionFlag(t *testing.T, args *InitTestArgs) {
t.Helper()

Expand Down Expand Up @@ -280,6 +281,7 @@ func ValidateImportUpdateProject(t *testing.T, args *InitTestArgs, preserveProvi
base.WaitForIndexing()
// Get App from env 2
importedAPI := GetAPI(t, args.SrcAPIM, args.APIName, args.CtlUser.Username, args.CtlUser.Password)
base.Log("#importedAPIOperations : ", importedAPI.Operations)

//Remove Created project and logout
t.Cleanup(func() {
Expand Down Expand Up @@ -385,15 +387,22 @@ func ValidateAPIWithUpdatedSequenceIsExported(t *testing.T, args *InitTestArgs,
relativePath := strings.ReplaceAll(exportedPath, ".zip", "")
base.Unzip(relativePath, exportedPath)

//
dstDir := filepath.Join(os.Getenv("HOME"), "Downloads", filepath.Base(exportedPath))
base.Copy(exportedPath, dstDir)

// Check whether the exported operation policy is equivalent to the latest operation policy
exportedApiSequencePath := relativePath + TestDefaultExtractedFileName + DevFirstSampleCaseDestPolicy1PathSuffix
exportedApiSequencePath := relativePath + TestDefaultExtractedFileName + DevFirstSampleCaseDestExportedPolicy1PathSuffix
base.Log("#exportedApiSequencePath : ", exportedApiSequencePath)

lastUpdatedSequencePath, _ := filepath.Abs(DevFirstUpdatedSampleCasePolicy1Path)
base.Log("#lastUpdatedSequencePath : ", lastUpdatedSequencePath)
isSequenceUpdated := base.IsFileContentIdentical(exportedApiSequencePath, lastUpdatedSequencePath)
base.Log("Exported operation policy is updated", isSequenceUpdated)
assert.Equal(t, true, isSequenceUpdated, "Error while updating the operation policy of API")

// Check whether the exported operation policy definition is equivalent to the latest operation policy definition
exportedApiSequenceDefinitionPath := relativePath + TestDefaultExtractedFileName + DevFirstSampleCaseDestPolicyDefinition1PathSuffix
exportedApiSequenceDefinitionPath := relativePath + TestDefaultExtractedFileName + DevFirstSampleCaseDestExportedPolicyDefinition1PathSuffix
lastUpdatedSequenceDefinitionPath, _ := filepath.Abs(DevFirstUpdatedSampleCasePolicyDefinition1Path)
isSequenceDefinitionUpdated := base.IsFileContentIdentical(exportedApiSequenceDefinitionPath, lastUpdatedSequenceDefinitionPath)
base.Log("Exported operation policy definition is updated", isSequenceDefinitionUpdated)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ func AddSequenceWithDynamicDataToAPIProject(t *testing.T, args *InitTestArgs) ap
operationPolicies := apim.OperationPolicies{
Request: append(requestPolicies, map[string]interface{}{
"policyName": TestSampleDynamicDataPolicyName,
"policyType": "api",
}),
Response: []string{},
Fault: []string{},
Expand Down
14 changes: 8 additions & 6 deletions import-export-cli/integration/testutils/testConstants.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,12 @@ const DevSampleCaseMalformedOperationPolicyDefinitionPath = DevFirstSampleCaseMa
const DevSampleCaseMalformedOperationPolicyPath = DevFirstSampleCaseMalformedOperationPolicyArtifactPath + "/customAddLogMessage.j2"
const DevFirstSampleCaseDestPolicy1PathSuffix = PoliciesDirectory + "/customAddLogMessage_v1.j2"
const DevFirstSampleCaseDestPolicy2PathSuffix = PoliciesDirectory + "/customAddLogMessage_v2.j2"
const DevFirstSampleCaseDestExportedPolicy1PathSuffix = PoliciesDirectory + "/customAddLogMessage_v1_api.j2"
const DevFirstSampleCaseDestPolicyDefinition1PathSuffix = PoliciesDirectory + "/customAddLogMessage_v1.yaml"
const DevFirstSampleCaseDestPolicyDefinition2PathSuffix = PoliciesDirectory + "/customAddLogMessage_v2.yaml"
const DevFirstUpdatedSampleCasePolicy1Path = DevFirstUpdatedSampleCaseArtifactPath + "/customAddLogMessage_v1.j2"
const DevFirstUpdatedSampleCasePolicyDefinition1Path = DevFirstUpdatedSampleCaseArtifactPath + "/customAddLogMessage_v1.yaml"
const DevFirstSampleCaseDestExportedPolicyDefinition1PathSuffix = PoliciesDirectory + "/customAddLogMessage_v1_api.yaml"
const DevFirstUpdatedSampleCasePolicy1Path = DevFirstUpdatedSampleCaseArtifactPath + "/customAddLogMessage_v1_api.j2"
const DevFirstUpdatedSampleCasePolicyDefinition1Path = DevFirstUpdatedSampleCaseArtifactPath + "/customAddLogMessage_v1_api.yaml"
const TestSynapseChoreoConnectPolicyDefinitionPath = TestSynapseChoreoConnectPolicyArtifactsPath + "/testSynapseChoreoConnectPolicy.yaml"
const TestSynapseChoreoConnectPolicyPathForSynapseType = TestSynapseChoreoConnectPolicyArtifactsPath + "/testSynapseChoreoConnectPolicy.j2"
const TestSynapseChoreoConnectPolicyPathForChoreoConnectType = TestSynapseChoreoConnectPolicyArtifactsPath + "/testSynapseChoreoConnectPolicy.gotmpl"
Expand All @@ -214,9 +216,9 @@ const (

// Constants for sequence of the dynamic data test case
const DynamicDataSampleCaseArtifactPath = "testdata/TestArtifactDirectory/DynamicDataSampleCaseArtifacts"
const DynamicDataInSequence = "dynamicAddLogMessage_v1.j2"
const DynamicDataInSequenceDefinition = "dynamicAddLogMessage_v1.yaml"
const DynamicDataSubstitutedInSequence = DynamicDataSampleCaseArtifactPath + "/dynamicDataSubstitutedAddLogMessage_v1.j2"
const DynamicDataInSequence = "dynamicAddLogMessage_v1_api.j2"
const DynamicDataInSequenceDefinition = "dynamicAddLogMessage_v1_api.yaml"
const DynamicDataSubstitutedInSequence = DynamicDataSampleCaseArtifactPath + "/dynamicDataSubstitutedAddLogMessage_v1_api.j2"

const (
TestSampleDynamicDataOperationTarget = "/menu"
Expand All @@ -232,5 +234,5 @@ const TestAPIPolicyOffset = "0"
const TestAPIPolicyLimit = "5"
const CleanUpFunction = "cleanup"

//Constant for API versioning tests
// Constant for API versioning tests
const APIVersion2 = "2.0.0"

0 comments on commit ce629d3

Please sign in to comment.