mirror of
https://github.com/ToolJet/ToolJet
synced 2026-04-21 21:47:17 +00:00
* working on replacing workspace id with workspace name * experimenting with zustand * added slug column to workspace table * working on workspace url * working on backward compatibility * fixing bugs * added not found error * fixed workspace switching issue * fix: switching b/w workspaces * fix: workspace login * changed workspace login url link * resolved conflicts * added create organization design * added backend validation * fixed constraint errors issue * fixed: creating new workspace * fixed: update workspace * fixed: update workspace bugs * fixed: auto created slug bugs * fixed: login slug * design changes * added folder slug * fixed: lint error * fixed: invite and first user issues * fixed: login page redirection * fixed: redirect path * added reserved word check * fix: edit workspace design * fix: folder query issue * fix: create and edit workspace modal validation issues * fixing failed test cases * fixing failed test cases - app.e2e * fixed organizations specs * fixed public app issue * working on app slug * Added app slug design to the general settings * Working on appId -> slug changes - Handling appId cases - Fixing issues * Worked on share modal design change - replaced slug functionality - Fixed backend slug issues - Fixed page handle issues * changed switch label * replace version param with query param * fix: possible uuid bug * fix: login app slug redirection issue * Worked on unique app slug * moved all apps related api calls to apps.service.js file * refactoring the code and fixing minor issues * Refactored and fixed some bugs * Fixed bugs: redirect cookie issue * Fixed dark-mode issues * removed duplicate code * Worked on develop branch conflicts * Moved handle app access check to private route * Added fix for navigate * Refactored the code. Added slug to failed sso login redirection path * again some redirect url fixes * onbaord navbar tj-icon onclick * Fix: viewer version id undefined issue * fix: multi-pages, invalid workspace slug * fix: removing the version search param while switching the pages * fix-sso: redirecting to prev tab's login organization slug * fix-sso: google signup * fix: preivew permission issue * Fixing merge issues * Fixed tjdb issues * dark mode fix of manage users button * fix: extra slash in url, tj-logo on click wrong org id * subpath workspace login url * resolved lint issue * fix: cannot clone apps * fixed switch workspace issue * fix: login page flashing issue * fix: back button issue * fix: private endless redirection * Update the modal with new UX * fixed all ui issues * fixed placeholder translation issues * fix: sso multi-request issues * fix: multi-pages crash while promoting a version * fix: error text msg delay * added default slug to the first workspace in the instance * subpath-fix: slug preview url * fix: same value check * fixed switch page query params issue * fix: folder query * fix: manage app users ui responsive issue * Backend PR changes --------- Co-authored-by: gsmithun4 <gsmithun4@gmail.com>
106 lines
3.1 KiB
TypeScript
106 lines
3.1 KiB
TypeScript
import { INestApplication } from '@nestjs/common';
|
|
import { clearDB, createUser, createNestAppInstance, logoutUser, authenticateUser } from '../test.helper';
|
|
import * as request from 'supertest';
|
|
|
|
describe('session & new apis', () => {
|
|
let app: INestApplication;
|
|
let tokenCookie: string;
|
|
let orgId: string;
|
|
beforeEach(async () => {
|
|
await clearDB();
|
|
const { organization } = await createUser(app, {
|
|
email: 'admin@tooljet.io',
|
|
firstName: 'user',
|
|
lastName: 'name',
|
|
});
|
|
orgId = organization.id;
|
|
const { tokenCookie: tokenCookieData } = await authenticateUser(app);
|
|
tokenCookie = tokenCookieData;
|
|
});
|
|
|
|
beforeAll(async () => {
|
|
app = await createNestAppInstance();
|
|
});
|
|
|
|
afterEach(async () => {
|
|
await logoutUser(app, tokenCookie, orgId);
|
|
});
|
|
|
|
it('Should return 403 if the auth token is invalid', async () => {
|
|
await request.agent(app.getHttpServer()).get('/api/authorize').set('tj-workspace-id', orgId).expect(403);
|
|
});
|
|
|
|
describe('GET /api/authorize', () => {
|
|
it("should return 401 if the organization-id isn't available in the auth token", async () => {
|
|
const response = await request(app.getHttpServer())
|
|
.post('/api/organizations')
|
|
.send({ name: 'My workspace', slug: 'slug' })
|
|
.set('Cookie', tokenCookie)
|
|
.set('tj-workspace-id', orgId);
|
|
|
|
await request
|
|
.agent(app.getHttpServer())
|
|
.get('/api/authorize')
|
|
.set('Cookie', tokenCookie)
|
|
.set('tj-workspace-id', response.body.current_organization_id)
|
|
.expect(401);
|
|
});
|
|
|
|
it('should return 404 if the user not in the specific organization', async () => {
|
|
const { organization } = await createUser(app, {
|
|
email: 'admin2@tooljet.io',
|
|
firstName: 'user',
|
|
lastName: 'name',
|
|
});
|
|
|
|
await request
|
|
.agent(app.getHttpServer())
|
|
.get('/api/authorize')
|
|
.set('Cookie', tokenCookie)
|
|
.set('tj-workspace-id', organization.id)
|
|
.expect(401);
|
|
});
|
|
|
|
it('should return the organization details if the auth token have the organization id', async () => {
|
|
await request(app.getHttpServer())
|
|
.get('/api/authorize')
|
|
.set('Cookie', tokenCookie)
|
|
.set('tj-workspace-id', orgId)
|
|
.expect(200);
|
|
});
|
|
});
|
|
|
|
describe('GET /api/profile', () => {
|
|
it('should return the user details', async () => {
|
|
await request(app.getHttpServer())
|
|
.get('/api/profile')
|
|
.set('Cookie', tokenCookie)
|
|
.set('tj-workspace-id', orgId)
|
|
.expect(200);
|
|
});
|
|
});
|
|
|
|
describe('GET /api/profile', () => {
|
|
it('should return the user details', async () => {
|
|
await request(app.getHttpServer())
|
|
.get('/api/profile')
|
|
.set('Cookie', tokenCookie)
|
|
.set('tj-workspace-id', orgId)
|
|
.expect(200);
|
|
});
|
|
});
|
|
|
|
describe('GET /api/session', () => {
|
|
it('should return the current user details', async () => {
|
|
await request(app.getHttpServer())
|
|
.get('/api/session')
|
|
.set('Cookie', tokenCookie)
|
|
.set('tj-workspace-id', orgId)
|
|
.expect(200);
|
|
});
|
|
});
|
|
|
|
afterAll(async () => {
|
|
await app.close();
|
|
});
|
|
});
|