Newer
Older
def do_login(page, username, password):
"""Logs into hiboo"""
page.get_by_label("Username").fill(username)
page.get_by_label("Password").fill(password)
page.get_by_role("button", name="Sign in").click()
def test_login(app, context, username, password):
"""Test that logs in as default test user"""
page = context.new_page()
page.goto(app)
do_login(page, username, password)
pw.expect(page.get_by_text("Sign out")).to_be_visible()
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
def test_saml_auth(app, context, username, password, service_name, httpd, httpd_saml, temp):
# First create a SAML service
page = context.new_page()
page.goto(app + "/service/create/saml")
do_login(page, username, password)
page.get_by_label("Service name").fill(service_name)
page.get_by_label("Provider").fill("test")
page.get_by_label("Description").fill("test")
page.get_by_label("Profile policy").select_option("open")
page.get_by_label("Maximum profile count").fill("10")
page.get_by_label("SP entity id").fill("http://localhost:8123/mellon/metadata")
page.get_by_label("SP ACS").fill("http://localhost:8123/mellon/postResponse")
page.get_by_role("button", name="submit").click()
# Then access the service and extract useful data
page.get_by_text(service_name).click()
httpd(httpd_saml.format(
metadata=temp(requests.get(page.get_by_label("SAML Metadata").text_content()).content),
key=temp(page.get_by_label("SP private key").text_content()),
cert=temp(page.get_by_label("SP certificate").text_content())
))
# Finally log into the service provider, validate a new profile and get in
page.goto("http://localhost:8123/")
page.get_by_role("button", name="Sign up").click()
pw.expect(page.get_by_text("Hello world")).to_be_visible()
def test_oidc_auth(app, context, username, password, service_name, httpd, httpd_oidc, temp):
# First create an OIDC service
page = context.new_page()
page.goto(app + "/service/create/oidc")
do_login(page, username, password)
page.get_by_label("Service name").fill(service_name)
page.get_by_label("Provider").fill("test")
page.get_by_label("Description").fill("test")
page.get_by_label("Profile policy").select_option("open")
page.get_by_label("Maximum profile count").fill("10")
page.get_by_label("Redirect URI").fill("http://localhost:8123/redirect_uri")
page.get_by_label("OpenID Connect grant type").select_option("authorization_code")
page.get_by_label("Allowed response types").select_option("code")
page.get_by_role("button", name="submit").click()
# Then access the service and extract useful data
page.get_by_text(service_name).click()
httpd(httpd_oidc.format(
metadata=page.get_by_label("OIDC discovery endpoint").text_content(),
client_id=page.get_by_label("Client ID").text_content(),
client_secret=page.get_by_label("Client secret").text_content()
))
# Finally log into the client app, validate a new profile and get in
page.goto("http://localhost:8123/")
page.get_by_role("button", name="Sign up").click()
pw.expect(page.get_by_text("Hello world")).to_be_visible()