logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma

app_operation_test.exs (1324B)


      1 # Pleroma: A lightweight social networking server
      2 # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
      3 # SPDX-License-Identifier: AGPL-3.0-only
      4 
      5 defmodule Pleroma.Web.ApiSpec.AppOperationTest do
      6   use Pleroma.Web.ConnCase, async: true
      7 
      8   alias Pleroma.Web.ApiSpec
      9   alias Pleroma.Web.ApiSpec.Schemas.AppCreateRequest
     10   alias Pleroma.Web.ApiSpec.Schemas.AppCreateResponse
     11 
     12   import OpenApiSpex.TestAssertions
     13   import Pleroma.Factory
     14 
     15   test "AppCreateRequest example matches schema" do
     16     api_spec = ApiSpec.spec()
     17     schema = AppCreateRequest.schema()
     18     assert_schema(schema.example, "AppCreateRequest", api_spec)
     19   end
     20 
     21   test "AppCreateResponse example matches schema" do
     22     api_spec = ApiSpec.spec()
     23     schema = AppCreateResponse.schema()
     24     assert_schema(schema.example, "AppCreateResponse", api_spec)
     25   end
     26 
     27   test "AppController produces a AppCreateResponse", %{conn: conn} do
     28     api_spec = ApiSpec.spec()
     29     app_attrs = build(:oauth_app)
     30 
     31     json =
     32       conn
     33       |> put_req_header("content-type", "application/json")
     34       |> post(
     35         "/api/v1/apps",
     36         Jason.encode!(%{
     37           client_name: app_attrs.client_name,
     38           redirect_uris: app_attrs.redirect_uris
     39         })
     40       )
     41       |> json_response(200)
     42 
     43     assert_schema(json, "AppCreateResponse", api_spec)
     44   end
     45 end