Skip to content

Commit bdc5492

Browse files
fix: use admin token for privatisation (#1454)
* fix: use admin token for privatisation * fix: test * fix: test
1 parent 0cf8d3f commit bdc5492

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/services/db/GitHubService.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ import logger from "@root/logger/logger"
1717
import { GitCommitResult } from "@root/types/gitfilesystem"
1818
import { GitHubRepoInfo, RawGitTreeEntry, RepoState } from "@root/types/github"
1919

20+
import { E2E_TEST_GH_TOKEN } from "../middlewareServices/AuthenticationMiddlewareService"
21+
2022
import * as ReviewApi from "./review"
2123

2224
export default class GitHubService {
@@ -861,9 +863,9 @@ export default class GitHubService {
861863
const endpointTemplate = urlTemplate.parse(`{siteName}`)
862864
const endpoint = endpointTemplate.expand({ siteName })
863865

864-
// Privatising a repo is restricted to repo admins - an admin token will be inserted in via our axios interceptor
866+
// Privatising a repo is restricted to repo admins - our main admin token is used
865867
const headers = {
866-
Authorization: "",
868+
Authorization: `token ${E2E_TEST_GH_TOKEN}`,
867869
"Content-Type": "application/json",
868870
}
869871

src/services/db/__tests__/GitHubService.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ describe("Github Service", () => {
4848
const resourceCategoryFileName = "index.html"
4949

5050
const sessionData = mockUserWithSiteSessionData
51+
const mockE2eToken = "test"
5152

5253
const authHeader = {
5354
headers: {
@@ -1042,7 +1043,7 @@ describe("Github Service", () => {
10421043
describe("changeRepoPrivacy", () => {
10431044
const refEndpoint = `${siteName}`
10441045
const headers = {
1045-
Authorization: "",
1046+
Authorization: `token ${mockE2eToken}`,
10461047
"Content-Type": "application/json",
10471048
}
10481049
it("should modify the repo privacy accordingly if making repo private", async () => {

0 commit comments

Comments
 (0)