Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion __tests__/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -846,7 +846,8 @@ describe('credentialsFromEnv', () => {
password: 'baz',
token: 'tok',
host: 'h',
'replaces-base': false
'replaces-base': false,
scope: '@mycompany'
}
]
process.env.GITHUB_REGISTRIES_PROXY = Buffer.from(
Expand All @@ -859,6 +860,7 @@ describe('credentialsFromEnv', () => {
expect(setSecretSpy).toHaveBeenCalledWith('tok')
expect(setSecretSpy).not.toHaveBeenCalledWith('bar')
expect(setSecretSpy).not.toHaveBeenCalledWith('https://foo')
expect(setSecretSpy).not.toHaveBeenCalledWith('@mycompany')
})
})

Expand Down
32 changes: 32 additions & 0 deletions __tests__/updater.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,38 @@ describe('Updater', () => {
})
})

describe('when given npm_registry credentials with a scope', () => {
const jobDetails = {...mockJobDetails}

new Updater(
'MOCK_UPDATER_IMAGE_NAME',
'MOCK_PROXY_IMAGE_NAME',
mockApiClient,
jobDetails,
[
{
type: 'npm_registry',
registry:
'jfrogghdemo.jfrog.io/artifactory/api/npm/dpndbt-pvt-repo-npm-key/',
username: 'npm_user',
token: 'npm_token',
scope: '@mycompany'
}
]
)

it('generates credentials metadata with the scope', () => {
expect(jobDetails['credentials-metadata']).toEqual([
{
type: 'npm_registry',
registry:
'jfrogghdemo.jfrog.io/artifactory/api/npm/dpndbt-pvt-repo-npm-key/',
scope: '@mycompany'
}
])
})
})

describe('when given npm_registry credentials with a URL and not a registry', () => {
const jobDetails = {...mockJobDetails}

Expand Down
12 changes: 11 additions & 1 deletion dist/main/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/main/index.js.map

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/api-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export type Credential = {
'index-url'?: string
'env-key'?: string
'replaces-base'?: boolean
scope?: string
'public-key-fingerprint'?: string
'auth-key'?: string
'tenant-id'?: string
Expand Down
9 changes: 8 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,14 @@ export function credentialsFromEnv(): Credential[] {
botSay('Failed to parse GITHUB_REGISTRIES_PROXY environment variable')
}

const nonSecrets = ['type', 'url', 'username', 'host', 'replaces-base']
const nonSecrets = [
'type',
'url',
'username',
'host',
'replaces-base',
'scope'
]
for (const e of parsed) {
// Mask credentials to reduce chance of accidental leakage in logs.
for (const key of Object.keys(e)) {
Expand Down
3 changes: 3 additions & 0 deletions src/updater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ export class Updater {
if (credential['replaces-base'] !== undefined) {
obj['replaces-base'] = credential['replaces-base']
}
if (credential.scope !== undefined) {
obj.scope = credential.scope
}
Comment thread
AbhishekBhaskar marked this conversation as resolved.
if (credential['public-key-fingerprint'] !== undefined) {
obj['public-key-fingerprint'] = credential['public-key-fingerprint']
}
Expand Down
Loading