Skip to content

Commit 1d7d864

Browse files
authored
Merge pull request #128 from Flydiverny/aws-sdk-v3
fix(ecr): only set credentials if username & password if specified, refactor to use aws-sdk v3
2 parents d9927c4 + 5885569 commit 1d7d864

File tree

5 files changed

+26615
-37189
lines changed

5 files changed

+26615
-37189
lines changed

__tests__/aws.test.ts

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
import {AuthorizationData} from '@aws-sdk/client-ecr';
12
import * as aws from '../src/aws';
2-
import {AuthorizationData} from 'aws-sdk/clients/ecr';
33

44
describe('isECR', () => {
55
test.each([
@@ -55,11 +55,15 @@ describe('getAccountIDs', () => {
5555

5656
const mockEcrGetAuthToken = jest.fn();
5757
const mockEcrPublicGetAuthToken = jest.fn();
58-
jest.mock('aws-sdk', () => {
58+
jest.mock('@aws-sdk/client-ecr', () => {
5959
return {
6060
ECR: jest.fn(() => ({
6161
getAuthorizationToken: mockEcrGetAuthToken
62-
})),
62+
}))
63+
};
64+
});
65+
jest.mock('@aws-sdk/client-ecr-public', () => {
66+
return {
6367
ECRPUBLIC: jest.fn(() => ({
6468
getAuthorizationToken: mockEcrPublicGetAuthToken
6569
}))
@@ -126,15 +130,11 @@ describe('getRegistriesData', () => {
126130
const authData: AuthorizationData[] = [];
127131
if (accountIDs.length == 0) {
128132
mockEcrPublicGetAuthToken.mockImplementation(() => {
129-
return {
130-
promise() {
131-
return Promise.resolve({
132-
authorizationData: {
133-
authorizationToken: Buffer.from(`AWS:world`).toString('base64'),
134-
}
135-
});
133+
return Promise.resolve({
134+
authorizationData: {
135+
authorizationToken: Buffer.from(`AWS:world`).toString('base64'),
136136
}
137-
};
137+
});
138138
});
139139
} else {
140140
aws.getAccountIDs(registry).forEach(accountID => {
@@ -144,13 +144,9 @@ describe('getRegistriesData', () => {
144144
});
145145
});
146146
mockEcrGetAuthToken.mockImplementation(() => {
147-
return {
148-
promise() {
149-
return Promise.resolve({
150-
authorizationData: authData
151-
});
152-
}
153-
};
147+
return Promise.resolve({
148+
authorizationData: authData
149+
});
154150
});
155151
}
156152
const regData = await aws.getRegistriesData(registry);

0 commit comments

Comments
 (0)