Esempio n. 1
0
def test_service_account_lifecycle(async_server, browser):  # noqa: F811
    browser.get(url(async_server, "/groups/user-admins"))

    page = GroupViewPage(browser)
    page.click_add_service_account_button()

    page = ServiceAccountCreatePage(browser)
    page.set_name("my-special-service-account")
    page.submit()

    page = ServiceAccountViewPage(browser)
    page.click_disable_button()

    disable_modal = page.get_disable_modal()
    disable_modal.confirm()

    browser.get(url(async_server, "/users"))

    page = UsersViewPage(browser)
    page.click_show_disabled_users_button()
    page.click_show_service_accounts_button()

    user_row = page.find_user_row(
        "[email protected] (service)")
    user_row.click()

    page = ServiceAccountViewPage(browser)
    page.click_enable_button()

    page = ServiceAccountEnablePage(browser)
    page.select_owner("Group: user-admins")
    page.submit()
Esempio n. 2
0
def test_service_account_lifecycle(async_server, browser):  # noqa: F811
    browser.get(url(async_server, "/groups/user-admins"))

    page = GroupViewPage(browser)
    page.click_add_service_account_button()

    page = ServiceAccountCreatePage(browser)
    page.set_name("my-special-service-account")
    page.submit()

    page = ServiceAccountViewPage(browser)
    page.click_disable_button()

    disable_modal = page.get_disable_modal()
    disable_modal.confirm()

    browser.get(url(async_server, "/users"))

    page = UsersViewPage(browser)
    page.click_show_disabled_users_button()
    page.click_show_service_accounts_button()

    user_row = page.find_user_row("[email protected] (service)")
    user_row.click()

    page = ServiceAccountViewPage(browser)
    page.click_enable_button()

    page = ServiceAccountEnablePage(browser)
    page.select_owner("Group: user-admins")
    page.submit()
Esempio n. 3
0
def test_service_account_lifecycle(tmpdir: LocalPath, setup: SetupTest,
                                   browser: Chrome) -> None:
    with setup.transaction():
        setup.add_user_to_group("*****@*****.**", "user-admins")
        setup.add_user_to_group("*****@*****.**", "some-group")
        setup.grant_permission_to_group(USER_ADMIN, "", "user-admins")

    with frontend_server(tmpdir, "*****@*****.**") as frontend_url:
        browser.get(url(frontend_url, "/groups/user-admins"))

        group_page = GroupViewPage(browser)
        group_page.click_add_service_account_button()

        # Test with an invalid machine set.
        create_page = ServiceAccountCreatePage(browser)
        create_page.set_name("my-special-service-account")
        create_page.set_description("some description")
        create_page.set_machine_set("some machines bad-machine")
        create_page.submit()
        assert create_page.has_alert("machine_set")
        expected = "[email protected] has invalid machine set"
        assert create_page.has_alert(expected)

        # Fix the machine set but test with an invalid name.
        create_page.set_name("service@service@service")
        create_page.set_machine_set("some machines")
        create_page.submit()
        assert create_page.has_alert("name")

        # Fix the name and then creation should succeed.
        create_page.set_name("my-special-service-account")
        create_page.submit()

        view_page = ServiceAccountViewPage(browser)
        assert view_page.owner == "user-admins"
        assert view_page.description == "some description"
        assert view_page.machine_set == "some machines"
        view_page.click_disable_button()
        disable_modal = view_page.get_disable_modal()
        disable_modal.confirm()

        browser.get(url(frontend_url, "/users"))

        users_page = UsersViewPage(browser)
        users_page.click_show_disabled_users_button()
        users_page.click_show_service_accounts_button()
        user_row = users_page.find_user_row(
            "[email protected] (service)")
        user_row.click()

        view_page = ServiceAccountViewPage(browser)
        view_page.click_enable_button()

        enable_page = ServiceAccountEnablePage(browser)
        enable_page.select_owner("Group: some-group")
        enable_page.submit()

        view_page = ServiceAccountViewPage(browser)
        assert view_page.owner == "some-group"