fixed bug on when compared in organzation name on github

Signed-off-by: Aurelio Saraiva <aureliosaraiva@gmail.com>
This commit is contained in:
Aurelio Saraiva
2021-08-02 10:51:46 -03:00
parent 13f5d78b0b
commit 3c50ff5620
3 changed files with 37 additions and 1 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/integration': patch
---
Fixed bug on when compared in organzation name on github
@@ -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');
});
});
@@ -129,7 +129,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 {