-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: adds unit tests for apigeecli (#387)
* chore: restructure folder structure * chore: use internal package * bug: fixes typo in method * chore: adds unit tests for apis * chore: move cmd as internal package * chore: adds unit tests for apigeecli #386 * bug: fixes missing region param for orgs #388 * bug: fixes missing setting params #386 * bug: fixes cleanup #386 * bug: uses id for delete #386 * bug: use id instead of name #386 * chore: adds unit tests for fh and res #386 * feat: adds quota scope * chore: adds unit tests * chore: adds unit tests for apps keys and bundles * fix: disables validation for specs with refs #389 * feat: adds support to import and exp env details #390 * chore: adds unit tests for debug mask #386 * chore: adds unit tests env and reports #386 * feat: adds ability to update entries #391 * chore: adds unit tests for registry #386 * chore: gofumpt files #386 * chore: print req and resp headers #386 * feat: add the update kvm cmd #386 * bug: fixes path for kvm update #386 * bug: fixes code to improve test cases #386
- Loading branch information
Showing
456 changed files
with
4,004 additions
and
238 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,3 +30,5 @@ remote-service.* | |
!test/*.json | ||
!test/*.yaml | ||
!test/*.zip | ||
!cmd/apigeecli* | ||
!internal/apigeecli* |
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
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
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
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
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
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
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
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,85 @@ | ||
// Copyright 2024 Google LLC | ||
// | ||
// 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 bundlegen | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"path" | ||
"regexp" | ||
"testing" | ||
|
||
"internal/client/clienttest" | ||
) | ||
|
||
var cliPath = os.Getenv("APIGEECLI_PATH") | ||
|
||
var specNames = []string{ | ||
"petstore-v3.1.yaml", | ||
"md-ext1.yaml", | ||
"windfarm3-quota.yaml", | ||
"open_weather_api.yaml", | ||
} | ||
|
||
func TestSpecs(t *testing.T) { | ||
for _, specName := range specNames { | ||
fmt.Println("Testing " + specName + " ...") | ||
testLoadDocument(specName, t) | ||
testGenerateAPIProxyDefFromOASv2(specName, t) | ||
} | ||
} | ||
|
||
func testLoadDocument(specName string, t *testing.T) { | ||
if err := clienttest.TestSetup(clienttest.ENV_NOT_REQD, | ||
clienttest.SITEID_NOT_REQD, clienttest.CLIPATH_REQD); err != nil { | ||
t.Fatalf("%v", err) | ||
} | ||
if _, err := LoadDocument(path.Join(cliPath, "test"), "", specName, true); err != nil { | ||
t.Fatalf("%v", err) | ||
} | ||
} | ||
|
||
func testGenerateAPIProxyDefFromOASv2(specName string, t *testing.T) { | ||
skipPolicy := false | ||
name := "test" | ||
addCORS := true | ||
integrationEndpoint := false | ||
basePath := "" | ||
oasGoogleAcessTokenScopeLiteral := "" | ||
targetURL := "http://api.example.com" | ||
oasGoogleIDTokenAudLiteral := "" | ||
oasGoogleIDTokenAudRef := "" | ||
targetURLRef := "" | ||
version := GetModelVersion() | ||
if version != "" { | ||
re := regexp.MustCompile(`3\.1\.[0-9]`) | ||
if re.MatchString(version) { | ||
skipPolicy = true | ||
} | ||
} | ||
if err := GenerateAPIProxyDefFromOASv2(name, | ||
basePath, | ||
specName, | ||
skipPolicy, | ||
addCORS, | ||
integrationEndpoint, | ||
oasGoogleAcessTokenScopeLiteral, | ||
oasGoogleIDTokenAudLiteral, | ||
oasGoogleIDTokenAudRef, | ||
targetURLRef, | ||
targetURL); err != nil { | ||
t.Fatalf("%v", err) | ||
} | ||
} |
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
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
Oops, something went wrong.