* add fetch request method post

* upgrade version

* fix lint

* update package-lock

Co-authored-by: Ray Chen <raychen@microsoft.com>
This commit is contained in:
Tianen 2022-05-26 15:22:28 +08:00 коммит произвёл GitHub
Родитель 2237feefbc
Коммит 2bbe9fc7f5
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
4 изменённых файлов: 9 добавлений и 2 удалений

2
package-lock.json сгенерированный
Просмотреть файл

@ -1,6 +1,6 @@
{
"name": "git-rest-api",
"version": "0.3.4",
"version": "0.3.5",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

Просмотреть файл

@ -1,6 +1,6 @@
{
"name": "git-rest-api",
"version": "0.3.4",
"version": "0.3.5",
"description": "This project welcomes contributions and suggestions. Most contributions require you to agree to a\r Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us\r the rights to use your contribution. For details, visit https://cla.microsoft.com.",
"main": "bin/main.js",
"scripts": {

Просмотреть файл

@ -51,6 +51,7 @@ describe("PermissionService", () => {
headers: {
Authorization: auth.toAuthorizationHeader(),
},
method: "POST",
});
});
@ -65,12 +66,14 @@ describe("PermissionService", () => {
headers: {
Authorization: auth.toAuthorizationHeader(),
},
method: "POST",
});
expect(httpSpy.fetch).toHaveBeenCalledWith("https://github.com/Azure/some-repo.git/git-upload-pack", {
headers: {
Authorization: auth.toAuthorizationHeader(),
},
method: "POST",
});
});
@ -87,6 +90,7 @@ describe("PermissionService", () => {
headers: {
Authorization: auth.toAuthorizationHeader(),
},
method: "POST",
},
);
@ -96,6 +100,7 @@ describe("PermissionService", () => {
headers: {
Authorization: auth.toAuthorizationHeader(),
},
method: "POST",
},
);
});

Просмотреть файл

@ -39,6 +39,7 @@ export class PermissionService {
private async checkWritePermission(auth: RepoAuth, gitUrl: string): Promise<boolean> {
const response = await this.http.fetch(`${gitUrl}/${GitServices.Push}`, {
headers: this.getHeaders(auth),
method: "POST",
});
return response.status === 200;
}
@ -46,6 +47,7 @@ export class PermissionService {
private async checkReadPermission(auth: RepoAuth, gitUrl: string): Promise<boolean> {
const response = await this.http.fetch(`${gitUrl}/${GitServices.Pull}`, {
headers: this.getHeaders(auth),
method: "POST",
});
return response.status === 200;
}