-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into feat/payments
- Loading branch information
Showing
2,828 changed files
with
81,835 additions
and
92,854 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 |
---|---|---|
|
@@ -12,7 +12,8 @@ medusaIntegrationTestRunner({ | |
await createAdminUser(dbConnection, adminHeaders, getContainer()) | ||
}) | ||
|
||
it.only("test the entire authentication flow", async () => { | ||
// TODO: This test won't work since we don't allow creating a user through HTTP. We need to have the invite flow plugged in here. | ||
it.skip("test the entire authentication flow", async () => { | ||
// BREAKING: `/admin/auth` changes to `/auth/user/emailpass` | ||
const signup = await api.post("/auth/user/emailpass", { | ||
email: "[email protected]", | ||
|
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 |
---|---|---|
|
@@ -40,8 +40,7 @@ medusaIntegrationTestRunner({ | |
|
||
describe("GET /admin/users", () => { | ||
it("should list users", async () => { | ||
const response = await api | ||
.get("/admin/users", adminHeaders) | ||
const response = await api.get("/admin/users", adminHeaders) | ||
|
||
expect(response.status).toEqual(200) | ||
|
||
|
@@ -80,84 +79,6 @@ medusaIntegrationTestRunner({ | |
}) | ||
}) | ||
|
||
describe("POST /admin/users", () => { | ||
let token | ||
|
||
beforeEach(async () => { | ||
token = ( | ||
await api.post("/auth/user/emailpass", { | ||
email: "[email protected]", | ||
password: "test123", | ||
}) | ||
).data.token | ||
}) | ||
|
||
// BREAKING: V2 users do not require a role | ||
// We should probably remove this endpoint? | ||
it("should create a user", async () => { | ||
const payload = { | ||
email: "[email protected]", | ||
} | ||
|
||
// In V2, the flow to create an authenticated user depends on the token or session of a previously created auth user | ||
const headers = { | ||
headers: { Authorization: `Bearer ${token}` }, | ||
} | ||
|
||
const response = await api.post("/admin/users", payload, headers) | ||
|
||
expect(response.status).toEqual(200) | ||
expect(response.data.user).toEqual( | ||
expect.objectContaining({ | ||
id: expect.stringMatching(/^user_*/), | ||
created_at: expect.any(String), | ||
updated_at: expect.any(String), | ||
email: "[email protected]", | ||
}) | ||
) | ||
}) | ||
|
||
// V2 only test | ||
it("should throw, if session/bearer auth is present for existing user", async () => { | ||
const emailPassResponse = await api.post("/auth/user/emailpass", { | ||
email: "[email protected]", | ||
password: "test123", | ||
}) | ||
|
||
const token = emailPassResponse.data.token | ||
|
||
const headers = (token) => ({ | ||
headers: { Authorization: `Bearer ${token}` }, | ||
}) | ||
|
||
const res = await api.post( | ||
"/admin/users", | ||
{ | ||
email: "[email protected]", | ||
}, | ||
headers(token) | ||
) | ||
|
||
const authenticated = await api.post("/auth/user/emailpass", { | ||
email: "[email protected]", | ||
password: "test123", | ||
}) | ||
|
||
const payload = { | ||
email: "[email protected]", | ||
} | ||
|
||
const errorResponse = await api | ||
.post("/admin/users", payload, headers(authenticated.data.token)) | ||
.catch((err) => err.response) | ||
|
||
expect(errorResponse.status).toEqual(400) | ||
expect(errorResponse.data.message).toEqual( | ||
"Request carries authentication for an existing user" | ||
) | ||
}) | ||
}) | ||
|
||
describe("POST /admin/users/:id", () => { | ||
it("should update a user", async () => { | ||
const updateResponse = ( | ||
|
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
6 changes: 6 additions & 0 deletions
6
www/apps/api-reference/specs/admin/code_samples/Shell/admin_payment-collections/post.sh
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,6 @@ | ||
curl -X POST '{backend_url}/admin/payment-collections' \ | ||
-H 'x-medusa-access-token: {api_token}' \ | ||
-H 'Content-Type: application/json' \ | ||
--data-raw '{ | ||
"order_id": "{value}" | ||
}' |
5 changes: 0 additions & 5 deletions
5
www/apps/api-reference/specs/admin/code_samples/Shell/admin_users/post.sh
This file was deleted.
Oops, something went wrong.
8 changes: 8 additions & 0 deletions
8
www/apps/api-reference/specs/admin/components/schemas/AdminPaymentCollectionResponse.yaml
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,8 @@ | ||
type: object | ||
description: SUMMARY | ||
x-schemaName: AdminPaymentCollectionResponse | ||
required: | ||
- payment_collection | ||
properties: | ||
payment_collection: | ||
$ref: ./AdminPaymentCollection.yaml |
60 changes: 60 additions & 0 deletions
60
www/apps/api-reference/specs/admin/components/schemas/CreateCartWorkflowInput.yaml
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,60 @@ | ||
type: object | ||
description: SUMMARY | ||
x-schemaName: CreateCartWorkflowInput | ||
properties: | ||
region_id: | ||
type: string | ||
title: region_id | ||
description: The cart's region id. | ||
customer_id: | ||
type: string | ||
title: customer_id | ||
description: The cart's customer id. | ||
sales_channel_id: | ||
type: string | ||
title: sales_channel_id | ||
description: The cart's sales channel id. | ||
email: | ||
type: string | ||
title: email | ||
description: The cart's email. | ||
format: email | ||
currency_code: | ||
type: string | ||
title: currency_code | ||
description: The cart's currency code. | ||
shipping_address_id: | ||
type: string | ||
title: shipping_address_id | ||
description: The cart's shipping address id. | ||
billing_address_id: | ||
type: string | ||
title: billing_address_id | ||
description: The cart's billing address id. | ||
shipping_address: | ||
oneOf: | ||
- type: string | ||
title: shipping_address | ||
description: The cart's shipping address. | ||
- $ref: ./CreateCartAddress.yaml | ||
billing_address: | ||
oneOf: | ||
- type: string | ||
title: billing_address | ||
description: The cart's billing address. | ||
- $ref: ./CreateCartAddress.yaml | ||
metadata: | ||
type: object | ||
description: The cart's metadata. | ||
items: | ||
type: array | ||
description: The cart's items. | ||
items: | ||
$ref: ./CreateCartCreateLineItem.yaml | ||
promo_codes: | ||
type: array | ||
description: The cart's promo codes. | ||
items: | ||
type: string | ||
title: promo_codes | ||
description: The promo code's promo codes. |
26 changes: 0 additions & 26 deletions
26
www/apps/api-reference/specs/admin/components/schemas/CreateUser.yaml
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.