1
0
Fork 0
mirror of https://github.com/docker/login-action.git synced 2025-04-22 14:46:37 +02:00

refactor: use v3 sdk

Signed-off-by: Markus Maga <markus@maga.se>
This commit is contained in:
Markus Maga 2021-12-20 10:00:03 +01:00
parent d9927c4142
commit 58855695bb
No known key found for this signature in database
GPG key ID: C4A60C14610ED918
5 changed files with 28595 additions and 39169 deletions

View file

@ -1,5 +1,5 @@
import {AuthorizationData} from '@aws-sdk/client-ecr';
import * as aws from '../src/aws';
import {AuthorizationData} from 'aws-sdk/clients/ecr';
describe('isECR', () => {
test.each([
@ -55,11 +55,15 @@ describe('getAccountIDs', () => {
const mockEcrGetAuthToken = jest.fn();
const mockEcrPublicGetAuthToken = jest.fn();
jest.mock('aws-sdk', () => {
jest.mock('@aws-sdk/client-ecr', () => {
return {
ECR: jest.fn(() => ({
getAuthorizationToken: mockEcrGetAuthToken
})),
}))
};
});
jest.mock('@aws-sdk/client-ecr-public', () => {
return {
ECRPUBLIC: jest.fn(() => ({
getAuthorizationToken: mockEcrPublicGetAuthToken
}))
@ -126,15 +130,11 @@ describe('getRegistriesData', () => {
const authData: AuthorizationData[] = [];
if (accountIDs.length == 0) {
mockEcrPublicGetAuthToken.mockImplementation(() => {
return {
promise() {
return Promise.resolve({
authorizationData: {
authorizationToken: Buffer.from(`AWS:world`).toString('base64'),
}
});
return Promise.resolve({
authorizationData: {
authorizationToken: Buffer.from(`AWS:world`).toString('base64'),
}
};
});
});
} else {
aws.getAccountIDs(registry).forEach(accountID => {
@ -144,13 +144,9 @@ describe('getRegistriesData', () => {
});
});
mockEcrGetAuthToken.mockImplementation(() => {
return {
promise() {
return Promise.resolve({
authorizationData: authData
});
}
};
return Promise.resolve({
authorizationData: authData
});
});
}
const regData = await aws.getRegistriesData(registry);