Skip to content
This repository was archived by the owner on Jan 16, 2025. It is now read-only.

Commit 1ecca1e

Browse files
authored
chore(runners): Add unit test for line break in app key (#1341) (#1397)
1 parent 14183ac commit 1ecca1e

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

Diff for: modules/runners/lambdas/runners/src/scale-runners/gh-auth.test.ts

+28
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,34 @@ describe('Test createGithubAppAuth', () => {
7171
process.env.ENVIRONMENT = ENVIRONMENT;
7272
});
7373

74+
test('Creates auth object with line breaks in SSH key.', async () => {
75+
// Arrange
76+
const authOptions = {
77+
appId: parseInt(GITHUB_APP_ID),
78+
privateKey: `${decryptedValue}
79+
${decryptedValue}`,
80+
installationId,
81+
};
82+
83+
const b64PrivateKeyWithLineBreaks = Buffer.from(decryptedValue + '\n' + decryptedValue, 'binary').toString(
84+
'base64',
85+
);
86+
mockedGet.mockResolvedValueOnce(GITHUB_APP_ID).mockResolvedValueOnce(b64PrivateKeyWithLineBreaks);
87+
88+
const mockedAuth = jest.fn();
89+
mockedAuth.mockResolvedValue({ token });
90+
mockedCreatAppAuth.mockImplementation(() => {
91+
return mockedAuth;
92+
});
93+
94+
// Act
95+
await createGithubAppAuth(installationId);
96+
97+
// Assert
98+
expect(mockedCreatAppAuth).toBeCalledTimes(1);
99+
expect(mockedCreatAppAuth).toBeCalledWith(authOptions);
100+
});
101+
74102
test('Creates auth object for public GitHub', async () => {
75103
// Arrange
76104
const authOptions = {

0 commit comments

Comments
 (0)