-
Notifications
You must be signed in to change notification settings - Fork 4
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 chore-server/items-as-csv-to-usecase
- Loading branch information
Showing
44 changed files
with
3,816 additions
and
118 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,199 @@ | ||
package e2e | ||
|
||
import ( | ||
"net/http" | ||
"testing" | ||
|
||
"github.com/reearth/reearth-cms/server/internal/app" | ||
"github.com/reearth/reearth-cms/server/pkg/id" | ||
) | ||
|
||
func TestIntegrationSchemaJSONExportAPI(t *testing.T) { | ||
e := StartServer(t, &app.Config{}, true, baseSeeder) | ||
|
||
// /api/schemata/{schemaId}/schema.json | ||
e.GET("/api/schemata/{schemaId}/schema.json", sid1). | ||
WithHeader("authorization", "Bearer abcd"). | ||
Expect(). | ||
Status(http.StatusUnauthorized) | ||
|
||
e.GET("/api/schemata/{schemaId}/schema.json", id.NewSchemaID()). | ||
WithHeader("authorization", "Bearer "+secret). | ||
Expect(). | ||
Status(http.StatusNotFound) | ||
|
||
e.GET("/api/schemata/{schemaId}/schema.json", sid1). | ||
WithHeader("authorization", "Bearer "+secret). | ||
Expect(). | ||
Status(http.StatusOK). | ||
JSON(). | ||
IsEqual(map[string]any{ | ||
"$id": sid1, | ||
"$schema": "https://json-schema.org/draft/2020-12/schema", | ||
"properties": map[string]any{ | ||
"asset": map[string]any{ | ||
"type": "string", | ||
"format": "binary", | ||
}, | ||
sfKey1.String(): map[string]any{ | ||
"type": "string", | ||
}, | ||
}, | ||
"type": "object", | ||
}) | ||
|
||
// /api/projects/{projectIdOrKey}/schemata/{schemaId}/schema.json | ||
e.GET("/api/projects/{projectIdOrKey}/schemata/{schemaId}/schema.json", pid, sid1). | ||
WithHeader("authorization", "Bearer abcd"). | ||
Expect(). | ||
Status(http.StatusUnauthorized) | ||
|
||
e.GET("/api/projects/{projectIdOrKey}/schemata/{schemaId}/schema.json", pid, id.NewSchemaID()). | ||
WithHeader("authorization", "Bearer "+secret). | ||
Expect(). | ||
Status(http.StatusNotFound) | ||
|
||
e.GET("/api/projects/{projectIdOrKey}/schemata/{schemaId}/schema.json", pid, sid1). | ||
WithHeader("authorization", "Bearer "+secret). | ||
Expect(). | ||
Status(http.StatusOK). | ||
JSON(). | ||
IsEqual(map[string]any{ | ||
"$id": sid1, | ||
"$schema": "https://json-schema.org/draft/2020-12/schema", | ||
"properties": map[string]any{ | ||
"asset": map[string]any{ | ||
"type": "string", | ||
"format": "binary", | ||
}, | ||
sfKey1.String(): map[string]any{ | ||
"type": "string", | ||
}, | ||
}, | ||
"type": "object", | ||
}) | ||
|
||
// /api/projects/{projectIdOrKey}/models/{modelId}/schema.json | ||
e.GET("/api/projects/{projectIdOrKey}/models/{modelId}/schema.json", pid, mId1). | ||
WithHeader("authorization", "Bearer abcd"). | ||
Expect(). | ||
Status(http.StatusUnauthorized) | ||
|
||
e.GET("/api/projects/{projectIdOrKey}/models/{modelId}/schema.json", pid, id.NewModelID()). | ||
WithHeader("authorization", "Bearer "+secret). | ||
Expect(). | ||
Status(http.StatusNotFound) | ||
|
||
e.GET("/api/projects/{projectIdOrKey}/models/{modelId}/schema.json", pid, mId1). | ||
WithHeader("authorization", "Bearer "+secret). | ||
Expect(). | ||
Status(http.StatusOK). | ||
JSON(). | ||
IsEqual(map[string]any{ | ||
"$id": mId1, | ||
"$schema": "https://json-schema.org/draft/2020-12/schema", | ||
"properties": map[string]any{ | ||
"asset": map[string]any{ | ||
"type": "string", | ||
"format": "binary", | ||
}, | ||
sfKey1.String(): map[string]any{ | ||
"type": "string", | ||
}, | ||
}, | ||
"type": "object", | ||
"description": "m1 desc", | ||
"title": "m1", | ||
}) | ||
|
||
// /api/projects/{projectIdOrKey}/models/{modelId}/metadata_schema.json | ||
e.GET("/api/projects/{projectIdOrKey}/models/{modelId}/metadata_schema.json", pid, mId1). | ||
WithHeader("authorization", "Bearer abcd"). | ||
Expect(). | ||
Status(http.StatusUnauthorized) | ||
|
||
e.GET("/api/projects/{projectIdOrKey}/models/{modelId}/metadata_schema.json", pid, id.NewModelID()). | ||
WithHeader("authorization", "Bearer "+secret). | ||
Expect(). | ||
Status(http.StatusNotFound) | ||
|
||
e.GET("/api/projects/{projectIdOrKey}/models/{modelId}/metadata_schema.json", pid, mId1). | ||
WithHeader("authorization", "Bearer "+secret). | ||
Expect(). | ||
Status(http.StatusOK). | ||
JSON(). | ||
IsEqual(map[string]any{ | ||
"$id": mId1, | ||
"$schema": "https://json-schema.org/draft/2020-12/schema", | ||
"properties": map[string]any{ | ||
sfKey4.String(): map[string]any{ | ||
"type": "boolean", | ||
}, | ||
}, | ||
"type": "object", | ||
"description": "m1 desc", | ||
"title": "m1", | ||
}) | ||
|
||
// /api/models/{modelId}/schema.json | ||
e.GET("/api/models/{modelId}/schema.json", mId1). | ||
WithHeader("authorization", "Bearer abcd"). | ||
Expect(). | ||
Status(http.StatusUnauthorized) | ||
|
||
e.GET("/api/models/{modelId}/schema.json", id.NewModelID()). | ||
WithHeader("authorization", "Bearer "+secret). | ||
Expect(). | ||
Status(http.StatusNotFound) | ||
|
||
e.GET("/api/models/{modelId}/schema.json", mId1). | ||
WithHeader("authorization", "Bearer "+secret). | ||
Expect(). | ||
Status(http.StatusOK). | ||
JSON(). | ||
IsEqual(map[string]any{ | ||
"$id": mId1, | ||
"$schema": "https://json-schema.org/draft/2020-12/schema", | ||
"properties": map[string]any{ | ||
"asset": map[string]any{ | ||
"type": "string", | ||
"format": "binary", | ||
}, | ||
sfKey1.String(): map[string]any{ | ||
"type": "string", | ||
}, | ||
}, | ||
"type": "object", | ||
"description": "m1 desc", | ||
"title": "m1", | ||
}) | ||
|
||
// /api/models/{modelId}/metadata_schema.json | ||
e.GET("/api/models/{modelId}/metadata_schema.json", mId1). | ||
WithHeader("authorization", "Bearer abcd"). | ||
Expect(). | ||
Status(http.StatusUnauthorized) | ||
|
||
e.GET("/api/models/{modelId}/metadata_schema.json", id.NewModelID()). | ||
WithHeader("authorization", "Bearer "+secret). | ||
Expect(). | ||
Status(http.StatusNotFound) | ||
|
||
e.GET("/api/models/{modelId}/metadata_schema.json", mId1). | ||
WithHeader("authorization", "Bearer "+secret). | ||
Expect(). | ||
Status(http.StatusOK). | ||
JSON(). | ||
IsEqual(map[string]any{ | ||
"$id": mId1, | ||
"$schema": "https://json-schema.org/draft/2020-12/schema", | ||
"properties": map[string]any{ | ||
sfKey4.String(): map[string]any{ | ||
"type": "boolean", | ||
}, | ||
}, | ||
"type": "object", | ||
"description": "m1 desc", | ||
"title": "m1", | ||
}) | ||
} |
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.