1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.ApiSpec.AccountOperationTest do
6 use Pleroma.Web.ConnCase, async: true
8 alias Pleroma.Web.ApiSpec
9 alias Pleroma.Web.ApiSpec.Schemas.Account
10 alias Pleroma.Web.ApiSpec.Schemas.AccountCreateRequest
11 alias Pleroma.Web.ApiSpec.Schemas.AccountCreateResponse
13 import OpenApiSpex.TestAssertions
14 import Pleroma.Factory
16 test "Account example matches schema" do
17 api_spec = ApiSpec.spec()
18 schema = Account.schema()
19 assert_schema(schema.example, "Account", api_spec)
22 test "AccountCreateRequest example matches schema" do
23 api_spec = ApiSpec.spec()
24 schema = AccountCreateRequest.schema()
25 assert_schema(schema.example, "AccountCreateRequest", api_spec)
28 test "AccountCreateResponse example matches schema" do
29 api_spec = ApiSpec.spec()
30 schema = AccountCreateResponse.schema()
31 assert_schema(schema.example, "AccountCreateResponse", api_spec)
34 test "AccountController produces a AccountCreateResponse", %{conn: conn} do
35 api_spec = ApiSpec.spec()
36 app_token = insert(:oauth_token, user: nil)
40 |> put_req_header("authorization", "Bearer " <> app_token.token)
41 |> put_req_header("content-type", "application/json")
46 email: "bar@example.org",
53 assert_schema(json, "AccountCreateResponse", api_spec)