1
0
Fork 0
mirror of https://git.youjo.love/youjo/youjo-be.git synced 2025-03-01 16:43:05 +01:00

Merge branch 'unique-app-id' into 'develop'

Add unique index for apps.client_id, fixes 

Closes 

See merge request 
This commit is contained in:
lain 2020-08-05 09:08:50 +00:00
commit 474aba984f
2 changed files with 18 additions and 0 deletions

View file

@ -0,0 +1,7 @@
defmodule Pleroma.Repo.Migrations.AddUniqueIndexToAppClientId do
use Ecto.Migration
def change do
create(unique_index(:apps, [:client_id]))
end
end

View file

@ -29,5 +29,16 @@ defmodule Pleroma.Web.OAuth.AppTest do
assert exist_app.id == app.id assert exist_app.id == app.id
assert exist_app.scopes == ["read", "write", "follow", "push"] assert exist_app.scopes == ["read", "write", "follow", "push"]
end end
test "has unique client_id" do
insert(:oauth_app, client_name: "", redirect_uris: "", client_id: "boop")
error =
catch_error(insert(:oauth_app, client_name: "", redirect_uris: "", client_id: "boop"))
assert %Ecto.ConstraintError{} = error
assert error.constraint == "apps_client_id_index"
assert error.type == :unique
end
end end
end end