1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.PleromaAPI.AppControllerTest do
6 use Pleroma.Web.ConnCase, async: true
8 alias Pleroma.Web.OAuth.App
11 import Pleroma.Factory
13 test "apps", %{conn: conn} do
15 app_attrs = build(:oauth_app)
19 |> put_req_header("content-type", "application/json")
20 |> assign(:user, user)
21 |> post("/api/v1/apps", %{
22 client_name: app_attrs.client_name,
23 redirect_uris: app_attrs.redirect_uris
26 [app] = App.get_user_apps(user)
29 "name" => app.client_name,
30 "website" => app.website,
31 "client_id" => app.client_id,
32 "client_secret" => app.client_secret,
33 "id" => app.id |> to_string(),
34 "redirect_uri" => app.redirect_uris,
35 "vapid_key" => Push.vapid_config() |> Keyword.get(:public_key)
38 assert expected == json_response_and_validate_schema(creation, 200)
42 |> put_req_header("content-type", "application/json")
43 |> assign(:user, user)
44 |> assign(:token, insert(:oauth_token, user: user, scopes: ["read", "follow"]))
45 |> get("/api/v1/pleroma/apps")
46 |> json_response_and_validate_schema(200)
50 assert length(response) == 1
51 assert apps["client_id"] == app.client_id