mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
feat: Add controls to IDP response JSON
Controls are now used in templates to prevent IDP URL hardcoding
This commit is contained in:
@@ -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.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user