* authentication middleware update * disable customer authentication * call correct feature flag method * fix authentication middleware for store/customers * fix integration tests and add middleware for admin customers * update seeders * customer groups fix * add authentication middleware for all admin endpoints * Feat(medusa, user): require authentication for invite accept (#6448) * initial invite token validation for authentication invocation * remove invite auth * remove unused import * cleanup tests * refactor to auth instead of auth_user * pr feedback * update authenticatedRequest type * update store authenticated endpoints * update routes with type * fix build * fix build * fix build * use auth middleware for api-keys
56 lines
1.4 KiB
TypeScript
56 lines
1.4 KiB
TypeScript
import { initDb, useDb } from "../../../environment-helpers/use-db"
|
|
|
|
import { AxiosInstance } from "axios"
|
|
import { createAdminUser } from "../../helpers/create-admin-user"
|
|
import path from "path"
|
|
import { startBootstrapApp } from "../../../environment-helpers/bootstrap-app"
|
|
import { useApi } from "../../../environment-helpers/use-api"
|
|
|
|
jest.setTimeout(50000)
|
|
|
|
const env = { MEDUSA_FF_MEDUSA_V2: true }
|
|
const adminHeaders = {
|
|
headers: { "x-medusa-access-token": "test_token" },
|
|
}
|
|
|
|
describe("POST /admin/users", () => {
|
|
let dbConnection
|
|
let shutdownServer
|
|
|
|
beforeAll(async () => {
|
|
const cwd = path.resolve(path.join(__dirname, "..", ".."))
|
|
dbConnection = await initDb({ cwd, env } as any)
|
|
shutdownServer = await startBootstrapApp({ cwd, env })
|
|
})
|
|
|
|
beforeEach(async () => {
|
|
await createAdminUser(dbConnection, adminHeaders)
|
|
})
|
|
|
|
afterAll(async () => {
|
|
const db = useDb()
|
|
await db.shutdown()
|
|
await shutdownServer()
|
|
})
|
|
|
|
afterEach(async () => {
|
|
const db = useDb()
|
|
await db.teardown()
|
|
})
|
|
|
|
it("create a user", async () => {
|
|
const api = useApi()! as AxiosInstance
|
|
|
|
const body = {
|
|
email: "test_member@test.com",
|
|
}
|
|
|
|
const response = await api.post(`/admin/users`, body, adminHeaders)
|
|
|
|
expect(response.status).toEqual(200)
|
|
expect(response.data).toEqual({
|
|
user: expect.objectContaining(body),
|
|
})
|
|
})
|
|
})
|