Skip to content

Commit

Permalink
fix: add missing options parameter back in (#3770)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
thomasheartman committed May 15, 2023
1 parent f01d2cc commit 741135a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/lib/error/unleash-error.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/lib/types/authentication-required.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class AuthenticationRequired extends UnleashError {
...super.toJSON(),
path: this.path,
type: this.type,
...(this.options ? { options: this.options } : {}),
};
}
}
Expand Down

0 comments on commit 741135a

Please sign in to comment.