grafana: fix tests to use API for checking user login (#725)
This commit is contained in:
parent
1b89d47651
commit
8871b9435b
1 changed files with 63 additions and 35 deletions
|
|
@ -97,19 +97,28 @@ let
|
||||||
"expect(page.get_by_text(re.compile('[Ii]ncorrect'))).to_be_visible(timeout=10000)"
|
"expect(page.get_by_text(re.compile('[Ii]ncorrect'))).to_be_visible(timeout=10000)"
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
# TODO: fix this. I tried a lot of stuff but can't figure out why it broke recently.
|
{
|
||||||
# For those reading this, it seems the call to Authelias's /userinfo endpoint returned a json response
|
username = "alice";
|
||||||
# with the value Editor in the field "grafana_groups". So I don't know what's wrong.
|
password = "AlicePassword";
|
||||||
# {
|
nextPageExpect = [
|
||||||
# username = "alice";
|
"page.get_by_role('button', name=re.compile('Accept')).click()"
|
||||||
# password = "AlicePassword";
|
"expect(page.get_by_text(re.compile('[Ii]ncorrect'))).not_to_be_visible(timeout=10000)"
|
||||||
# nextPageExpect = [
|
"expect(page.get_by_role('button', name=re.compile('Sign In'))).not_to_be_visible()"
|
||||||
# "page.get_by_role('button', name=re.compile('Accept')).click()"
|
''
|
||||||
# "expect(page.get_by_text(re.compile('[Ii]ncorrect'))).not_to_be_visible(timeout=10000)"
|
assert page.evaluate("""
|
||||||
# "expect(page.get_by_role('button', name=re.compile('Sign In'))).not_to_be_visible()"
|
async () => {
|
||||||
# "expect(page.get_by_text('Welcome to Grafana')).to_be_visible()"
|
const r = await fetch('/api/user');
|
||||||
# ];
|
if (!r.ok) return false;
|
||||||
# }
|
|
||||||
|
const u = await r.json();
|
||||||
|
return u.login === 'alice'
|
||||||
|
&& u.email === 'alice@example.com'
|
||||||
|
&& u.orgId === 1;
|
||||||
|
}
|
||||||
|
""")
|
||||||
|
''
|
||||||
|
];
|
||||||
|
}
|
||||||
{
|
{
|
||||||
username = "bob";
|
username = "bob";
|
||||||
password = "NotBobPassword";
|
password = "NotBobPassword";
|
||||||
|
|
@ -117,18 +126,28 @@ let
|
||||||
"expect(page.get_by_text(re.compile('[Ii]ncorrect'))).to_be_visible(timeout=10000)"
|
"expect(page.get_by_text(re.compile('[Ii]ncorrect'))).to_be_visible(timeout=10000)"
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
# TODO: fix this. I tried a lot of stuff but can't figure out why it broke recently.
|
{
|
||||||
# Same error as above.
|
username = "bob";
|
||||||
# {
|
password = "BobPassword";
|
||||||
# username = "bob";
|
nextPageExpect = [
|
||||||
# password = "BobPassword";
|
"page.get_by_role('button', name=re.compile('Accept')).click()"
|
||||||
# nextPageExpect = [
|
"expect(page.get_by_text(re.compile('[Ii]ncorrect'))).not_to_be_visible(timeout=10000)"
|
||||||
# "page.get_by_role('button', name=re.compile('Accept')).click()"
|
"expect(page.get_by_role('button', name=re.compile('Sign In'))).not_to_be_visible()"
|
||||||
# "expect(page.get_by_text(re.compile('[Ii]ncorrect'))).not_to_be_visible(timeout=10000)"
|
''
|
||||||
# "expect(page.get_by_role('button', name=re.compile('Sign In'))).not_to_be_visible()"
|
assert page.evaluate("""
|
||||||
# "expect(page.get_by_text('Welcome to Grafana')).to_be_visible()"
|
async () => {
|
||||||
# ];
|
const r = await fetch('/api/user');
|
||||||
# }
|
if (!r.ok) return false;
|
||||||
|
|
||||||
|
const u = await r.json();
|
||||||
|
return u.login === 'bob'
|
||||||
|
&& u.email === 'bob@example.com'
|
||||||
|
&& u.orgId === 1;
|
||||||
|
}
|
||||||
|
""")
|
||||||
|
''
|
||||||
|
];
|
||||||
|
}
|
||||||
{
|
{
|
||||||
username = "charlie";
|
username = "charlie";
|
||||||
password = "NotCharliePassword";
|
password = "NotCharliePassword";
|
||||||
|
|
@ -136,16 +155,25 @@ let
|
||||||
"expect(page.get_by_text(re.compile('[Ii]ncorrect'))).to_be_visible(timeout=10000)"
|
"expect(page.get_by_text(re.compile('[Ii]ncorrect'))).to_be_visible(timeout=10000)"
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
# TODO: fix this. This fails with:
|
{
|
||||||
# "If you're seeing this Grafana has failed to load its application files"
|
username = "charlie";
|
||||||
# {
|
password = "CharliePassword";
|
||||||
# username = "charlie";
|
nextPageExpect = [
|
||||||
# password = "CharliePassword";
|
"page.get_by_role('button', name=re.compile('Accept')).click()"
|
||||||
# nextPageExpect = [
|
"expect(page).to_have_url('https://${config.test.fqdn}/login', timeout=10000)"
|
||||||
# "page.get_by_role('button', name=re.compile('Accept')).click()" # I don't understand why this is not needed. Maybe it keeps somewhere the previous token?
|
''
|
||||||
# "expect(page.get_by_text(re.compile('[Ll]ogin failed'))).to_be_visible(timeout=10000)"
|
assert page.evaluate("""
|
||||||
# ];
|
async () => {
|
||||||
# }
|
const r = await fetch('/api/user');
|
||||||
|
if (r.status !== 401) return false;
|
||||||
|
|
||||||
|
const u = await r.json();
|
||||||
|
return u.message === 'Unauthorized';
|
||||||
|
}
|
||||||
|
""")
|
||||||
|
''
|
||||||
|
];
|
||||||
|
}
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue