permission-node rename createIsAuthorized to createConditionAuthorizer
Signed-off-by: Vincenzo Scamporlino <vincenzos@spotify.com>
This commit is contained in:
@@ -25,7 +25,7 @@ import { z } from 'zod';
|
||||
import {
|
||||
createPermissionIntegrationRouter,
|
||||
CreatePermissionIntegrationRouterResourceOptions,
|
||||
createIsAuthorized,
|
||||
createConditionAuthorizer,
|
||||
} from './createPermissionIntegrationRouter';
|
||||
import { createPermissionRule } from './createPermissionRule';
|
||||
|
||||
@@ -633,13 +633,13 @@ describe('createPermissionIntegrationRouter', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('createIsAuthorized', () => {
|
||||
describe('createConditionAuthorizer', () => {
|
||||
afterEach(() => {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
it('should return true in case of allowed decision', () => {
|
||||
const isAuthorized = createIsAuthorized([testRule1, testRule2]);
|
||||
const isAuthorized = createConditionAuthorizer([testRule1, testRule2]);
|
||||
expect(
|
||||
isAuthorized(
|
||||
{
|
||||
@@ -653,7 +653,7 @@ describe('createIsAuthorized', () => {
|
||||
expect(mockTestRule2Apply).not.toHaveBeenCalled();
|
||||
});
|
||||
it('should return false in case of denied decision', () => {
|
||||
const isAuthorized = createIsAuthorized([testRule1, testRule2]);
|
||||
const isAuthorized = createConditionAuthorizer([testRule1, testRule2]);
|
||||
expect(
|
||||
isAuthorized(
|
||||
{
|
||||
@@ -668,7 +668,7 @@ describe('createIsAuthorized', () => {
|
||||
});
|
||||
|
||||
it('should apply conditions to a resource in case of conditional decision', () => {
|
||||
const isAuthorized = createIsAuthorized([testRule1, testRule2]);
|
||||
const isAuthorized = createConditionAuthorizer([testRule1, testRule2]);
|
||||
expect(
|
||||
isAuthorized(
|
||||
{
|
||||
|
||||
@@ -168,7 +168,7 @@ const applyConditions = <TResourceType extends string, TResource>(
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export const createIsAuthorized = <TResource, TQuery>(
|
||||
export const createConditionAuthorizer = <TResource, TQuery>(
|
||||
rules: PermissionRule<TResource, TQuery, string>[],
|
||||
) => {
|
||||
const getRule = createGetRule(rules);
|
||||
|
||||
Reference in New Issue
Block a user