-
Notifications
You must be signed in to change notification settings - Fork 842
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feat-admin-signup
- Loading branch information
Showing
202 changed files
with
9,810 additions
and
3,340 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
REDIS_URL=redis://localhost:6379 | ||
DB_CONNECTION_URI=postgres://infisical:infisical@localhost/infisical?sslmode=disable | ||
AUTH_SECRET=4bnfe4e407b8921c104518903515b218 | ||
ENCRYPTION_KEY=4bnfe4e407b8921c104518903515b218 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
name: "Run backend tests" | ||
|
||
on: | ||
pull_request: | ||
types: [opened, synchronize] | ||
paths: | ||
- "backend/**" | ||
- "!backend/README.md" | ||
- "!backend/.*" | ||
- "backend/.eslintrc.js" | ||
workflow_call: | ||
|
||
jobs: | ||
check-be-pr: | ||
name: Run integration test | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 15 | ||
steps: | ||
- name: ☁️ Checkout source | ||
uses: actions/checkout@v3 | ||
- uses: KengoTODA/actions-setup-docker-compose@v1 | ||
if: ${{ env.ACT }} | ||
name: Install `docker-compose` for local simulations | ||
with: | ||
version: "2.14.2" | ||
- name: 🔧 Setup Node 20 | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: "20" | ||
cache: "npm" | ||
cache-dependency-path: backend/package-lock.json | ||
- name: Install dependencies | ||
run: npm install | ||
working-directory: backend | ||
- name: Start postgres and redis | ||
run: touch .env && docker-compose -f docker-compose.dev.yml up -d db redis | ||
- name: Start integration test | ||
run: npm run test:e2e | ||
working-directory: backend | ||
env: | ||
REDIS_URL: redis://172.17.0.1:6379 | ||
DB_CONNECTION_URI: postgres://infisical:[email protected]:5432/infisical?sslmode=disable | ||
AUTH_SECRET: something-random | ||
ENCRYPTION_KEY: 4bnfe4e407b8921c104518903515b218 | ||
- name: cleanup | ||
run: | | ||
docker-compose -f "docker-compose.dev.yml" down |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
vitest-environment-infisical.ts | ||
vitest.config.ts | ||
vitest.e2e.config.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import { OrgMembershipRole } from "@app/db/schemas"; | ||
import { seedData1 } from "@app/db/seed-data"; | ||
|
||
export const createIdentity = async (name: string, role: string) => { | ||
const createIdentityRes = await testServer.inject({ | ||
method: "POST", | ||
url: "/api/v1/identities", | ||
body: { | ||
name, | ||
role, | ||
organizationId: seedData1.organization.id | ||
}, | ||
headers: { | ||
authorization: `Bearer ${jwtAuthToken}` | ||
} | ||
}); | ||
expect(createIdentityRes.statusCode).toBe(200); | ||
return createIdentityRes.json().identity; | ||
}; | ||
|
||
export const deleteIdentity = async (id: string) => { | ||
const deleteIdentityRes = await testServer.inject({ | ||
method: "DELETE", | ||
url: `/api/v1/identities/${id}`, | ||
headers: { | ||
authorization: `Bearer ${jwtAuthToken}` | ||
} | ||
}); | ||
expect(deleteIdentityRes.statusCode).toBe(200); | ||
return deleteIdentityRes.json().identity; | ||
}; | ||
|
||
describe("Identity v1", async () => { | ||
test("Create identity", async () => { | ||
const newIdentity = await createIdentity("mac1", OrgMembershipRole.Admin); | ||
expect(newIdentity.name).toBe("mac1"); | ||
expect(newIdentity.authMethod).toBeNull(); | ||
|
||
await deleteIdentity(newIdentity.id); | ||
}); | ||
|
||
test("Update identity", async () => { | ||
const newIdentity = await createIdentity("mac1", OrgMembershipRole.Admin); | ||
expect(newIdentity.name).toBe("mac1"); | ||
expect(newIdentity.authMethod).toBeNull(); | ||
|
||
const updatedIdentity = await testServer.inject({ | ||
method: "PATCH", | ||
url: `/api/v1/identities/${newIdentity.id}`, | ||
headers: { | ||
authorization: `Bearer ${jwtAuthToken}` | ||
}, | ||
body: { | ||
name: "updated-mac-1", | ||
role: OrgMembershipRole.Member | ||
} | ||
}); | ||
|
||
expect(updatedIdentity.statusCode).toBe(200); | ||
expect(updatedIdentity.json().identity.name).toBe("updated-mac-1"); | ||
|
||
await deleteIdentity(newIdentity.id); | ||
}); | ||
|
||
test("Delete Identity", async () => { | ||
const newIdentity = await createIdentity("mac1", OrgMembershipRole.Admin); | ||
|
||
const deletedIdentity = await deleteIdentity(newIdentity.id); | ||
expect(deletedIdentity.name).toBe("mac1"); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.