-
Notifications
You must be signed in to change notification settings - Fork 594
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(credentials): used selected auth scheme identity instead of calli…
…ng credentials provider (#6555) * fix(credentials): used selected auth scheme identity instead of calling credentials provider * test(middleware-user-agent): add unit test for empty config/context
- Loading branch information
Showing
2 changed files
with
44 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { AwsHandlerExecutionContext } from "@aws-sdk/types"; | ||
|
||
import { checkFeatures } from "./check-features"; | ||
|
||
describe(checkFeatures.name, () => { | ||
it("should not call the credentials provider to retrieve the identity", async () => { | ||
const config = { | ||
credentials: jest.fn(), | ||
}; | ||
|
||
const context = { | ||
__smithy_context: { | ||
selectedHttpAuthScheme: { | ||
identity: { | ||
accountId: "123456789012", | ||
$source: {}, | ||
}, | ||
}, | ||
}, | ||
} as AwsHandlerExecutionContext; | ||
|
||
await checkFeatures(context, config, { | ||
request: undefined, | ||
input: undefined, | ||
}); | ||
|
||
expect(config.credentials).not.toHaveBeenCalled(); | ||
expect(context.__aws_sdk_context?.features?.RESOLVED_ACCOUNT_ID).toBe("T"); | ||
}); | ||
|
||
it("should not throw an error if no fields are present", async () => { | ||
await checkFeatures({}, {}, {} as any); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters