Skip to content

Commit aaa2480

Browse files
committed
Use Credentials and CredentialProvider from types package
1 parent 6d866cf commit aaa2480

20 files changed

+137
-154
lines changed

packages/credential-provider/__mocks__/fs.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
interface FsModule {
2-
__addMatcher(toMatch: RegExp, toReturn: string): void;
2+
__addMatcher(toMatch: string, toReturn: string): void;
33
__clearMatchers(): void;
44
readFile: (path: string, encoding: string, cb: Function) => void
55
}
66

77
const fs: FsModule = <FsModule>jest.genMockFromModule('fs');
8-
const matchers = new Map<RegExp, string>();
8+
const matchers = new Map<string, string>();
99

10-
function __addMatcher(toMatch: RegExp, toReturn: string): void {
10+
function __addMatcher(toMatch: string, toReturn: string): void {
1111
matchers.set(toMatch, toReturn);
1212
}
1313

@@ -21,7 +21,7 @@ function readFile(
2121
callback: (err: Error|null, data?: string) => void
2222
): void {
2323
for (let [matcher, data] of matchers.entries()) {
24-
if (matcher.test(path)) {
24+
if (matcher === path) {
2525
callback(null, data);
2626
return;
2727
}

packages/credential-provider/__tests__/chain.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ import {isCredentials} from "../lib/isCredentials";
55
describe('chain', () => {
66
it('should distill many credential providers into one', async () => {
77
const provider = chain(
8-
fromCredentials({accessKeyId: 'foo', secretKey: 'bar'}),
9-
fromCredentials({accessKeyId: 'baz', secretKey: 'quux'}),
8+
fromCredentials({accessKeyId: 'foo', secretAccessKey: 'bar'}),
9+
fromCredentials({accessKeyId: 'baz', secretAccessKey: 'quux'}),
1010
);
1111

1212
expect(isCredentials(await provider())).toBe(true);
1313
});
1414

1515
it('should return the resolved value of the first successful promise', async () => {
16-
const creds = {accessKeyId: 'foo', secretKey: 'bar'};
16+
const creds = {accessKeyId: 'foo', secretAccessKey: 'bar'};
1717
const provider = chain(
1818
() => Promise.reject('Move along'),
1919
() => Promise.reject('Nothing to see here'),
@@ -24,7 +24,7 @@ describe('chain', () => {
2424
});
2525

2626
it('should not invoke subsequent providers one resolves', async () => {
27-
const creds = {accessKeyId: 'foo', secretKey: 'bar'};
27+
const creds = {accessKeyId: 'foo', secretAccessKey: 'bar'};
2828
const providers = [
2929
jest.fn(() => Promise.reject('Move along')),
3030
jest.fn(() => Promise.resolve(creds)),

packages/credential-provider/__tests__/fromCredentials.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
import {CredentialProvider} from "../lib/CredentialProvider";
2-
import {Credentials} from "../lib/Credentials";
1+
import {CredentialProvider, Credentials} from "@aws/types";
32
import {fromCredentials} from "../lib/fromCredentials";
43

54
describe('fromCredentials', () => {
65
it('should convert credentials into a credential provider', async () => {
7-
const credentials: Credentials = {accessKeyId: 'foo', secretKey: 'bar'};
6+
const credentials: Credentials = {
7+
accessKeyId: 'foo',
8+
secretAccessKey: 'bar'
9+
};
810
const provider: CredentialProvider = fromCredentials(credentials);
911

1012
expect(typeof provider).toBe('function');

packages/credential-provider/__tests__/fromEnv.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ describe('fromEnv', () => {
2929

3030
expect(await fromEnv()()).toEqual({
3131
accessKeyId: 'foo',
32-
secretKey: 'bar',
32+
secretAccessKey: 'bar',
3333
sessionToken: 'baz',
3434
});
3535
});
@@ -40,7 +40,7 @@ describe('fromEnv', () => {
4040

4141
expect(await fromEnv()()).toEqual({
4242
accessKeyId: 'foo',
43-
secretKey: 'bar',
43+
secretAccessKey: 'bar',
4444
sessionToken: void 0,
4545
});
4646
});

0 commit comments

Comments
 (0)