-
Notifications
You must be signed in to change notification settings - Fork 3.7k
test(e2e): cover credential settings workflows #5846
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
Merged
BillLeoutsakosvl346
merged 4 commits into
e2e/settings-playwright
from
e2e/05-credentials
Jul 22, 2026
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
322 changes: 180 additions & 142 deletions
322
apps/sim/app/workspace/[workspaceId]/settings/components/api-keys/api-keys.tsx
Large diffs are not rendered by default.
Oops, something went wrong.
52 changes: 52 additions & 0 deletions
52
...Id]/settings/components/secrets/components/secret-value-field/secret-value-field.test.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| /** | ||
| * @vitest-environment jsdom | ||
| */ | ||
| import { act, type ComponentProps } from 'react' | ||
| import { createRoot, type Root } from 'react-dom/client' | ||
| import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' | ||
| import { SecretValueField } from './secret-value-field' | ||
|
|
||
| vi.mock('@sim/emcn', () => ({ | ||
| ChipInput: (props: ComponentProps<'input'>) => <input {...props} />, | ||
| })) | ||
|
|
||
| describe('SecretValueField', () => { | ||
| let container: HTMLDivElement | ||
| let root: Root | ||
|
|
||
| beforeEach(() => { | ||
| container = document.createElement('div') | ||
| document.body.appendChild(container) | ||
| root = createRoot(container) | ||
| }) | ||
|
|
||
| afterEach(() => { | ||
| act(() => root.unmount()) | ||
| container.remove() | ||
| }) | ||
|
|
||
| it('keeps editable plaintext out of the DOM until focus', () => { | ||
| act(() => root.render(<SecretValueField value='private-value' onChange={() => undefined} />)) | ||
| const input = container.querySelector('input') | ||
| expect(input).not.toBeNull() | ||
| expect(input?.type).toBe('text') | ||
| expect(input?.value).toBe('••••••••••') | ||
|
|
||
| act(() => input?.focus()) | ||
| expect(input?.type).toBe('text') | ||
| expect(input?.value).toBe('private-value') | ||
|
|
||
| act(() => input?.blur()) | ||
| expect(input?.type).toBe('text') | ||
| expect(input?.value).toBe('••••••••••') | ||
| }) | ||
|
|
||
| it('uses a fixed mask for viewers regardless of secret length', () => { | ||
| act(() => root.render(<SecretValueField value='short' canEdit={false} />)) | ||
| const input = container.querySelector('input') | ||
| expect(input?.value).toBe('••••••••••') | ||
|
|
||
| act(() => root.render(<SecretValueField value='a-much-longer-private-value' canEdit={false} />)) | ||
| expect(input?.value).toBe('••••••••••') | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
.../app/workspace/[workspaceId]/settings/secrets/[credentialId]/secret-detail-access.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| import { describe, expect, it } from 'vitest' | ||
| import { canOpenSecretDetail } from './secret-detail-access' | ||
|
|
||
| const allowedAccess = { | ||
| credential: { workspaceId: 'workspace-a', type: 'env_workspace' }, | ||
| hasWorkspaceAccess: true, | ||
| hasActiveMembership: true, | ||
| isAdmin: false, | ||
| } | ||
|
|
||
| describe('canOpenSecretDetail', () => { | ||
| it('allows active members and derived admins for matching environment credentials', () => { | ||
| expect( | ||
| canOpenSecretDetail({ | ||
| workspaceId: 'workspace-a', | ||
| secretsHidden: false, | ||
| access: allowedAccess, | ||
| }) | ||
| ).toBe(true) | ||
| expect( | ||
| canOpenSecretDetail({ | ||
| workspaceId: 'workspace-a', | ||
| secretsHidden: false, | ||
| access: { | ||
| ...allowedAccess, | ||
| credential: { workspaceId: 'workspace-a', type: 'env_personal' }, | ||
| hasActiveMembership: false, | ||
| isAdmin: true, | ||
| }, | ||
| }) | ||
| ).toBe(true) | ||
| }) | ||
|
|
||
| it.each([ | ||
| ['missing credential', { ...allowedAccess, credential: null }, false], | ||
| [ | ||
| 'cross-workspace credential', | ||
| { | ||
| ...allowedAccess, | ||
| credential: { workspaceId: 'workspace-b', type: 'env_workspace' }, | ||
| }, | ||
| false, | ||
| ], | ||
| [ | ||
| 'wrong credential type', | ||
| { ...allowedAccess, credential: { workspaceId: 'workspace-a', type: 'oauth' } }, | ||
| false, | ||
| ], | ||
| ['missing workspace access', { ...allowedAccess, hasWorkspaceAccess: false }, false], | ||
| [ | ||
| 'missing credential membership', | ||
| { ...allowedAccess, hasActiveMembership: false, isAdmin: false }, | ||
| false, | ||
| ], | ||
| ])('rejects %s', (_label, access, expected) => { | ||
| expect( | ||
| canOpenSecretDetail({ | ||
| workspaceId: 'workspace-a', | ||
| secretsHidden: false, | ||
| access, | ||
| }) | ||
| ).toBe(expected) | ||
| }) | ||
|
|
||
| it('rejects permission-group hidden Secrets', () => { | ||
| expect( | ||
| canOpenSecretDetail({ | ||
| workspaceId: 'workspace-a', | ||
| secretsHidden: true, | ||
| access: allowedAccess, | ||
| }) | ||
| ).toBe(false) | ||
| }) | ||
| }) |
27 changes: 27 additions & 0 deletions
27
apps/sim/app/workspace/[workspaceId]/settings/secrets/[credentialId]/secret-detail-access.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| interface SecretDetailCredential { | ||
| workspaceId: string | ||
| type: string | ||
| } | ||
|
|
||
| interface SecretDetailAccess { | ||
| credential: SecretDetailCredential | null | ||
| hasWorkspaceAccess: boolean | ||
| hasActiveMembership: boolean | ||
| isAdmin: boolean | ||
| } | ||
|
|
||
| export function canOpenSecretDetail(options: { | ||
| workspaceId: string | ||
| secretsHidden: boolean | ||
| access: SecretDetailAccess | ||
| }): boolean { | ||
| const { access } = options | ||
| return Boolean( | ||
| !options.secretsHidden && | ||
| access.credential && | ||
| access.credential.workspaceId === options.workspaceId && | ||
| (access.credential.type === 'env_personal' || access.credential.type === 'env_workspace') && | ||
| access.hasWorkspaceAccess && | ||
| (access.hasActiveMembership || access.isAdmin) | ||
| ) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new route gate requires an active
credentialMemberrow even forenv_personalcredentials. If personal credential ownership is represented only byenvOwnerUserId, the owner is neither an active member nor a derived admin and now receives a 404 when opening their own secret detail page. Include personal ownership in this authorization decision or ensure that every personal credential owner has an active membership row.