mirror of
https://github.com/Kong/insomnia
synced 2024-11-08 14:49:53 +00:00
3f5e7e2e14
* Proof of concept authorize call * Authorize and Refresh endpoints done * OAuth2 editor started * Some small fixes * Set OAuth headers on request * Started on some OAuth tests * Updated network logic with new OAuth API * OAuth forms and refactor flows * Fix grant type handling * Moved auth handling out of render pipeline * Fixed legacy auth header * Fix vertical center * Prompt user on auth type change * Refresh tokens working (I think) and better UI * Catch same type auth change * POC refresh token and small refactor * Better token handling * LOading state to token refresh * Show o-auth-2 errors * Some minor updates
77 lines
2.2 KiB
JavaScript
77 lines
2.2 KiB
JavaScript
import * as harUtils from '../har';
|
|
import * as db from '../database';
|
|
import * as render from '../render';
|
|
import * as models from '../../models';
|
|
import {AUTH_BASIC} from '../constants';
|
|
|
|
describe('exportHarWithRequest()', () => {
|
|
beforeEach(() => db.init(models.types(), {inMemoryOnly: true}, true));
|
|
it('renders does it correctly', async () => {
|
|
const workspace = await models.workspace.create();
|
|
const cookies = [{
|
|
creation: new Date('2016-10-05T04:40:49.505Z'),
|
|
key: 'foo',
|
|
value: 'barrrrr',
|
|
expires: new Date('2096-10-12T04:40:49.000Z'),
|
|
domain: 'google.com',
|
|
path: '/',
|
|
hostOnly: true,
|
|
lastAccessed: new Date('2096-10-05T04:40:49.505Z')
|
|
}];
|
|
|
|
await models.cookieJar.create({
|
|
parentId: workspace._id,
|
|
cookies
|
|
});
|
|
|
|
const request = Object.assign(models.request.init(), {
|
|
_id: 'req_123',
|
|
parentId: workspace._id,
|
|
headers: [{name: 'Content-Type', value: 'application/json'}],
|
|
parameters: [{name: 'foo bar', value: 'hello&world'}],
|
|
method: 'POST',
|
|
body: {
|
|
text: 'foo bar'
|
|
},
|
|
url: 'http://google.com',
|
|
authentication: {
|
|
type: AUTH_BASIC,
|
|
username: 'user',
|
|
password: 'pass'
|
|
}
|
|
});
|
|
|
|
const renderedRequest = await render.getRenderedRequest(request);
|
|
const har = await harUtils.exportHarWithRequest(renderedRequest);
|
|
|
|
expect(har.cookies.length).toBe(1);
|
|
expect(har).toEqual({
|
|
bodySize: -1,
|
|
cookies: [{
|
|
creation: '2016-10-05T04:40:49.505Z',
|
|
domain: 'google.com',
|
|
expires: '2096-10-12T04:40:49.000Z',
|
|
hostOnly: true,
|
|
key: 'foo',
|
|
name: 'foo',
|
|
path: '/',
|
|
value: 'barrrrr',
|
|
// lastAccessed is updated, so lets hack the assertion
|
|
lastAccessed: har.cookies[0].lastAccessed
|
|
}],
|
|
headers: [
|
|
{name: 'Content-Type', value: 'application/json'},
|
|
{name: 'Authorization', value: 'Basic dXNlcjpwYXNz'}
|
|
],
|
|
headersSize: -1,
|
|
httpVersion: 'HTTP/1.1',
|
|
method: 'POST',
|
|
postData: {
|
|
text: 'foo bar'
|
|
},
|
|
queryString: [{name: 'foo bar', value: 'hello&world'}],
|
|
url: 'http://google.com/'
|
|
});
|
|
});
|
|
});
|