Skip to content

Commit

Permalink
refactor: Rename BasePermissionsExtractor to MethodPermissionsExtractor
Browse files Browse the repository at this point in the history
  • Loading branch information
RubenVerborgh committed Sep 4, 2020
1 parent c808dfe commit ba8b357
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion config/presets/ldp/permissions-extractor.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"@type": "CompositeAsyncHandler",
"CompositeAsyncHandler:_handlers": [
{
"@type": "BasePermissionsExtractor"
"@type": "MethodPermissionsExtractor"
},
{
"@type": "SparqlPatchPermissionsExtractor"
Expand Down
2 changes: 1 addition & 1 deletion index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export * from './src/ldp/operations/ResponseDescription';
// LDP/Permissions
export * from './src/ldp/permissions/PermissionSet';
export * from './src/ldp/permissions/PermissionsExtractor';
export * from './src/ldp/permissions/BasePermissionsExtractor';
export * from './src/ldp/permissions/MethodPermissionsExtractor';
export * from './src/ldp/permissions/SparqlPatchPermissionsExtractor';

// LDP/Representation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { PermissionsExtractor } from './PermissionsExtractor';
* Generates permissions for the base set of methods that always require the same permissions.
* Specifically: GET, HEAD, POST, PUT and DELETE.
*/
export class BasePermissionsExtractor extends PermissionsExtractor {
export class MethodPermissionsExtractor extends PermissionsExtractor {
public async canHandle(input: Operation): Promise<void> {
if (!/^(?:HEAD|GET|POST|PUT|DELETE)$/u.test(input.method)) {
throw new UnsupportedHttpError(`Unsupported method: ${input.method}`);
Expand Down
6 changes: 3 additions & 3 deletions test/integration/AuthenticatedLdpHandler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { Operation } from '../../src/ldp/operations/Operation';
import { PatchOperationHandler } from '../../src/ldp/operations/PatchOperationHandler';
import { PostOperationHandler } from '../../src/ldp/operations/PostOperationHandler';
import { ResponseDescription } from '../../src/ldp/operations/ResponseDescription';
import { BasePermissionsExtractor } from '../../src/ldp/permissions/BasePermissionsExtractor';
import { MethodPermissionsExtractor } from '../../src/ldp/permissions/MethodPermissionsExtractor';
import { SparqlPatchPermissionsExtractor } from '../../src/ldp/permissions/SparqlPatchPermissionsExtractor';
import { Representation } from '../../src/ldp/representation/Representation';
import { HttpRequest } from '../../src/server/HttpRequest';
Expand All @@ -42,7 +42,7 @@ describe('An integrated AuthenticatedLdpHandler', (): void => {
});

const credentialsExtractor = new UnsecureWebIdExtractor();
const permissionsExtractor = new BasePermissionsExtractor();
const permissionsExtractor = new MethodPermissionsExtractor();
const authorizer = new AllowEverythingAuthorizer();

const store = new InMemoryResourceStore(new RuntimeConfig({ base: 'http://test.com/' }));
Expand Down Expand Up @@ -111,7 +111,7 @@ describe('An integrated AuthenticatedLdpHandler', (): void => {

const credentialsExtractor = new UnsecureWebIdExtractor();
const permissionsExtractor = new CompositeAsyncHandler([
new BasePermissionsExtractor(),
new MethodPermissionsExtractor(),
new SparqlPatchPermissionsExtractor(),
]);
const authorizer = new AllowEverythingAuthorizer();
Expand Down
4 changes: 2 additions & 2 deletions test/integration/Authorization.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { Operation } from '../../src/ldp/operations/Operation';
import { PostOperationHandler } from '../../src/ldp/operations/PostOperationHandler';
import { PutOperationHandler } from '../../src/ldp/operations/PutOperationHandler';
import { ResponseDescription } from '../../src/ldp/operations/ResponseDescription';
import { BasePermissionsExtractor } from '../../src/ldp/permissions/BasePermissionsExtractor';
import { MethodPermissionsExtractor } from '../../src/ldp/permissions/MethodPermissionsExtractor';
import { PermissionSet } from '../../src/ldp/permissions/PermissionSet';
import { QuadToTurtleConverter } from '../../src/storage/conversion/QuadToTurtleConverter';
import { TurtleToQuadConverter } from '../../src/storage/conversion/TurtleToQuadConverter';
Expand Down Expand Up @@ -88,7 +88,7 @@ describe('A server with authorization', (): void => {
const convertingStore = new RepresentationConvertingStore(store, converter);

const credentialsExtractor = new UnsecureWebIdExtractor();
const permissionsExtractor = new BasePermissionsExtractor();
const permissionsExtractor = new MethodPermissionsExtractor();
const authorizer = new WebAclAuthorizer(
new UrlBasedAclManager(),
new UrlContainerManager(new RuntimeConfig({ base: 'http://test.com/' })),
Expand Down
6 changes: 3 additions & 3 deletions test/unit/ldp/permissions/BasePermissionsExtractor.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Operation } from '../../../../src/ldp/operations/Operation';
import { BasePermissionsExtractor } from '../../../../src/ldp/permissions/BasePermissionsExtractor';
import { MethodPermissionsExtractor } from '../../../../src/ldp/permissions/MethodPermissionsExtractor';
import { UnsupportedHttpError } from '../../../../src/util/errors/UnsupportedHttpError';

describe('A BasePermissionsExtractor', (): void => {
const extractor = new BasePermissionsExtractor();
describe('A MethodPermissionsExtractor', (): void => {
const extractor = new MethodPermissionsExtractor();

it('can handle HEAD/GET/POST/PUT/DELETE.', async(): Promise<void> => {
await expect(extractor.canHandle({ method: 'HEAD' } as Operation)).resolves.toBeUndefined();
Expand Down

0 comments on commit ba8b357

Please sign in to comment.