Skip to content

Commit

Permalink
Merge 9d7209e into 64c8ef5
Browse files Browse the repository at this point in the history
  • Loading branch information
vreynolds authored Apr 8, 2021
2 parents 64c8ef5 + 9d7209e commit e8436c7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export class AwsEksDetector implements Detector {
await AwsEksDetector.fileAccessAsync(this.K8S_TOKEN_PATH);
const k8scert = await AwsEksDetector.readFileAsync(this.K8S_CERT_PATH);

if (!this._isEks(k8scert)) {
if (!(await this._isEks(k8scert))) {
return Resource.empty();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,7 @@ describe('awsEksDetector', () => {
});

describe('on unsuccesful request', () => {
it('should throw when receiving error response code', async () => {
const expectedError = new Error('EKS metadata api request timed out.');
it('should return an empty resource when timed out', async () => {
fileStub = sinon
.stub(AwsEksDetector, 'fileAccessAsync' as any)
.resolves();
Expand All @@ -265,17 +264,14 @@ describe('awsEksDetector', () => {
.delayConnection(2500)
.reply(200, () => mockedAwsAuth);

try {
await awsEksDetector.detect();
} catch (err) {
assert.deepStrictEqual(err, expectedError);
}

const resource: Resource = await awsEksDetector.detect();
scope.done();
});

it('should return an empty resource when timed out', async () => {
const expectedError = new Error('Failed to load page, status code: 404');
assert.ok(resource);
assertEmptyResource(resource);
}).timeout(awsEksDetector.TIMEOUT_MS + 100);

it('should return an empty resource when receiving error response code', async () => {
fileStub = sinon
.stub(AwsEksDetector, 'fileAccessAsync' as any)
.resolves();
Expand All @@ -291,13 +287,11 @@ describe('awsEksDetector', () => {
.matchHeader('Authorization', k8s_token)
.reply(404, () => new Error());

try {
await awsEksDetector.detect();
} catch (err) {
assert.deepStrictEqual(err, expectedError);
}

const resource: Resource = await awsEksDetector.detect();
scope.done();

assert.ok(resource);
assertEmptyResource(resource);
});
});
});

0 comments on commit e8436c7

Please sign in to comment.