Skip to content

Commit

Permalink
chore: remove auth functionality
Browse files Browse the repository at this point in the history
Signed-off-by: Husen <[email protected]>
  • Loading branch information
heyhusen committed Nov 19, 2023
1 parent 5c55d22 commit a5c4e19
Show file tree
Hide file tree
Showing 40 changed files with 20 additions and 2,338 deletions.
46 changes: 4 additions & 42 deletions node/__tests__/app.test.ts
Original file line number Diff line number Diff line change
@@ -1,55 +1,17 @@
import { afterAll, beforeAll, describe, expect, test } from 'vitest';
import type {
BearerTokenError,
JsonApiError,
} from '../src/adapters/interfaces/http.interface';
import { logIn, request } from './setup';
import { afterAll, describe, expect, test } from 'vitest';
import type { JsonApiError } from '../src/adapters/interfaces/http.interface';
import { request } from './setup';
import { close } from './teardown';

let accessToken: string;

beforeAll(async () => {
const { accessToken: access } = await logIn();

accessToken = access;
});

afterAll(async () => {
await close();
});

describe('GET /', () => {
test('should return unauthorized error if authorization header missing', async () => {
const response = await request
.get('/')
.set('Accept', 'application/vnd.api+json');

expect(response.status).toEqual<number>(400);
expect(response.body).toEqual<BearerTokenError>({
error: 'invalid_request',
error_description:
'The request is missing a required authorization header.',
});
});

test('should return unauthorized error if token missing', async () => {
const response = await request
.get('/')
.set('Accept', 'application/vnd.api+json')
.auth('', { type: 'bearer' });

expect(response.status).toEqual<number>(401);
expect(response.body).toEqual<BearerTokenError>({
error: 'invalid_token',
error_description: 'The token is malformed.',
});
});

test('should return hello world', async () => {
const response = await request
.get('/')
.set('Accept', 'application/vnd.api+json')
.auth(accessToken, { type: 'bearer' });
.set('Accept', 'application/vnd.api+json');

expect(response.status).toEqual<number>(200);
expect(response.body).toEqual<string>('Hello world!');
Expand Down
Loading

0 comments on commit a5c4e19

Please sign in to comment.