Merge remote-tracking branch 'origin' into github-installations-limit

This commit is contained in:
Brian Fletcher
2021-08-06 13:30:56 +01:00
742 changed files with 24958 additions and 5496 deletions
@@ -254,4 +254,35 @@ describe('GithubCredentialsProvider tests', () => {
}),
).resolves.toEqual({ headers: undefined, token: undefined, type: 'token' });
});
it('should to create a token for the organization ignoring case sensitive', async () => {
octokit.apps.listInstallations.mockResolvedValue({
headers: {
etag: '123',
},
data: [
{
id: 1,
repository_selection: 'all',
account: {
login: 'BACKSTAGE',
},
},
],
} as RestEndpointMethodTypes['apps']['listInstallations']['response']);
octokit.apps.createInstallationAccessToken.mockResolvedValueOnce({
data: {
expires_at: DateTime.local().plus({ hour: 1 }).toString(),
token: 'secret_token',
},
} as RestEndpointMethodTypes['apps']['createInstallationAccessToken']['response']);
const { token, headers } = await github.getCredentials({
url: 'https://github.com/backstage',
});
expect(headers).toEqual({ Authorization: 'Bearer secret_token' });
expect(token).toEqual('secret_token');
});
});
@@ -142,7 +142,7 @@ class GithubAppManager {
private async getInstallationData(owner: string): Promise<InstallationData> {
const allInstallations = await this.getInstallations();
const installation = allInstallations.find(
inst => inst.account?.login === owner,
inst => inst.account?.login?.toLowerCase() === owner.toLowerCase(),
);
if (installation) {
return {