Keycloak

Форк
0
/
device-activity.spec.ts 
81 строка · 3.0 Кб
1
import { expect, test } from "@playwright/test";
2
import { login } from "../login";
3

4
test.describe("Sign out test", () => {
5
  test("Sign out one device", async ({ browser }) => {
6
    const context1 = await browser.newContext({
7
      userAgent:
8
        "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)",
9
    });
10
    const context2 = await browser.newContext();
11
    try {
12
      const page1 = await context1.newPage();
13
      const page2 = await context2.newPage();
14
      await login(page1, "jdoe", "jdoe", "groups");
15
      await page1.getByTestId("accountSecurity").click();
16
      await expect(
17
        page1.getByTestId("account-security/device-activity"),
18
      ).toBeVisible();
19
      await page1.getByTestId("account-security/device-activity").click();
20
      await expect(page1.getByTestId("row-0")).toContainText("Current session");
21

22
      await login(page2, "jdoe", "jdoe", "groups");
23
      await page2.getByTestId("accountSecurity").click();
24
      await expect(
25
        page2.getByTestId("account-security/device-activity"),
26
      ).toBeVisible();
27
      await page2.getByTestId("account-security/device-activity").click();
28

29
      await page2
30
        .getByRole("button", { name: "Sign out", exact: true })
31
        .click();
32
      await page2.getByRole("button", { name: "Confirm" }).click();
33

34
      // reload pages in browsers, one should stay logged in, the other should be logged out
35
      await page1.reload();
36
      await page2.reload();
37
      await expect(
38
        page1.getByRole("heading", { name: "Sign in to your account" }),
39
      ).toBeVisible();
40
      await expect(page2.getByTestId("accountSecurity")).toBeVisible();
41
    } finally {
42
      await context1.close();
43
      await context2.close();
44
    }
45
  });
46

47
  test("Sign out all devices", async ({ browser }) => {
48
    const context1 = await browser.newContext({
49
      userAgent:
50
        "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)",
51
    });
52
    const context2 = await browser.newContext();
53
    try {
54
      const page1 = await context1.newPage();
55
      const page2 = await context2.newPage();
56
      await login(page1, "jdoe", "jdoe", "groups");
57
      await login(page2, "jdoe", "jdoe", "groups");
58

59
      await page2.getByTestId("accountSecurity").click();
60
      await page2.getByTestId("account-security/device-activity").click();
61

62
      await page2
63
        .getByRole("button", { name: "Sign out all devices", exact: true })
64
        .click();
65
      await page2.getByRole("button", { name: "Confirm" }).click();
66

67
      // reload pages in browsers, one should stay logged in, the other should be logged out
68
      await page1.reload();
69
      // Reload in page2 should not be needed, as it should be logged out after clicking the button
70
      await expect(
71
        page1.getByRole("heading", { name: "Sign in to your account" }),
72
      ).toBeVisible();
73
      await expect(
74
        page2.getByRole("heading", { name: "Sign in to your account" }),
75
      ).toBeVisible();
76
    } finally {
77
      await context1.close();
78
      await context2.close();
79
    }
80
  });
81
});
82

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.