1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-03-04 00:18:40 +01:00

fix: add missing options parameter back in (#3770)

This PR adds the missing serialization of the AuthenticationRequired
response back in. It was mistakenly removed in #3633.

This PR also adds another test to verify that it the options property is
present.
This commit is contained in:
Thomas Heartman 2023-05-15 09:19:55 +02:00 committed by GitHub
parent f01d2cc644
commit 741135a171
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 0 deletions

View File

@ -369,6 +369,25 @@ describe('Error serialization special cases', () => {
expect(json).toMatchObject({ path, type });
});
it('AuthenticationRequired adds `options` if they are present', () => {
const config = {
type: 'password',
path: `base-path/auth/simple/login`,
message: 'You must sign in order to use Unleash',
options: [
{
type: 'google',
message: 'Sign in with Google',
path: `base-path/auth/google/login`,
},
],
};
const json = new AuthenticationRequired(config).toJSON();
expect(json).toMatchObject(config);
});
it('NoAccessError: adds `permission`', () => {
const permission = 'x';
const error = new NoAccessError(permission);

View File

@ -39,6 +39,7 @@ class AuthenticationRequired extends UnleashError {
...super.toJSON(),
path: this.path,
type: this.type,
...(this.options ? { options: this.options } : {}),
};
}
}