def test_show_group_hides_aliased_permissions(async_server, browser): # noqa: F811 fe_url = url(async_server, "/groups/sad-team") browser.get(fe_url) page = GroupViewPage(browser) assert len(page.find_permission_rows("owner", "sad-team")) == 1 assert page.find_permission_rows("ssh", "owner=sad-team") == [] assert page.find_permission_rows("sudo", "sad-team") == []
def test_remove_last_owner_via_audit(async_server, browser, users, groups, session): # noqa: F811 future = datetime.utcnow() + timedelta(1) add_member(groups["auditors"], users["*****@*****.**"], role="owner") add_member(groups["audited-team"], users["*****@*****.**"], role="owner", expiration=future) session.commit() fe_url = url(async_server, "/audits/create") browser.get(fe_url) page = AuditsCreatePage(browser) page.set_end_date(future.strftime("%m/%d/%Y")) page.submit() fe_url = url(async_server, "/groups/audited-team") browser.get(fe_url) page = GroupViewPage(browser) audit_modal = page.get_audit_modal() audit_modal.find_member_row("*****@*****.**").set_audit_status("remove") audit_modal.confirm() assert page.current_url.endswith("/groups/audited-team") assert page.has_text(group_ownership_policy.EXCEPTION_MESSAGE)
def test_expire_last_owner(async_server, browser): # noqa: F811 fe_url = url(async_server, "/groups/sad-team") browser.get(fe_url) page = GroupViewPage(browser) row = page.find_member_row("*****@*****.**") row.click_edit_button() page = GroupEditMemberPage(browser) page.set_expiration("12/31/2999") page.set_reason("Unit Testing") page.submit() assert page.current_url.endswith("/groups/sad-team/edit/user/[email protected]") assert page.has_text(group_ownership_policy.EXCEPTION_MESSAGE)
def test_remove_member(async_server, browser): # noqa: F811 fe_url = url(async_server, "/groups/team-sre") browser.get(fe_url) page = GroupViewPage(browser) row = page.find_member_row("*****@*****.**") assert row.role == "member" row.click_remove_button() modal = page.get_remove_user_modal() modal.confirm() assert page.current_url.endswith("/groups/team-sre?refresh=yes") with pytest.raises(NoSuchElementException): assert page.find_member_row("*****@*****.**")
def test_show_group(async_server, browser, groups): # noqa: F811 group = groups["team-sre"] fe_url = url(async_server, "/groups/{}".format(group.name)) browser.get(fe_url) page = GroupViewPage(browser) members = group.my_members() for [_, username], _ in members.iteritems(): row = page.find_member_row(username) assert row.href.endswith("/users/{}".format(username)) for permission in group.my_permissions(): rows = page.find_permission_rows(permission.name) assert len(rows) == 1 assert rows[0].argument == permission.argument assert rows[0].href.endswith("/permissions/{}".format(permission.name))
def test_remove_last_owner(async_server, browser): # noqa: F811 fe_url = url(async_server, "/groups/team-sre") browser.get(fe_url) page = GroupViewPage(browser) row = page.find_member_row("*****@*****.**") assert row.role == "owner" row.click_remove_button() modal = page.get_remove_user_modal() modal.confirm() row = page.find_member_row("*****@*****.**") assert row.role == "owner" assert page.has_text(group_ownership_policy.EXCEPTION_MESSAGE)
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()
def test_service_account_lifecycle(async_server, browser): # noqa: F811 browser.get(url(async_server, "/groups/team-sre")) 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: team-sre") page.submit()