mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
docs: Make registration form self-explanatory.
This commit is contained in:
committed by
Joachim Van Herwegen
parent
e99f670252
commit
969bb0ee6c
@@ -117,8 +117,8 @@ describe('A Solid server with IDP', (): void => {
|
||||
const res = await postForm(`${baseUrl}idp/register`, formBody);
|
||||
expect(res.status).toBe(200);
|
||||
const text = await res.text();
|
||||
expect(text).toMatch(new RegExp(`your WebID.*${webId}`, 'u'));
|
||||
expect(text).toMatch(new RegExp(`your email address.*${email}`, 'u'));
|
||||
expect(text).toMatch(new RegExp(`your.WebID.*${webId}`, 'u'));
|
||||
expect(text).toMatch(new RegExp(`your.email.address.*${email}`, 'u'));
|
||||
expect(text).toMatch(new RegExp(`<code><${webId}> <http://www.w3.org/ns/solid/terms#oidcIssuer> <${baseUrl}>\\.</code>`, 'mu'));
|
||||
});
|
||||
});
|
||||
@@ -280,7 +280,7 @@ describe('A Solid server with IDP', (): void => {
|
||||
const res = await postForm(`${baseUrl}idp/register`, formBody);
|
||||
expect(res.status).toBe(200);
|
||||
const text = await res.text();
|
||||
expect(text).toMatch(new RegExp(`Your new pod.*${baseUrl}${podName}/`, 'u'));
|
||||
expect(text).toMatch(new RegExp(`Your new Pod.*${baseUrl}${podName}/`, 'u'));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -305,7 +305,7 @@ describe('A Solid server with IDP', (): void => {
|
||||
newWebId = matchWebId![1];
|
||||
expect(text).toMatch(new RegExp(`new WebID is.*${newWebId}`, 'u'));
|
||||
expect(text).toMatch(new RegExp(`your email address.*${newMail}`, 'u'));
|
||||
expect(text).toMatch(new RegExp(`Your new pod.*${baseUrl}${podName}/`, 'u'));
|
||||
expect(text).toMatch(new RegExp(`Your new Pod.*${baseUrl}${podName}/`, 'u'));
|
||||
});
|
||||
|
||||
it('initializes the session and logs in.', async(): Promise<void> => {
|
||||
|
||||
@@ -53,12 +53,11 @@ describe('EmailPasswordUtil', (): void => {
|
||||
|
||||
describe('#assertPassword', (): void => {
|
||||
it('validates the password against the confirmPassword.', async(): Promise<void> => {
|
||||
expect((): void => assertPassword(undefined, undefined)).toThrow('Password required');
|
||||
expect((): void => assertPassword([], undefined)).toThrow('Password required');
|
||||
expect((): void => assertPassword('password', undefined)).toThrow('Password confirmation required');
|
||||
expect((): void => assertPassword('password', [])).toThrow('Password confirmation required');
|
||||
expect((): void => assertPassword('password', 'confirmPassword'))
|
||||
.toThrow('Password and confirmation do not match');
|
||||
expect((): void => assertPassword(undefined, undefined)).toThrow('Please enter a password.');
|
||||
expect((): void => assertPassword([], undefined)).toThrow('Please enter a password.');
|
||||
expect((): void => assertPassword('password', undefined)).toThrow('Please confirm your password.');
|
||||
expect((): void => assertPassword('password', [])).toThrow('Please confirm your password.');
|
||||
expect((): void => assertPassword('password', 'other')).toThrow('Your password and confirmation did not match');
|
||||
expect(assertPassword('password', 'password')).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -78,81 +78,73 @@ describe('A RegistrationHandler', (): void => {
|
||||
|
||||
describe('validating data', (): void => {
|
||||
it('rejects array inputs.', async(): Promise<void> => {
|
||||
request = createPostFormRequest({ data: [ 'a', 'b' ]});
|
||||
await expect(handler.handle({ request, response })).rejects.toThrow('Multiple values found for key data');
|
||||
request = createPostFormRequest({ mydata: [ 'a', 'b' ]});
|
||||
await expect(handler.handle({ request, response }))
|
||||
.rejects.toThrow('Unexpected multiple values for mydata.');
|
||||
});
|
||||
|
||||
it('errors on invalid emails.', async(): Promise<void> => {
|
||||
request = createPostFormRequest({ email: undefined });
|
||||
await expect(handler.handle({ request, response })).rejects.toThrow('A valid e-mail address is required');
|
||||
await expect(handler.handle({ request, response }))
|
||||
.rejects.toThrow('Please enter a valid e-mail address.');
|
||||
|
||||
request = createPostFormRequest({ email: '' });
|
||||
await expect(handler.handle({ request, response })).rejects.toThrow('A valid e-mail address is required');
|
||||
await expect(handler.handle({ request, response }))
|
||||
.rejects.toThrow('Please enter a valid e-mail address.');
|
||||
|
||||
request = createPostFormRequest({ email: 'invalidEmail' });
|
||||
await expect(handler.handle({ request, response })).rejects.toThrow('A valid e-mail address is required');
|
||||
});
|
||||
|
||||
it('errors when an unnecessary WebID is provided.', async(): Promise<void> => {
|
||||
request = createPostFormRequest({ email, webId, createWebId });
|
||||
await expect(handler.handle({ request, response }))
|
||||
.rejects.toThrow('A WebID should only be provided when no new one is being created');
|
||||
.rejects.toThrow('Please enter a valid e-mail address.');
|
||||
});
|
||||
|
||||
it('errors when a required WebID is not valid.', async(): Promise<void> => {
|
||||
request = createPostFormRequest({ email, webId: undefined });
|
||||
request = createPostFormRequest({ email, register, webId: undefined });
|
||||
await expect(handler.handle({ request, response }))
|
||||
.rejects.toThrow('A WebID is required if no new one is being created');
|
||||
.rejects.toThrow('Please enter a valid WebID.');
|
||||
|
||||
request = createPostFormRequest({ email, webId: '' });
|
||||
request = createPostFormRequest({ email, register, webId: '' });
|
||||
await expect(handler.handle({ request, response }))
|
||||
.rejects.toThrow('A WebID is required if no new one is being created');
|
||||
});
|
||||
|
||||
it('errors when an unnecessary password is provided.', async(): Promise<void> => {
|
||||
request = createPostFormRequest({ email, webId, password });
|
||||
await expect(handler.handle({ request, response }))
|
||||
.rejects.toThrow('A password should only be provided when registering');
|
||||
.rejects.toThrow('Please enter a valid WebID.');
|
||||
});
|
||||
|
||||
it('errors on invalid passwords when registering.', async(): Promise<void> => {
|
||||
request = createPostFormRequest({ email, webId, password, confirmPassword: 'bad', register });
|
||||
await expect(handler.handle({ request, response })).rejects.toThrow('Password and confirmation do not match');
|
||||
});
|
||||
|
||||
it('errors when an unnecessary pod name is provided.', async(): Promise<void> => {
|
||||
request = createPostFormRequest({ email, webId, podName });
|
||||
await expect(handler.handle({ request, response }))
|
||||
.rejects.toThrow('A pod name should only be provided when creating a pod and/or WebID');
|
||||
.rejects.toThrow('Your password and confirmation did not match.');
|
||||
});
|
||||
|
||||
it('errors on invalid pod names when required.', async(): Promise<void> => {
|
||||
request = createPostFormRequest({ email, podName: undefined, createWebId });
|
||||
request = createPostFormRequest({ email, webId, createPod, podName: undefined });
|
||||
await expect(handler.handle({ request, response }))
|
||||
.rejects.toThrow('A pod name is required when creating a pod and/or WebID');
|
||||
.rejects.toThrow('Please specify a Pod name.');
|
||||
|
||||
request = createPostFormRequest({ email, webId, podName: '', createPod });
|
||||
request = createPostFormRequest({ email, webId, createPod, podName: ' ' });
|
||||
await expect(handler.handle({ request, response }))
|
||||
.rejects.toThrow('A pod name is required when creating a pod and/or WebID');
|
||||
.rejects.toThrow('Please specify a Pod name.');
|
||||
|
||||
request = createPostFormRequest({ email, webId, createWebId });
|
||||
await expect(handler.handle({ request, response }))
|
||||
.rejects.toThrow('Please specify a Pod name.');
|
||||
});
|
||||
|
||||
it('errors when trying to create a WebID without registering or creating a pod.', async(): Promise<void> => {
|
||||
request = createPostFormRequest({ email, podName, createWebId });
|
||||
await expect(handler.handle({ request, response }))
|
||||
.rejects.toThrow('Creating a WebID is only possible when also registering and creating a pod');
|
||||
|
||||
request = createPostFormRequest({ email, podName, password, confirmPassword, createWebId, register });
|
||||
await expect(handler.handle({ request, response }))
|
||||
.rejects.toThrow('Creating a WebID is only possible when also registering and creating a pod');
|
||||
.rejects.toThrow('Please enter a password.');
|
||||
|
||||
request = createPostFormRequest({ email, podName, createWebId, createPod });
|
||||
await expect(handler.handle({ request, response }))
|
||||
.rejects.toThrow('Creating a WebID is only possible when also registering and creating a pod');
|
||||
.rejects.toThrow('Please enter a password.');
|
||||
|
||||
request = createPostFormRequest({ email, podName, createWebId, createPod, register });
|
||||
await expect(handler.handle({ request, response }))
|
||||
.rejects.toThrow('Please enter a password.');
|
||||
});
|
||||
|
||||
it('errors when no option is chosen.', async(): Promise<void> => {
|
||||
request = createPostFormRequest({ email, webId });
|
||||
await expect(handler.handle({ request, response })).rejects.toThrow('At least one option needs to be chosen');
|
||||
await expect(handler.handle({ request, response }))
|
||||
.rejects.toThrow('Please register for a WebID or create a Pod.');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ describe('A ResetPasswordHandler', (): void => {
|
||||
});
|
||||
|
||||
it('errors for invalid passwords.', async(): Promise<void> => {
|
||||
const errorMessage = 'Password and confirmation do not match';
|
||||
const errorMessage = 'Your password and confirmation did not match.';
|
||||
request = createPostFormRequest({ password: 'password!', confirmPassword: 'otherPassword!' }, url);
|
||||
await expect(handler.handle({ request, response })).rejects.toThrow(errorMessage);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user