Merge branch 'fix-oauth-app-registration' into 'develop'
Change redirect_uris to accept array of strings See merge request pleroma/pleroma!4423
This commit is contained in:
commit
09aad75b33
6 changed files with 87 additions and 5 deletions
|
|
@ -57,6 +57,28 @@ defmodule Pleroma.Web.AdminAPI.OAuthAppControllerTest do
|
|||
} = response
|
||||
end
|
||||
|
||||
test "success with redirect_uris array", %{conn: conn} do
|
||||
base_url = Endpoint.url()
|
||||
app_name = "Trusted app"
|
||||
|
||||
response =
|
||||
conn
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> post("/api/pleroma/admin/oauth_app", %{
|
||||
name: app_name,
|
||||
redirect_uris: [base_url]
|
||||
})
|
||||
|> json_response_and_validate_schema(200)
|
||||
|
||||
assert %{
|
||||
"client_id" => _,
|
||||
"client_secret" => _,
|
||||
"name" => ^app_name,
|
||||
"redirect_uri" => ^base_url,
|
||||
"trusted" => false
|
||||
} = response
|
||||
end
|
||||
|
||||
test "with trusted", %{conn: conn} do
|
||||
base_url = Endpoint.url()
|
||||
app_name = "Trusted app"
|
||||
|
|
|
|||
|
|
@ -61,6 +61,33 @@ defmodule Pleroma.Web.MastodonAPI.AppControllerTest do
|
|||
assert app.user_id == nil
|
||||
end
|
||||
|
||||
test "creates an oauth app with redirect_uris array", %{conn: conn} do
|
||||
app_attrs = build(:oauth_app)
|
||||
|
||||
conn =
|
||||
conn
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> post("/api/v1/apps", %{
|
||||
client_name: app_attrs.client_name,
|
||||
redirect_uris: [app_attrs.redirect_uris]
|
||||
})
|
||||
|
||||
[app] = Repo.all(App)
|
||||
|
||||
expected = %{
|
||||
"name" => app.client_name,
|
||||
"website" => app.website,
|
||||
"client_id" => app.client_id,
|
||||
"client_secret" => app.client_secret,
|
||||
"id" => app.id |> to_string(),
|
||||
"redirect_uri" => app.redirect_uris,
|
||||
"vapid_key" => Push.vapid_config() |> Keyword.get(:public_key)
|
||||
}
|
||||
|
||||
assert expected == json_response_and_validate_schema(conn, 200)
|
||||
assert app.user_id == nil
|
||||
end
|
||||
|
||||
test "creates an oauth app with a user", %{conn: conn} do
|
||||
user = insert(:user)
|
||||
app_attrs = build(:oauth_app)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue