feat: Add controls to IDP response JSON

Controls are now used in templates to prevent IDP URL hardcoding
This commit is contained in:
Joachim Van Herwegen
2021-08-25 14:49:57 +02:00
parent d68854a474
commit 32a182dde8
13 changed files with 80 additions and 58 deletions

View File

@@ -94,15 +94,14 @@ export class IdentityTestState {
return nextUrl;
}
public async parseLoginPage(url: string): Promise<{ register: string; login: string; forgotPassword: string }> {
public async parseLoginPage(url: string): Promise<{ register: string; forgotPassword: string }> {
const res = await this.fetchIdp(url);
expect(res.status).toBe(200);
const text = await res.text();
const register = this.extractUrl(text, 'a:contains("Sign up")', 'href');
const login = this.extractUrl(text, 'form', 'action');
const forgotPassword = this.extractUrl(text, 'a:contains("Forgot password")', 'href');
return { register, login, forgotPassword };
return { register, forgotPassword };
}
/**
@@ -118,21 +117,6 @@ export class IdentityTestState {
return this.handleLoginRedirect(nextUrl);
}
/**
* Calls the given URL and extracts the action URL from a form contained within the resulting body.
* Also returns the resulting body in case further parsing is needed.
*/
public async extractFormUrl(url: string): Promise<{ url: string; body: string }> {
const res = await this.fetchIdp(url);
expect(res.status).toBe(200);
const text = await res.text();
const formUrl = this.extractUrl(text, 'form', 'action');
return {
url: new URL(formUrl, this.baseUrl).href,
body: text,
};
}
/**
* Handles the redirect that happens after logging in.
*/