Skip to content

Commit b755f81

Browse files
committed
wip: cleanup
1 parent 5fa5d8e commit b755f81

File tree

6 files changed

+5
-65
lines changed

6 files changed

+5
-65
lines changed

meteor/__mocks__/meteor.ts

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { stringifyError } from '@sofie-automation/shared-lib/dist/lib/stringifyError'
22
import * as _ from 'underscore'
33
import { Fiber } from './Fibers'
4-
import { MongoMock } from './mongo'
54
import { USER_PERMISSIONS_HEADER } from '@sofie-automation/meteor-lib/dist/userPermissions'
65

76
let controllableDefer = false
@@ -13,27 +12,14 @@ export function useNextTickDefer(): void {
1312
controllableDefer = false
1413
}
1514

16-
namespace Meteor {
15+
export namespace Meteor {
1716
export interface Settings {
1817
public: {
1918
[id: string]: any
2019
}
2120
[id: string]: any
2221
}
2322

24-
export interface UserEmail {
25-
address: string
26-
verified: boolean
27-
}
28-
export interface User {
29-
_id?: string
30-
username?: string
31-
emails?: UserEmail[]
32-
createdAt?: number
33-
profile?: any
34-
services?: any
35-
}
36-
3723
export interface ErrorStatic {
3824
new (error: string | number, reason?: string, details?: string): Error
3925
}
@@ -107,23 +93,16 @@ export namespace MeteorMock {
10793
export const settings: any = {}
10894

10995
export const mockMethods: { [name: string]: Function } = {}
110-
export let mockUser: Meteor.User | undefined = undefined
11196
export const mockStartupFunctions: Function[] = []
11297

11398
export const absolutePath = process.cwd()
11499

115-
export function user(): Meteor.User | undefined {
116-
return mockUser
117-
}
118-
export function userId(): string | undefined {
119-
return mockUser ? mockUser._id : undefined
120-
}
121100
function getMethodContext() {
122101
return {
123-
userId: mockUser ? mockUser._id : undefined,
124102
connection: {
125103
clientAddress: '1.1.1.1',
126104
httpHeaders: {
105+
// Default to full permissions for tests
127106
[USER_PERMISSIONS_HEADER]: 'admin',
128107
},
129108
},
@@ -285,7 +264,6 @@ export namespace MeteorMock {
285264
}
286265
}
287266
}
288-
export let users: MongoMock.Collection<any> | undefined = undefined
289267

290268
// -- Mock functions: --------------------------
291269
/**
@@ -298,12 +276,6 @@ export namespace MeteorMock {
298276

299277
waitTimeNoFakeTimers(10) // So that any observers or defers has had time to run.
300278
}
301-
export function mockLoginUser(newUser: Meteor.User): void {
302-
mockUser = newUser
303-
}
304-
export function mockSetUsersCollection(usersCollection: MongoMock.Collection<any>): void {
305-
users = usersCollection
306-
}
307279
export function mockSetClientEnvironment(): void {
308280
mockIsClient = true
309281
}

meteor/__mocks__/mongo.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,5 +350,3 @@ export function setup(): any {
350350
Mongo: MongoMock,
351351
}
352352
}
353-
354-
MeteorMock.mockSetUsersCollection(new MongoMock.Collection('Meteor.users'))

meteor/server/api/peripheralDevice.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ import { convertPeripheralDeviceForGateway } from '../publications/peripheralDev
6767
import { executePeripheralDeviceFunction } from './peripheralDevice/executeFunction'
6868
import KoaRouter from '@koa/router'
6969
import bodyParser from 'koa-bodyparser'
70+
import { checkUserIdHasOneOfPermissions } from '../security/auth'
7071

7172
const apmNamespace = 'peripheralDevice'
7273
export namespace ServerPeripheralDeviceAPI {

packages/shared-lib/src/peripheralDevice/methodsAPI.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ export interface NewPeripheralDeviceAPI {
116116
timelineTriggerTime(deviceId: PeripheralDeviceId, deviceToken: string, r: TimelineTriggerTimeResult): Promise<void>
117117
requestUserAuthToken(deviceId: PeripheralDeviceId, deviceToken: string, authUrl: string): Promise<void>
118118
storeAccessToken(deviceId: PeripheralDeviceId, deviceToken: string, authToken: string): Promise<void>
119-
removePeripheralDevice(deviceId: PeripheralDeviceId): Promise<void>
119+
removePeripheralDevice(deviceId: PeripheralDeviceId, deviceToken?: string): Promise<void>
120120
reportResolveDone(
121121
deviceId: PeripheralDeviceId,
122122
deviceToken: string,

packages/webui/src/__mocks__/meteor.ts

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import * as _ from 'underscore'
2-
import { MongoMock } from './mongo'
32
import type { DDP } from 'meteor/ddp'
43

54
let controllableDefer = false
@@ -11,27 +10,14 @@ export function useNextTickDefer(): void {
1110
controllableDefer = false
1211
}
1312

14-
namespace Meteor {
13+
export namespace Meteor {
1514
export interface Settings {
1615
public: {
1716
[id: string]: any
1817
}
1918
[id: string]: any
2019
}
2120

22-
export interface UserEmail {
23-
address: string
24-
verified: boolean
25-
}
26-
export interface User {
27-
_id?: string
28-
username?: string
29-
emails?: UserEmail[]
30-
createdAt?: number
31-
profile?: any
32-
services?: any
33-
}
34-
3521
export interface ErrorStatic {
3622
new (error: string | number, reason?: string, details?: string): Error
3723
}
@@ -89,7 +75,6 @@ export namespace MeteorMock {
8975
export const settings: any = {}
9076

9177
export const mockMethods: { [name: string]: Function } = {}
92-
export let mockUser: Meteor.User | undefined = undefined
9378
export const mockStartupFunctions: Function[] = []
9479

9580
export function status(): DDP.DDPStatus {
@@ -100,15 +85,8 @@ export namespace MeteorMock {
10085
}
10186
}
10287

103-
export function user(): Meteor.User | undefined {
104-
return mockUser
105-
}
106-
export function userId(): string | undefined {
107-
return mockUser ? mockUser._id : undefined
108-
}
10988
function getMethodContext() {
11089
return {
111-
userId: mockUser ? mockUser._id : undefined,
11290
connection: {
11391
clientAddress: '1.1.1.1',
11492
},
@@ -223,7 +201,6 @@ export namespace MeteorMock {
223201
export function bindEnvironment(_fcn: Function): any {
224202
throw new Error(500, 'bindEnvironment not supported on client')
225203
}
226-
export let users: MongoMock.Collection<any> | undefined = undefined
227204

228205
// -- Mock functions: --------------------------
229206
/**
@@ -236,12 +213,6 @@ export namespace MeteorMock {
236213

237214
await waitTimeNoFakeTimers(10) // So that any observers or defers has had time to run.
238215
}
239-
export function mockLoginUser(newUser: Meteor.User): void {
240-
mockUser = newUser
241-
}
242-
export function mockSetUsersCollection(usersCollection: MongoMock.Collection<any>): void {
243-
users = usersCollection
244-
}
245216

246217
/** Wait for time to pass ( unaffected by jest.useFakeTimers() ) */
247218
export async function sleepNoFakeTimers(time: number): Promise<void> {

packages/webui/src/__mocks__/mongo.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,5 +349,3 @@ export function setup(): any {
349349
Mongo: MongoMock,
350350
}
351351
}
352-
353-
MeteorMock.mockSetUsersCollection(new MongoMock.Collection('Meteor.users'))

0 commit comments

Comments
 (0)