Repository navigation
fix: clean properties we send #9067
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -117,8 +117,9 @@ | |
| didEnableCompileCache: expect.any(Boolean), | ||
| monorepo: false, | ||
| nodejsVersion, | ||
| flags: [], | ||
| opts: expect.any(Object), | ||
| args: expect.any(Array), | ||
| argCount: expect.any(Number), | ||
| // TODO: this should be NPM however some CI tests are using pnpm which changes the value | ||
| packageManager: expect.stringMatching(/npm|pnpm/), | ||
| }) | ||
|
|
@@ -143,8 +144,9 @@ | |
| didEnableCompileCache: expect.any(Boolean), | ||
| monorepo: false, | ||
| nodejsVersion, | ||
| flags: [], | ||
| opts: expect.any(Object), | ||
| args: expect.any(Array), | ||
| argCount: expect.any(Number), | ||
| // TODO: this should be NPM however some CI tests are using pnpm which changes the value | ||
| packageManager: expect.stringMatching(/npm|pnpm/), | ||
| }) | ||
|
|
@@ -174,8 +176,10 @@ | |
| }) | ||
| }) | ||
|
|
||
| test('should attach user options as `opts` and positional args as `args`', async () => { | ||
| await withMockApi(routes, async ({ apiUrl, requests }) => { | ||
| test<MockApiTestContext>('should attach user-set flag names as `flags` and the positional arg count as `argCount`', async ({ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Restore the mock API wrappers. Both tests omit Removing the closures alone will not fix the tests: the Also applies to: 202-202
|
||
| apiUrl, | ||
| requests, | ||
| }) => { | ||
| await expect( | ||
| callCli(['blobs:get', '--filter', 'web', '-O', './output_dir', 'my-store', 'my-key'], getCLIOptions(apiUrl)), | ||
| ).rejects.toThrow(/You don't appear to be in a folder that is linked to a project/) | ||
|
|
@@ -187,33 +191,34 @@ | |
| 'properties', | ||
| expect.objectContaining({ | ||
| command: 'blobs:get', | ||
| opts: { | ||
| filter: { source: 'cli', value: 'web' }, | ||
| output: { source: 'cli', value: './output_dir' }, | ||
| }, | ||
| args: ['my-store', 'my-key'], | ||
| flags: ['filter', 'output'], | ||
| opts: {}, | ||
| argCount: 2, | ||
| }), | ||
| ) | ||
| }) | ||
| }) | ||
|
Check failure on line 200 in tests/integration/telemetry.test.ts
|
||
|
|
||
| test('should scrub values of sensitive `opts`', async () => { | ||
| await withMockApi(routes, async ({ apiUrl, requests }) => { | ||
| await callCli(['api', 'listSites', '--auth', 'my-sensitive-token'], getCLIOptions(apiUrl)) | ||
| test<MockApiTestContext>('should not send option values or positional args', async ({ apiUrl, requests }) => { | ||
| await callCli( | ||
| ['api', 'listSites', '--auth', 'my-sensitive-token', '--data', '{"filter":"my-filter-value"}'], | ||
| getCLIOptions(apiUrl), | ||
| ) | ||
| const request = requests.find(({ path }) => path === '/api/v1/track') | ||
| expect(request).toBeDefined() | ||
|
|
||
| expect(request!.body).toHaveProperty('event', 'cli:command') | ||
| expect(request!.body).toHaveProperty( | ||
| 'properties', | ||
| expect.objectContaining({ | ||
| command: 'api', | ||
| opts: { | ||
| auth: { source: 'cli', value: '********' }, | ||
| list: { source: 'default', value: false }, | ||
| }, | ||
| args: ['listSites'], | ||
| flags: ['auth', 'data'], | ||
| opts: {}, | ||
| argCount: 1, | ||
| }), | ||
| ) | ||
| const sentPayload = JSON.stringify(request!.body) | ||
| expect(sentPayload).not.toContain('my-sensitive-token') | ||
| expect(sentPayload).not.toContain('my-filter-value') | ||
| expect(sentPayload).not.toContain('listSites') | ||
| }) | ||
| }) | ||
|
Check failure on line 224 in tests/integration/telemetry.test.ts
|
||
Uh oh!
There was an error while loading. Please reload this page.