Skip to content

Commit 3a30b54

Browse files
committed
CR
1 parent 5ce4b62 commit 3a30b54

File tree

4 files changed

+185
-1
lines changed

4 files changed

+185
-1
lines changed

integration/web-e2e_test.go

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//go:build webassets_embed
2+
13
package integration
24

35
import (
@@ -42,3 +44,65 @@ func TestSignup(t *testing.T) {
4244
cmd.Stderr = os.Stderr
4345
require.NoError(t, cmd.Run())
4446
}
47+
48+
// TestCreateNewRole sets up a test instance of Teleport and a user to test role management in the UI.
49+
func TestRoleManagement(t *testing.T) {
50+
rc, ctx := helpers.CreateTeleportTestInstance(t)
51+
52+
as := rc.Process.GetAuthServer()
53+
54+
accessRole := services.NewPresetAccessRole()
55+
editorRole := services.NewPresetEditorRole()
56+
57+
// Create a test user.
58+
testUser, err := types.NewUser("testuser")
59+
require.NoError(t, err)
60+
testUser.SetRoles([]string{accessRole.GetName(), editorRole.GetName()})
61+
user, err := as.UpsertUser(ctx, testUser)
62+
63+
inviteToken, err := as.CreateResetPasswordToken(ctx, authclient.CreateUserTokenRequest{
64+
Name: user.GetName(),
65+
})
66+
require.NoError(t, err)
67+
68+
// Generate the URL the playwright test will start from.
69+
startUrl := fmt.Sprintf("START_URL=https://%s/web/invite/%s", rc.Web, inviteToken.GetName())
70+
71+
// Start the playwright test
72+
cmd := exec.Command("pnpm", "test-e2e", "roles.spec.ts", "--headed")
73+
cmd.Env = append(os.Environ(), startUrl)
74+
cmd.Stdout = os.Stdout
75+
cmd.Stderr = os.Stderr
76+
require.NoError(t, cmd.Run())
77+
}
78+
79+
// TestAuthConnectorManagement sets up a test instance of Teleport and a user to test auth connector management in the UI.
80+
func TestAuthConnectorManagement(t *testing.T) {
81+
rc, ctx := helpers.CreateTeleportTestInstance(t)
82+
83+
as := rc.Process.GetAuthServer()
84+
85+
accessRole := services.NewPresetAccessRole()
86+
editorRole := services.NewPresetEditorRole()
87+
88+
// Create a test user.
89+
testUser, err := types.NewUser("testuser")
90+
require.NoError(t, err)
91+
testUser.SetRoles([]string{accessRole.GetName(), editorRole.GetName()})
92+
user, err := as.UpsertUser(ctx, testUser)
93+
94+
inviteToken, err := as.CreateResetPasswordToken(ctx, authclient.CreateUserTokenRequest{
95+
Name: user.GetName(),
96+
})
97+
require.NoError(t, err)
98+
99+
// Generate the URL the playwright test will start from.
100+
startUrl := fmt.Sprintf("START_URL=https://%s/web/invite/%s", rc.Web, inviteToken.GetName())
101+
102+
// Start the playwright test
103+
cmd := exec.Command("pnpm", "test-e2e", "authconnectors.spec.ts", "--headed")
104+
cmd.Env = append(os.Environ(), startUrl)
105+
cmd.Stdout = os.Stdout
106+
cmd.Stderr = os.Stderr
107+
require.NoError(t, cmd.Run())
108+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import { expect, test } from '@playwright/test';
2+
3+
import { mockWebAuthn } from '../utils/mockWebAuthn';
4+
5+
test('verify that a user can create and delete an auth connector', async ({
6+
page,
7+
}) => {
8+
const { cleanup } = await mockWebAuthn(page);
9+
10+
await page.goto('');
11+
12+
await page.getByRole('button', { name: 'Get started' }).click();
13+
await page.getByRole('textbox', { name: 'Password', exact: true }).click();
14+
await page
15+
.getByRole('textbox', { name: 'Password', exact: true })
16+
.fill('passwordtest123');
17+
await page
18+
.getByRole('textbox', { name: 'Password', exact: true })
19+
.press('Tab');
20+
await page
21+
.getByRole('textbox', { name: 'Confirm Password' })
22+
.fill('passwordtest123');
23+
await page.getByRole('button', { name: 'Next' }).click();
24+
await page.getByRole('button', { name: 'Create an MFA Method' }).click();
25+
await page.getByRole('button', { name: 'Submit' }).click();
26+
await page.getByRole('button', { name: 'Go to Cluster' }).click();
27+
28+
await page.getByRole('button', { name: "I'll do that later" }).click();
29+
30+
await page.getByRole('button', { name: 'Zero Trust Access' }).click();
31+
await page.getByRole('link', { name: 'Auth Connectors' }).click();
32+
await page.getByRole('button', { name: 'New GitHub Connector' }).click();
33+
34+
await page.waitForSelector('.ace_editor', { state: 'visible' });
35+
await page.evaluate(() => {
36+
const editor = (window as any).ace.edit(
37+
document.querySelector('.ace_editor')
38+
);
39+
40+
const lines = editor.session.getDocument().getAllLines();
41+
42+
lines[3] = ' name: testconnector';
43+
44+
editor.session.setValue(lines.join('\n'));
45+
});
46+
47+
await page.getByRole('button', { name: 'Save Changes' }).click();
48+
49+
await expect(page.getByText('testconnector')).toBeVisible();
50+
51+
const connectorTile = page.getByTestId('testconnector-tile');
52+
53+
await connectorTile.getByRole('button').click();
54+
55+
await page.getByRole('menuitem', { name: 'Delete' }).click();
56+
await page.getByRole('button', { name: 'Delete Connector' }).click();
57+
58+
await expect(page.getByText('testconnector')).not.toBeVisible();
59+
60+
cleanup();
61+
});

web/e2e/tests/roles.spec.ts

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import { expect, test } from '@playwright/test';
2+
3+
import { mockWebAuthn } from '../utils/mockWebAuthn';
4+
5+
test('verify that a user can create and delete a role', async ({ page }) => {
6+
const { cleanup } = await mockWebAuthn(page);
7+
8+
await page.goto('');
9+
10+
await page.getByRole('button', { name: 'Get started' }).click();
11+
await page.getByRole('textbox', { name: 'Password', exact: true }).click();
12+
await page
13+
.getByRole('textbox', { name: 'Password', exact: true })
14+
.fill('passwordtest123');
15+
await page
16+
.getByRole('textbox', { name: 'Password', exact: true })
17+
.press('Tab');
18+
await page
19+
.getByRole('textbox', { name: 'Confirm Password' })
20+
.fill('passwordtest123');
21+
await page.getByRole('button', { name: 'Next' }).click();
22+
await page.getByRole('button', { name: 'Create an MFA Method' }).click();
23+
await page.getByRole('button', { name: 'Submit' }).click();
24+
await page.getByRole('button', { name: 'Go to Cluster' }).click();
25+
26+
await page.getByRole('button', { name: "I'll do that later" }).click();
27+
28+
await page.getByRole('button', { name: 'Zero Trust Access' }).click();
29+
await page.getByRole('link', { name: 'Roles' }).click();
30+
await page.getByTestId('create_new_role_button').click();
31+
await page.getByRole('textbox', { name: 'Role Name(required)' }).click();
32+
await page
33+
.getByRole('textbox', { name: 'Role Name(required)' })
34+
.press('ControlOrMeta+a');
35+
await page
36+
.getByRole('textbox', { name: 'Role Name(required)' })
37+
.fill('testrole');
38+
await page.getByRole('button', { name: 'Next: Resources' }).click();
39+
await page
40+
.getByRole('button', { name: 'Add Teleport Resource Access' })
41+
.click();
42+
await page.getByRole('menuitem', { name: 'SSH Server Access' }).click();
43+
await page.getByRole('button', { name: 'Next: Admin Rules' }).click();
44+
await page.getByRole('button', { name: 'Next: Options' }).click();
45+
await page.getByRole('button', { name: 'Create Role' }).click();
46+
47+
await expect(page.getByRole('cell', { name: 'testrole' })).toBeVisible();
48+
49+
await page
50+
.getByRole('row', { name: 'testrole Options' })
51+
.getByRole('button')
52+
.click();
53+
await page.getByRole('menuitem', { name: 'Delete' }).click();
54+
await page.getByRole('button', { name: 'Yes, Remove Role' }).click();
55+
56+
await expect(page.getByRole('cell', { name: 'testrole' })).not.toBeVisible();
57+
58+
cleanup();
59+
});

web/packages/teleport/src/AuthConnectors/AuthConnectorTile.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export function AuthConnectorTile({
7373
}
7474

7575
return (
76-
<ConnectorBox tabIndex={0}>
76+
<ConnectorBox tabIndex={0} data-testid={`${name}-tile`}>
7777
<Flex
7878
flexDirection="column"
7979
justifyContent="space-between"

0 commit comments

Comments
 (0)