Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: remove all usages of TokenStore and tests #533

Merged
merged 1 commit into from
Oct 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.