@homebridge-plugins/homebridge-august 3.4.1 → 3.4.2-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,86 +0,0 @@
1
- import { describe, expect, it } from 'vitest'
2
-
3
- import { redactConfig } from '../src/redact.js'
4
-
5
- describe('redactConfig', () => {
6
- it('masks a password but shows that one is set', () => {
7
- const out = redactConfig({ password: 'hunter2' }) as Record<string, unknown>
8
- expect(out.password).toBe('<redacted>')
9
- expect(JSON.stringify(out)).not.toContain('hunter2')
10
- })
11
-
12
- it('distinguishes a blank value from a set one', () => {
13
- expect((redactConfig({ password: '' }) as Record<string, unknown>).password).toBe('<empty>')
14
- expect((redactConfig({ password: 'x' }) as Record<string, unknown>).password).toBe('<redacted>')
15
- })
16
-
17
- it('leaves an unset value alone so it reads as never configured', () => {
18
- const out = redactConfig({ password: undefined, other: 1 }) as Record<string, unknown>
19
- expect(out.password).toBeUndefined()
20
- expect(out.other).toBe(1)
21
- })
22
-
23
- it('partially masks an email so the account stays identifiable', () => {
24
- const out = redactConfig({ email: 'someone@example.com' }) as Record<string, unknown>
25
- expect(out.email).toBe('s*****@example.com')
26
- })
27
-
28
- it('leaves a non-email string alone', () => {
29
- expect((redactConfig({ email: 'notanemail' }) as Record<string, unknown>).email).toBe('notanemail')
30
- })
31
-
32
- it('masks an email-shaped value under any key name', () => {
33
- const out = redactConfig({ augustId: 'someone@example.com', user: 'a@b.co' }) as Record<string, unknown>
34
- expect(out.augustId).toBe('s*****@example.com')
35
- expect(out.user).toBe('a*****@b.co')
36
- })
37
-
38
- it('redacts the roomba blid and nested device credentials', () => {
39
- const out = redactConfig({
40
- devices: [
41
- { name: 'Living Room', blid: '1234567890', password: ':1:9999:abcdef' },
42
- ],
43
- }) as { devices: Record<string, unknown>[] }
44
-
45
- expect(out.devices[0].name).toBe('Living Room')
46
- expect(out.devices[0].blid).toBe('<redacted>')
47
- expect(out.devices[0].password).toBe('<redacted>')
48
- expect(JSON.stringify(out)).not.toContain('abcdef')
49
- })
50
-
51
- it('keeps non-sensitive settings readable', () => {
52
- const out = redactConfig({
53
- name: 'Roomba',
54
- debug: true,
55
- disableDiscovery: false,
56
- mission: { ordered: 1, regions: [{ region_id: '3' }] },
57
- }) as Record<string, any>
58
-
59
- expect(out.name).toBe('Roomba')
60
- expect(out.debug).toBe(true)
61
- expect(out.disableDiscovery).toBe(false)
62
- expect(out.mission.regions[0].region_id).toBe('3')
63
- })
64
-
65
- it('matches sensitive keys case-insensitively and by substring', () => {
66
- const out = redactConfig({
67
- apiKey: 'a',
68
- API_KEY: 'b',
69
- refreshToken: 'c',
70
- clientSecret: 'd',
71
- credentials: { user: 'e' },
72
- }) as Record<string, unknown>
73
-
74
- expect(out.apiKey).toBe('<redacted>')
75
- expect(out.API_KEY).toBe('<redacted>')
76
- expect(out.refreshToken).toBe('<redacted>')
77
- expect(out.clientSecret).toBe('<redacted>')
78
- expect(out.credentials).toBe('<redacted>')
79
- })
80
-
81
- it('handles arrays and primitives without throwing', () => {
82
- expect(redactConfig([1, 'two', null])).toEqual([1, 'two', null])
83
- expect(redactConfig(null)).toBeNull()
84
- expect(redactConfig('plain')).toBe('plain')
85
- })
86
- })
@@ -1,148 +0,0 @@
1
- import type { AugustPlatformConfig, credentials, device, options } from '../src/settings.js'
2
-
3
- import { describe, expect, it } from 'vitest'
4
-
5
- import { PLATFORM_NAME, PLUGIN_NAME } from '../src/settings.js'
6
-
7
- describe('settings', () => {
8
- it('should have correct PLATFORM_NAME', () => {
9
- expect(PLATFORM_NAME).toBe('August')
10
- })
11
-
12
- it('should have correct PLUGIN_NAME', () => {
13
- expect(PLUGIN_NAME).toBe('homebridge-august')
14
- })
15
-
16
- it('should define AugustPlatformConfig interface', () => {
17
- const config: AugustPlatformConfig = {
18
- platform: 'August',
19
- credentials: {
20
- apiKey: 'test-api-key',
21
- pnSubKey: 'test-pn-sub-key',
22
- installId: 'test-install-id',
23
- augustId: 'test-august-id',
24
- password: 'test-password',
25
- countryCode: 'test-country-code',
26
- },
27
- options: {
28
- devices: [],
29
- allowInvalidCharacters: true,
30
- refreshRate: 60,
31
- updateRate: 60,
32
- pushRate: 60,
33
- logging: 'debug',
34
- },
35
- }
36
- expect(config.credentials?.apiKey).toBe('test-api-key')
37
- expect(config.options?.refreshRate).toBe(60)
38
- })
39
-
40
- it('should define credentials interface', () => {
41
- const creds: credentials = {
42
- apiKey: 'test-api-key',
43
- pnSubKey: 'test-pn-sub-key',
44
- installId: 'test-install-id',
45
- augustId: 'test-august-id',
46
- password: 'test-password',
47
- countryCode: 'test-country-code',
48
- }
49
- expect(creds.apiKey).toBe('test-api-key')
50
- expect(creds.installId).toBe('test-install-id')
51
- })
52
-
53
- it('should define options interface', () => {
54
- const opts: options = {
55
- devices: [],
56
- excludeLockIds: ['LOCK-ID-TO-EXCLUDE'],
57
- allowInvalidCharacters: true,
58
- refreshRate: 60,
59
- updateRate: 60,
60
- pushRate: 60,
61
- logging: 'debug',
62
- }
63
- expect(opts.refreshRate).toBe(60)
64
- expect(opts.logging).toBe('debug')
65
- expect(opts.excludeLockIds).toContain('LOCK-ID-TO-EXCLUDE')
66
- })
67
-
68
- it('should support disableMatter option', () => {
69
- const opts: options = {
70
- devices: [],
71
- disableMatter: true,
72
- }
73
- expect(opts.disableMatter).toBe(true)
74
-
75
- const optsDefault: options = {
76
- devices: [],
77
- }
78
- expect(optsDefault.disableMatter).toBeUndefined()
79
- })
80
-
81
- it('should define device interface', () => {
82
- const dev: device = {
83
- LockName: 'Test Lock',
84
- Type: 1,
85
- Created: '2023-01-01',
86
- Updated: '2023-01-02',
87
- LockId: 'test-lock-id',
88
- HouseID: 'test-house-id',
89
- HouseName: 'Test House',
90
- Calibrated: true,
91
- timeZone: 'UTC',
92
- battery: 100,
93
- batteryInfo: {
94
- level: 100,
95
- warningState: 'none',
96
- infoUpdatedDate: '2023-01-01',
97
- lastChangeDate: '2023-01-01',
98
- lastChangeVoltage: 4.2,
99
- },
100
- doorStateOpenTimeout: 30,
101
- hostLockInfo: {
102
- serialNumber: 'test-serial-number',
103
- manufacturer: 'Test Manufacturer',
104
- productID: 1234,
105
- productTypeID: 5678,
106
- },
107
- supportsEntryCodes: true,
108
- remoteOperateSecret: 'test-secret',
109
- skuNumber: 'test-sku',
110
- macAddress: '00:11:22:33:44:55',
111
- SerialNumber: 'test-serial-number',
112
- LockStatus: {
113
- status: 'locked',
114
- dateTime: '2023-01-01T00:00:00Z',
115
- isLockStatusChanged: true,
116
- valid: true,
117
- doorState: 'closed',
118
- },
119
- currentFirmwareVersion: '1.0.0',
120
- homeKitEnabled: true,
121
- zWaveEnabled: true,
122
- isGalileo: false,
123
- Bridge: {
124
- _id: 'test-bridge-id',
125
- mfgBridgeID: 'test-mfg-bridge-id',
126
- deviceModel: 'test-model',
127
- firmwareVersion: '1.0.0',
128
- operative: true,
129
- status: {
130
- current: 'online',
131
- lastOffline: '2023-01-01T00:00:00Z',
132
- updated: '2023-01-01T00:00:00Z',
133
- lastOnline: '2023-01-01T00:00:00Z',
134
- },
135
- locks: [],
136
- hyperBridge: false,
137
- },
138
- parametersToSet: {},
139
- users: {},
140
- pubsubChannel: 'test-channel',
141
- ruleHash: {},
142
- cameras: [],
143
- lockId: 'test-lock-id',
144
- }
145
- expect(dev.LockName).toBe('Test Lock')
146
- expect(dev.battery).toBe(100)
147
- })
148
- })