-
Notifications
You must be signed in to change notification settings - Fork 302
Expand file tree
/
Copy pathprepareBitGo.ts
More file actions
85 lines (75 loc) · 2.58 KB
/
prepareBitGo.ts
File metadata and controls
85 lines (75 loc) · 2.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import * as assert from 'assert';
import * as sinon from 'sinon';
import 'should';
import { Config } from '../../../src/config';
describe('prepareBitGo middleware', function () {
afterEach(function () {
sinon.restore();
});
describe('authVersion configuration', function () {
it('should pass authVersion 2 to BitGo constructor by default', async function () {
const config: Config = {
port: 3080,
bind: 'localhost',
env: 'test',
debugNamespace: [],
logFile: '',
disableSSL: false,
disableProxy: false,
disableEnvCheck: true,
timeout: 305000,
authVersion: 2, // Default
};
// We would need to make prepareBitGo exportable to test it directly
// For now, document that authVersion should be passed through
assert.strictEqual(config.authVersion, 2);
});
it('should pass authVersion 4 to BitGo constructor when configured', async function () {
const config: Config = {
port: 3080,
bind: 'localhost',
env: 'test',
debugNamespace: [],
logFile: '',
disableSSL: false,
disableProxy: false,
disableEnvCheck: true,
timeout: 305000,
authVersion: 4, // V4 auth
};
assert.strictEqual(config.authVersion, 4);
});
it('should respect BITGO_AUTH_VERSION environment variable', function () {
const originalEnv = process.env.BITGO_AUTH_VERSION;
try {
process.env.BITGO_AUTH_VERSION = '4';
// Would need to reload config module to test this properly
// Document expected behavior
assert.strictEqual(process.env.BITGO_AUTH_VERSION, '4');
} finally {
if (originalEnv !== undefined) {
process.env.BITGO_AUTH_VERSION = originalEnv;
} else {
delete process.env.BITGO_AUTH_VERSION;
}
}
});
});
describe('BitGo constructor parameters', function () {
it('should include authVersion in BitGoOptions', function () {
// This test documents that BitGoOptions should include authVersion
// The actual implementation is in clientRoutes.ts prepareBitGo function
const expectedParams = {
env: 'test',
customRootURI: undefined,
customBitcoinNetwork: undefined,
accessToken: undefined,
userAgent: 'BitGoExpress/test BitGoJS/test',
authVersion: 2, // Should be passed from config
};
// Verify structure
assert.ok(expectedParams.authVersion !== undefined);
assert.ok([2, 3, 4].includes(expectedParams.authVersion));
});
});
});