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:
parent
f01d2cc644
commit
741135a171
@ -369,6 +369,25 @@ describe('Error serialization special cases', () => {
|
|||||||
expect(json).toMatchObject({ path, type });
|
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`', () => {
|
it('NoAccessError: adds `permission`', () => {
|
||||||
const permission = 'x';
|
const permission = 'x';
|
||||||
const error = new NoAccessError(permission);
|
const error = new NoAccessError(permission);
|
||||||
|
@ -39,6 +39,7 @@ class AuthenticationRequired extends UnleashError {
|
|||||||
...super.toJSON(),
|
...super.toJSON(),
|
||||||
path: this.path,
|
path: this.path,
|
||||||
type: this.type,
|
type: this.type,
|
||||||
|
...(this.options ? { options: this.options } : {}),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user