mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
refactor: Update eslint related dependencies
This commit is contained in:
@@ -1,13 +1,14 @@
|
||||
import { CredentialsExtractor } from '../../../src/authentication/CredentialsExtractor';
|
||||
import { Authorizer } from '../../../src/authorization/Authorizer';
|
||||
import { AuthenticatedLdpHandler, AuthenticatedLdpHandlerArgs } from '../../../src/ldp/AuthenticatedLdpHandler';
|
||||
import { RequestParser } from '../../../src/ldp/http/RequestParser';
|
||||
import { ResponseWriter } from '../../../src/ldp/http/ResponseWriter';
|
||||
import { Operation } from '../../../src/ldp/operations/Operation';
|
||||
import { OperationHandler } from '../../../src/ldp/operations/OperationHandler';
|
||||
import { PermissionsExtractor } from '../../../src/ldp/permissions/PermissionsExtractor';
|
||||
import { HttpRequest } from '../../../src/server/HttpRequest';
|
||||
import { HttpResponse } from '../../../src/server/HttpResponse';
|
||||
import type { CredentialsExtractor } from '../../../src/authentication/CredentialsExtractor';
|
||||
import type { Authorizer } from '../../../src/authorization/Authorizer';
|
||||
import type { AuthenticatedLdpHandlerArgs } from '../../../src/ldp/AuthenticatedLdpHandler';
|
||||
import { AuthenticatedLdpHandler } from '../../../src/ldp/AuthenticatedLdpHandler';
|
||||
import type { RequestParser } from '../../../src/ldp/http/RequestParser';
|
||||
import type { ResponseWriter } from '../../../src/ldp/http/ResponseWriter';
|
||||
import type { Operation } from '../../../src/ldp/operations/Operation';
|
||||
import type { OperationHandler } from '../../../src/ldp/operations/OperationHandler';
|
||||
import type { PermissionsExtractor } from '../../../src/ldp/permissions/PermissionsExtractor';
|
||||
import type { HttpRequest } from '../../../src/server/HttpRequest';
|
||||
import type { HttpResponse } from '../../../src/server/HttpResponse';
|
||||
import { StaticAsyncHandler } from '../../util/StaticAsyncHandler';
|
||||
|
||||
describe('An AuthenticatedLdpHandler', (): void => {
|
||||
@@ -67,4 +68,13 @@ describe('An AuthenticatedLdpHandler', (): void => {
|
||||
|
||||
await expect(handler.handle({ request: 'request' as any, response: {} as HttpResponse })).rejects.toThrow(Error);
|
||||
});
|
||||
|
||||
it('errors an invalid object was thrown by a handler.', async(): Promise< void> => {
|
||||
args.authorizer.handle = async(): Promise<void> => {
|
||||
throw 'apple';
|
||||
};
|
||||
const handler = new AuthenticatedLdpHandler(args);
|
||||
|
||||
await expect(handler.handle({ request: 'request' as any, response: {} as HttpResponse })).rejects.toEqual('apple');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { AcceptPreferenceParser } from '../../../../src/ldp/http/AcceptPreferenceParser';
|
||||
import { HttpRequest } from '../../../../src/server/HttpRequest';
|
||||
import type { HttpRequest } from '../../../../src/server/HttpRequest';
|
||||
|
||||
describe('An AcceptPreferenceParser', (): void => {
|
||||
const preferenceParser = new AcceptPreferenceParser();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { BasicRequestParser } from '../../../../src/ldp/http/BasicRequestParser';
|
||||
import { BodyParser } from '../../../../src/ldp/http/BodyParser';
|
||||
import { PreferenceParser } from '../../../../src/ldp/http/PreferenceParser';
|
||||
import { TargetExtractor } from '../../../../src/ldp/http/TargetExtractor';
|
||||
import type { BodyParser } from '../../../../src/ldp/http/BodyParser';
|
||||
import type { PreferenceParser } from '../../../../src/ldp/http/PreferenceParser';
|
||||
import type { TargetExtractor } from '../../../../src/ldp/http/TargetExtractor';
|
||||
import { StaticAsyncHandler } from '../../../util/StaticAsyncHandler';
|
||||
|
||||
describe('A BasicRequestParser', (): void => {
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import { EventEmitter } from 'events';
|
||||
import { createResponse, MockResponse } from 'node-mocks-http';
|
||||
import type { MockResponse } from 'node-mocks-http';
|
||||
import { createResponse } from 'node-mocks-http';
|
||||
import streamifyArray from 'streamify-array';
|
||||
import { BasicResponseWriter } from '../../../../src/ldp/http/BasicResponseWriter';
|
||||
import { ResponseDescription } from '../../../../src/ldp/operations/ResponseDescription';
|
||||
import type { ResponseDescription } from '../../../../src/ldp/operations/ResponseDescription';
|
||||
import { RepresentationMetadata } from '../../../../src/ldp/representation/RepresentationMetadata';
|
||||
import { UnsupportedHttpError } from '../../../../src/util/errors/UnsupportedHttpError';
|
||||
import { CONTENT_TYPE } from '../../../../src/util/UriConstants';
|
||||
|
||||
@@ -2,7 +2,7 @@ import arrayifyStream from 'arrayify-stream';
|
||||
import streamifyArray from 'streamify-array';
|
||||
import { RawBodyParser } from '../../../../src/ldp/http/RawBodyParser';
|
||||
import { RepresentationMetadata } from '../../../../src/ldp/representation/RepresentationMetadata';
|
||||
import { HttpRequest } from '../../../../src/server/HttpRequest';
|
||||
import type { HttpRequest } from '../../../../src/server/HttpRequest';
|
||||
import { UnsupportedHttpError } from '../../../../src/util/errors/UnsupportedHttpError';
|
||||
import 'jest-rdf';
|
||||
import { HTTP, RDF } from '../../../../src/util/UriConstants';
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import { namedNode, quad } from '@rdfjs/data-model';
|
||||
import arrayifyStream from 'arrayify-stream';
|
||||
import { Algebra } from 'sparqlalgebrajs';
|
||||
import * as algebra from 'sparqlalgebrajs';
|
||||
import streamifyArray from 'streamify-array';
|
||||
import { SparqlUpdateBodyParser } from '../../../../src/ldp/http/SparqlUpdateBodyParser';
|
||||
import { HttpRequest } from '../../../../src/server/HttpRequest';
|
||||
import type { HttpRequest } from '../../../../src/server/HttpRequest';
|
||||
import { UnsupportedHttpError } from '../../../../src/util/errors/UnsupportedHttpError';
|
||||
import { UnsupportedMediaTypeHttpError } from '../../../../src/util/errors/UnsupportedMediaTypeHttpError';
|
||||
|
||||
@@ -23,6 +24,16 @@ describe('A SparqlUpdateBodyParser', (): void => {
|
||||
.rejects.toThrow(UnsupportedHttpError);
|
||||
});
|
||||
|
||||
it('errors when receiving an unexpected error.', async(): Promise<void> => {
|
||||
const mock = jest.spyOn(algebra, 'translate').mockImplementationOnce((): any => {
|
||||
throw 'apple';
|
||||
});
|
||||
await expect(bodyParser.handle(streamifyArray(
|
||||
[ 'DELETE DATA { <http://test.com/s> <http://test.com/p> <http://test.com/o>}' ],
|
||||
) as HttpRequest)).rejects.toThrow(UnsupportedHttpError);
|
||||
mock.mockRestore();
|
||||
});
|
||||
|
||||
it('converts SPARQL updates to algebra.', async(): Promise<void> => {
|
||||
const result = await bodyParser.handle(streamifyArray(
|
||||
[ 'DELETE DATA { <http://test.com/s> <http://test.com/p> <http://test.com/o>}' ],
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { DeleteOperationHandler } from '../../../../src/ldp/operations/DeleteOperationHandler';
|
||||
import { Operation } from '../../../../src/ldp/operations/Operation';
|
||||
import { ResourceStore } from '../../../../src/storage/ResourceStore';
|
||||
import type { Operation } from '../../../../src/ldp/operations/Operation';
|
||||
import type { ResourceStore } from '../../../../src/storage/ResourceStore';
|
||||
import { UnsupportedHttpError } from '../../../../src/util/errors/UnsupportedHttpError';
|
||||
|
||||
describe('A DeleteOperationHandler', (): void => {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { GetOperationHandler } from '../../../../src/ldp/operations/GetOperationHandler';
|
||||
import { Operation } from '../../../../src/ldp/operations/Operation';
|
||||
import { Representation } from '../../../../src/ldp/representation/Representation';
|
||||
import { ResourceStore } from '../../../../src/storage/ResourceStore';
|
||||
import type { Operation } from '../../../../src/ldp/operations/Operation';
|
||||
import type { Representation } from '../../../../src/ldp/representation/Representation';
|
||||
import type { ResourceStore } from '../../../../src/storage/ResourceStore';
|
||||
import { UnsupportedHttpError } from '../../../../src/util/errors/UnsupportedHttpError';
|
||||
|
||||
describe('A GetOperationHandler', (): void => {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Operation } from '../../../../src/ldp/operations/Operation';
|
||||
import type { Operation } from '../../../../src/ldp/operations/Operation';
|
||||
import { PatchOperationHandler } from '../../../../src/ldp/operations/PatchOperationHandler';
|
||||
import { ResourceStore } from '../../../../src/storage/ResourceStore';
|
||||
import type { ResourceStore } from '../../../../src/storage/ResourceStore';
|
||||
import { UnsupportedHttpError } from '../../../../src/util/errors/UnsupportedHttpError';
|
||||
|
||||
describe('A PatchOperationHandler', (): void => {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Operation } from '../../../../src/ldp/operations/Operation';
|
||||
import type { Operation } from '../../../../src/ldp/operations/Operation';
|
||||
import { PostOperationHandler } from '../../../../src/ldp/operations/PostOperationHandler';
|
||||
import { ResourceIdentifier } from '../../../../src/ldp/representation/ResourceIdentifier';
|
||||
import { ResourceStore } from '../../../../src/storage/ResourceStore';
|
||||
import type { ResourceIdentifier } from '../../../../src/ldp/representation/ResourceIdentifier';
|
||||
import type { ResourceStore } from '../../../../src/storage/ResourceStore';
|
||||
import { UnsupportedHttpError } from '../../../../src/util/errors/UnsupportedHttpError';
|
||||
|
||||
describe('A PostOperationHandler', (): void => {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Operation } from '../../../../src/ldp/operations/Operation';
|
||||
import type { Operation } from '../../../../src/ldp/operations/Operation';
|
||||
import { PutOperationHandler } from '../../../../src/ldp/operations/PutOperationHandler';
|
||||
import { ResourceStore } from '../../../../src/storage/ResourceStore';
|
||||
import type { ResourceStore } from '../../../../src/storage/ResourceStore';
|
||||
import { UnsupportedHttpError } from '../../../../src/util/errors/UnsupportedHttpError';
|
||||
|
||||
describe('A PutOperationHandler', (): void => {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Operation } from '../../../../src/ldp/operations/Operation';
|
||||
import type { Operation } from '../../../../src/ldp/operations/Operation';
|
||||
import { MethodPermissionsExtractor } from '../../../../src/ldp/permissions/MethodPermissionsExtractor';
|
||||
import { UnsupportedHttpError } from '../../../../src/util/errors/UnsupportedHttpError';
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Factory } from 'sparqlalgebrajs';
|
||||
import { SparqlUpdatePatch } from '../../../../src/ldp/http/SparqlUpdatePatch';
|
||||
import { Operation } from '../../../../src/ldp/operations/Operation';
|
||||
import type { SparqlUpdatePatch } from '../../../../src/ldp/http/SparqlUpdatePatch';
|
||||
import type { Operation } from '../../../../src/ldp/operations/Operation';
|
||||
import { SparqlPatchPermissionsExtractor } from '../../../../src/ldp/permissions/SparqlPatchPermissionsExtractor';
|
||||
import { UnsupportedHttpError } from '../../../../src/util/errors/UnsupportedHttpError';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user