resolve conflicts

This commit is contained in:
Kagami Sascha Rosylight
2023-04-07 10:06:07 +02:00
parent 179640af30
commit 2f566e4173
3 changed files with 21 additions and 6 deletions

View File

@@ -1,11 +1,12 @@
process.env.NODE_ENV = 'test';
import * as assert from 'assert';
import { port, signup, startServer } from '../utils.js';
import { port, relativeFetch, signup, startServer } from '../utils.js';
import type { INestApplicationContext } from '@nestjs/common';
import { AuthorizationCode } from 'simple-oauth2';
import pkceChallenge from 'pkce-challenge';
import { JSDOM } from 'jsdom';
import { api } from '../utils.js';
const clientPort = port + 1;
const redirect_uri = `http://127.0.0.1:${clientPort}/redirect`;
@@ -106,6 +107,19 @@ describe('OAuth', () => {
assert.strictEqual(typeof token.token.access_token, 'string');
assert.strictEqual(typeof token.token.refresh_token, 'string');
assert.strictEqual(token.token.token_type, 'Bearer');
const createResponse = await relativeFetch('api/notes/create', {
method: 'POST',
headers: {
Authorization: `Bearer ${token.token.access_token}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ text: 'test' }),
});
assert.strictEqual(createResponse.status, 200);
const createResponseBody: any = await createResponse.json();
assert.strictEqual(createResponseBody.createdNote.text, 'test');
});
test('Require PKCE', async () => {
@@ -171,4 +185,6 @@ describe('OAuth', () => {
// TODO: authorizing two users concurrently
// TODO: invalid redirect_uri (at authorize / at token)
// TODO: Wrong Authorization header (Not starts with Bearer / token is wrong)
});