Skip to content

Commit

Permalink
refactor: remove all usages of TokenStore and tests (#533)
Browse files Browse the repository at this point in the history
  • Loading branch information
dcshzj authored Oct 18, 2022
1 parent 8518296 commit 2196e93
Show file tree
Hide file tree
Showing 6 changed files with 1 addition and 111 deletions.
3 changes: 0 additions & 3 deletions src/integration/Sites.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import { GitHubService } from "@root/services/db/GitHubService"
import { ConfigYmlService } from "@root/services/fileServices/YmlFileServices/ConfigYmlService"
import IsomerAdminsService from "@root/services/identity/IsomerAdminsService"
import SitesService from "@root/services/identity/SitesService"
import TokenStore from "@root/services/identity/TokenStore"
import { getIdentityAuthService, getUsersService } from "@services/identity"
import CollaboratorsService from "@services/identity/CollaboratorsService"
import { sequelize } from "@tests/database"
Expand All @@ -35,15 +34,13 @@ const gitHubService = new GitHubService({ axiosInstance: mockAxios.create() })
const configYmlService = new ConfigYmlService({ gitHubService })
const usersService = getUsersService(sequelize)
const isomerAdminsService = new IsomerAdminsService({ repository: IsomerAdmin })
const tokenStore = new TokenStore()
const identityAuthService = getIdentityAuthService(gitHubService)
const sitesService = new SitesService({
siteRepository: Site,
gitHubService,
configYmlService,
usersService,
isomerAdminsService,
tokenStore,
})
const collaboratorsService = new CollaboratorsService({
siteRepository: Site,
Expand Down
11 changes: 1 addition & 10 deletions src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,7 @@ const helmet = require("helmet")
const createError = require("http-errors")

// Env vars
const { FRONTEND_URL, NODE_ENV, LOCAL_SITE_ACCESS_TOKEN } = process.env
const IS_LOCAL_DEV = NODE_ENV === "LOCAL_DEV"

const tokenStore = IS_LOCAL_DEV
? {
getToken: (_apiTokenName) => LOCAL_SITE_ACCESS_TOKEN,
}
: new TokenStore()

const { FRONTEND_URL } = process.env
// Import middleware

// Import routes
Expand Down Expand Up @@ -96,7 +88,6 @@ const sitesService = new SitesService({
configYmlService,
usersService,
isomerAdminsService,
tokenStore,
})
const infraService = new InfraService({
sitesService,
Expand Down
7 changes: 0 additions & 7 deletions src/services/identity/SitesService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,12 @@ import { ConfigYmlService } from "@services/fileServices/YmlFileServices/ConfigY
import IsomerAdminsService from "@services/identity/IsomerAdminsService"
import UsersService from "@services/identity/UsersService"

import TokenStore from "./TokenStore"

interface SitesServiceProps {
siteRepository: ModelStatic<Site>
gitHubService: GitHubService
configYmlService: ConfigYmlService
usersService: UsersService
isomerAdminsService: IsomerAdminsService
tokenStore: TokenStore
}

type SiteUrlTypes = "staging" | "prod"
Expand All @@ -49,22 +46,18 @@ class SitesService {

private readonly isomerAdminsService: SitesServiceProps["isomerAdminsService"]

private readonly tokenStore: SitesServiceProps["tokenStore"]

constructor({
siteRepository,
gitHubService,
configYmlService,
usersService,
isomerAdminsService,
tokenStore,
}: SitesServiceProps) {
this.siteRepository = siteRepository
this.gitHubService = gitHubService
this.configYmlService = configYmlService
this.usersService = usersService
this.isomerAdminsService = isomerAdminsService
this.tokenStore = tokenStore
}

isGitHubCommitData(commit: any): commit is GitHubCommitData {
Expand Down
37 changes: 0 additions & 37 deletions src/services/identity/TokenStore.ts

This file was deleted.

6 changes: 0 additions & 6 deletions src/services/identity/__tests__/SitesService.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import { GitHubService } from "@services/db/GitHubService"
import { ConfigYmlService } from "@services/fileServices/YmlFileServices/ConfigYmlService"
import IsomerAdminsService from "@services/identity/IsomerAdminsService"
import _SitesService from "@services/identity/SitesService"
import TokenStore from "@services/identity/TokenStore"
import UsersService from "@services/identity/UsersService"

const MockRepository = {
Expand All @@ -63,17 +62,12 @@ const MockIsomerAdminsService = {
getByUserId: jest.fn(),
}

const MockTokenStore = {
getToken: jest.fn(),
}

const SitesService = new _SitesService({
siteRepository: (MockRepository as unknown) as ModelStatic<Site>,
gitHubService: (MockGithubService as unknown) as GitHubService,
configYmlService: (MockConfigYmlService as unknown) as ConfigYmlService,
usersService: (MockUsersService as unknown) as UsersService,
isomerAdminsService: (MockIsomerAdminsService as unknown) as IsomerAdminsService,
tokenStore: (MockTokenStore as unknown) as TokenStore,
})

const mockSiteName = "some site name"
Expand Down
48 changes: 0 additions & 48 deletions src/services/identity/__tests__/TokenStore.spec.ts

This file was deleted.

0 comments on commit 2196e93

Please sign in to comment.