Skip to content

Commit

Permalink
refactor: apply feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
jannyHou committed Aug 14, 2019
1 parent 492a4ba commit 594a743
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
AUTHENTICATED,
authorize,
EVERYONE,
getAuthorizeMetadata,
getAuthorizationMetadata,
UNAUTHENTICATED,
} from '../..';

Expand All @@ -23,13 +23,13 @@ describe('Authentication', () => {
update() {}
}

let metaData = getAuthorizeMetadata(TestClass, 'getSecret');
let metaData = getAuthorizationMetadata(TestClass, 'getSecret');
expect(metaData).to.eql({
allowedRoles: ['ADMIN'],
scopes: ['secret.read'],
});

metaData = getAuthorizeMetadata(TestClass, 'update');
metaData = getAuthorizationMetadata(TestClass, 'update');
expect(metaData).to.eql({
allowedRoles: ['OWNER'],
scopes: ['data.update'],
Expand All @@ -45,13 +45,13 @@ describe('Authentication', () => {
update() {}
}

let metaData = getAuthorizeMetadata(TestClass, 'getSecret');
let metaData = getAuthorizationMetadata(TestClass, 'getSecret');
expect(metaData).to.eql({
allowedRoles: ['ADMIN'],
scopes: ['secret.read'],
});

metaData = getAuthorizeMetadata(TestClass, 'update');
metaData = getAuthorizationMetadata(TestClass, 'update');
expect(metaData).to.eql({
allowedRoles: ['OWNER'],
scopes: ['data.update'],
Expand All @@ -68,13 +68,13 @@ describe('Authentication', () => {
update() {}
}

let metaData = getAuthorizeMetadata(TestClass, 'getSecret');
let metaData = getAuthorizationMetadata(TestClass, 'getSecret');
expect(metaData).to.eql({
allowedRoles: ['ADMIN'],
scopes: ['secret.read'],
});

metaData = getAuthorizeMetadata(TestClass, 'update');
metaData = getAuthorizationMetadata(TestClass, 'update');
expect(metaData).to.eql({
allowedRoles: ['OWNER'],
scopes: ['data.update'],
Expand All @@ -87,7 +87,7 @@ describe('Authentication', () => {
getSecret() {}
}

const metaData = getAuthorizeMetadata(TestClass, 'getSecret');
const metaData = getAuthorizationMetadata(TestClass, 'getSecret');
expect(metaData).to.eql({
allowedRoles: [EVERYONE],
});
Expand All @@ -99,7 +99,7 @@ describe('Authentication', () => {
getSecret() {}
}

const metaData = getAuthorizeMetadata(TestClass, 'getSecret');
const metaData = getAuthorizationMetadata(TestClass, 'getSecret');
expect(metaData).to.eql({
allowedRoles: [EVERYONE],
deniedRoles: ['xyz'],
Expand All @@ -112,7 +112,7 @@ describe('Authentication', () => {
getSecret() {}
}

const metaData = getAuthorizeMetadata(TestClass, 'getSecret');
const metaData = getAuthorizationMetadata(TestClass, 'getSecret');
expect(metaData).to.eql({
deniedRoles: [EVERYONE],
});
Expand All @@ -124,7 +124,7 @@ describe('Authentication', () => {
getSecret() {}
}

const metaData = getAuthorizeMetadata(TestClass, 'getSecret');
const metaData = getAuthorizationMetadata(TestClass, 'getSecret');
expect(metaData).to.eql({
allowedRoles: ['xyz'],
deniedRoles: [EVERYONE],
Expand All @@ -137,7 +137,7 @@ describe('Authentication', () => {
getSecret() {}
}

const metaData = getAuthorizeMetadata(TestClass, 'getSecret');
const metaData = getAuthorizationMetadata(TestClass, 'getSecret');
expect(metaData).to.eql({
allowedRoles: [AUTHENTICATED],
});
Expand All @@ -149,7 +149,7 @@ describe('Authentication', () => {
getSecret() {}
}

const metaData = getAuthorizeMetadata(TestClass, 'getSecret');
const metaData = getAuthorizationMetadata(TestClass, 'getSecret');
expect(metaData).to.eql({
deniedRoles: [UNAUTHENTICATED],
});
Expand All @@ -168,7 +168,7 @@ describe('Authentication', () => {
getSecret() {}
}

const metaData = getAuthorizeMetadata(TestClass, 'getSecret');
const metaData = getAuthorizationMetadata(TestClass, 'getSecret');
expect(metaData).to.deepEqual({
voters: ['v1', 'v2'],
allowedRoles: ['a1', 'a3', 'a2'],
Expand Down
4 changes: 2 additions & 2 deletions packages/authorization/src/authorize-interceptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
Provider,
} from '@loopback/context';
import * as debugFactory from 'debug';
import {getAuthorizeMetadata} from './decorators/authorize';
import {getAuthorizationMetadata} from './decorators/authorize';
import {AuthorizationTags} from './keys';
import {
AuthorizationContext,
Expand All @@ -42,7 +42,7 @@ export class AuthorizationInterceptor implements Provider<Interceptor> {

async intercept(invocationCtx: InvocationContext, next: Next) {
const description = debug.enabled ? invocationCtx.description : '';
const metadata = getAuthorizeMetadata(
const metadata = getAuthorizationMetadata(
invocationCtx.target,
invocationCtx.methodName,
);
Expand Down
2 changes: 1 addition & 1 deletion packages/authorization/src/decorators/authorize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ export namespace authorize {
* @param target Target object/class
* @param methodName Target method
*/
export function getAuthorizeMetadata(
export function getAuthorizationMetadata(
target: object,
methodName: string,
): AuthorizationMetadata | undefined {
Expand Down

0 comments on commit 594a743

Please sign in to comment.