-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: empty sensitive envs values in Neo Session Launcher
- Loading branch information
Showing
6 changed files
with
139 additions
and
16 deletions.
There are no files selected for viewing
This file contains 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,54 @@ | ||
import { | ||
createSession, | ||
deleteSession, | ||
loginAsUser, | ||
navigateTo, | ||
} from './test-util'; | ||
import { test, expect } from '@playwright/test'; | ||
|
||
test.describe('NEO Sessions Launcher', () => { | ||
test.beforeEach(async ({ page }) => { | ||
await loginAsUser(page); | ||
}); | ||
|
||
const sessionName = 'e2e-test-session'; | ||
test('User can create session in NEO', async ({ page }) => { | ||
await createSession(page, sessionName); | ||
await deleteSession(page, sessionName); | ||
}); | ||
|
||
test('Sensitive environment variables are cleared when the browser is reloaded.', async ({ | ||
page, | ||
}) => { | ||
await navigateTo(page, 'session/start'); | ||
await page | ||
.getByRole('button', { name: '2 Environments & Resource' }) | ||
.click(); | ||
await page | ||
.getByRole('button', { name: 'plus Add environment variables' }) | ||
.click(); | ||
await page.getByPlaceholder('Variable').fill('abc'); | ||
await page.getByPlaceholder('Variable').press('Tab'); | ||
await page.getByPlaceholder('Value').fill('123'); | ||
await page | ||
.getByRole('button', { name: 'plus Add environment variables' }) | ||
.click(); | ||
await page.locator('#envvars_1_variable').fill('password'); | ||
await page.locator('#envvars_1_variable').press('Tab'); | ||
await page.locator('#envvars_1_value').fill('hello'); | ||
await page | ||
.getByRole('button', { name: 'plus Add environment variables' }) | ||
.click(); | ||
await page.locator('#envvars_2_variable').fill('api_key'); | ||
await page.locator('#envvars_2_variable').press('Tab'); | ||
await page.locator('#envvars_2_value').fill('secret'); | ||
await page.waitForTimeout(1000); // Wait for the form state to be saved as query param. | ||
await page.reload(); | ||
await expect( | ||
page.locator('#envvars_1_value_help').getByText('Please enter a value.'), | ||
).toBeVisible(); | ||
await expect( | ||
page.locator('#envvars_2_value_help').getByText('Please enter a value.'), | ||
).toBeVisible(); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
This file contains 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,35 @@ | ||
// EnvVarFormList.test.tsx | ||
import { sanitizeSensitiveEnv } from './EnvVarFormList'; | ||
|
||
describe('emptySensitiveEnv', () => { | ||
it('should empty the value of sensitive environment variables', () => { | ||
const envs = [ | ||
{ variable: 'SECRET_KEY', value: '12345' }, | ||
{ variable: 'API_KEY', value: 'abcdef' }, | ||
{ variable: 'NON_SENSITIVE', value: 'value' }, | ||
]; | ||
|
||
const result = sanitizeSensitiveEnv(envs); | ||
|
||
expect(result).toEqual([ | ||
{ variable: 'SECRET_KEY', value: '' }, | ||
{ variable: 'API_KEY', value: '' }, | ||
{ variable: 'NON_SENSITIVE', value: 'value' }, | ||
]); | ||
}); | ||
|
||
it('should not change non-sensitive environment variables', () => { | ||
const envs = [{ variable: 'NON_SENSITIVE', value: 'value' }]; | ||
const result = sanitizeSensitiveEnv(envs); | ||
|
||
expect(result).toEqual([{ variable: 'NON_SENSITIVE', value: 'value' }]); | ||
}); | ||
|
||
it('should handle an empty array', () => { | ||
const envs: any[] = []; | ||
|
||
const result = sanitizeSensitiveEnv(envs); | ||
|
||
expect(result).toEqual([]); | ||
}); | ||
}); |
This file contains 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 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 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