-
Notifications
You must be signed in to change notification settings - Fork 494
Private registries: Add support for Cloudsmith and GCP OIDC configurations #3850
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
243c274
Add simple JSON schema / validation helpers
mbg 0752451
Use schema/validation for existing OIDC config types
mbg c8e26e2
Move `getAuthConfig` out of `start-proxy.ts`
mbg bc4097b
Simplify credential cloning in `getAuthConfig`
mbg d2a54a4
Add schemas for basic credential types
mbg 2acf819
Add tests for `getAuthConfig`
mbg 530fcb3
Group OIDC schemas into an array
mbg 70b2658
Validate Cloudsmith OIDC configurations
mbg 4d2c7c6
Validate GCP OIDC configurations
mbg efdcb31
Accept `replaces-base` option
mbg 0ed734b
Ignore test files
mbg 35715ef
Improve typing of `cloneCredential`
mbg 91fbc51
Improve `validateSchema` comment
mbg 7a6ed56
Modify `FromSchema` so that optional properties are actually optional
mbg 549683c
Make it clearer what the expectations for `isUsernamePassword` are
mbg b779832
Fix `permutations` comment
mbg d1edf2e
Improve `replaces-base` validation and add tests
mbg 0a4d574
Add changelog entry
mbg 022ff3c
Merge remote-tracking branch 'origin/main' into mbg/private-registry/…
mbg 262a15f
Add generic non-printable chars test for OIDC configs
mbg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Add tests for
getAuthConfig
- Loading branch information
commit 2acf81942be0e7e23680c9ea047cc9dc9154cc30
There are no files selected for viewing
This file contains hidden or 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,88 @@ | ||
| import test from "ava"; | ||
|
|
||
| import * as json from "../json"; | ||
| import { setupTests } from "../testing-utils"; | ||
|
|
||
| import * as types from "./types"; | ||
| import { getAuthConfig } from "./validation"; | ||
|
|
||
| setupTests(test); | ||
|
|
||
| function makeFromSchema( | ||
| includeOptional: boolean, | ||
| schema: json.Schema, | ||
| ): json.FromSchema<typeof schema> { | ||
| const result = {}; | ||
| for (const [key, validator] of Object.entries(schema)) { | ||
| if (!validator.required && !includeOptional) { | ||
| continue; | ||
| } | ||
| result[key] = `value-for-${key}`; | ||
| } | ||
| return result; | ||
| } | ||
|
|
||
| const schemaTests = [ | ||
| { schema: types.azureConfigSchema, name: "isAzureConfig" }, | ||
| { schema: types.awsConfigSchema, name: "isAWSConfig" }, | ||
| { schema: types.jfrogConfigSchema, name: "isJFrogConfig" }, | ||
| ] as Array<{ schema: json.Schema; name: string }>; | ||
|
|
||
| for (const schemaTest of schemaTests) { | ||
| for (const includeOptional of [true, false]) { | ||
| const minimalName = includeOptional ? "full" : "minimal"; | ||
|
|
||
| test(`getAuthConfig - ${schemaTest.name} - ${minimalName}`, async (t) => { | ||
| const config = makeFromSchema(includeOptional, schemaTest.schema); | ||
|
|
||
| t.deepEqual( | ||
| getAuthConfig({ | ||
| ...config, | ||
| unexpected: "unexpected-value", | ||
| } as json.UnvalidatedObject<types.AuthConfig>), | ||
| config, | ||
| ); | ||
| }); | ||
| } | ||
| } | ||
|
|
||
| test("getAuthConfig - token", async (t) => { | ||
| const config = makeFromSchema(true, types.tokenSchema); | ||
|
|
||
| t.deepEqual( | ||
| getAuthConfig({ | ||
| ...config, | ||
| unexpected: "unexpected-value", | ||
| } as json.UnvalidatedObject<types.AuthConfig>), | ||
| config, | ||
| ); | ||
| }); | ||
|
|
||
| test("getAuthConfig - username and password", async (t) => { | ||
| const config = makeFromSchema(true, types.usernamePasswordSchema); | ||
|
|
||
| t.deepEqual( | ||
| getAuthConfig({ | ||
| ...config, | ||
| unexpected: "unexpected-value", | ||
| } as json.UnvalidatedObject<types.AuthConfig>), | ||
|
github-advanced-security[bot] marked this conversation as resolved.
Fixed
|
||
| config, | ||
| ); | ||
| }); | ||
|
|
||
| test("getAuthConfig - empty", async (t) => { | ||
| const config = makeFromSchema(false, types.usernamePasswordSchema); | ||
|
|
||
| // Since the purpose of constructing the `AuthConfig` values is for | ||
| // serialisation to JSON so that they can be passed to the proxy as configuration, | ||
| // we only care that the stringified JSON representations are the same. | ||
| t.deepEqual( | ||
| JSON.stringify( | ||
| getAuthConfig({ | ||
| ...config, | ||
| unexpected: "unexpected-value", | ||
| } as json.UnvalidatedObject<types.AuthConfig>), | ||
| ), | ||
|
github-advanced-security[bot] marked this conversation as resolved.
Fixed
|
||
| JSON.stringify({}), | ||
| ); | ||
| }); | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.