Improve and activate groups
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
@@ -64,7 +64,7 @@ defmodule Mobilizon.GraphQL.Resolvers.CommentTest do
|
||||
|> AbsintheHelpers.graphql_query(query: mutation, variables: %{})
|
||||
|
||||
assert hd(res["errors"])["message"] ==
|
||||
"Actor id is not owned by authenticated user"
|
||||
"Profile is not owned by authenticated user"
|
||||
end
|
||||
|
||||
test "create_comment/3 requires that the user needs to be authenticated", %{conn: conn} do
|
||||
|
||||
@@ -141,7 +141,7 @@ defmodule Mobilizon.Web.Resolvers.EventTest do
|
||||
assert res["data"]["createEvent"] == nil
|
||||
|
||||
assert hd(res["errors"])["message"] ==
|
||||
"Organizer actor id is not owned by the user"
|
||||
"Organizer profile is not owned by the user"
|
||||
end
|
||||
|
||||
test "create_event/3 should check that end time is after start time", %{
|
||||
@@ -693,7 +693,7 @@ defmodule Mobilizon.Web.Resolvers.EventTest do
|
||||
|> auth_conn(user)
|
||||
|> post("/api", AbsintheHelpers.mutation_skeleton(mutation))
|
||||
|
||||
assert hd(json_response(res, 200)["errors"])["message"] == "User doesn't own actor"
|
||||
assert hd(json_response(res, 200)["errors"])["message"] == "User doesn't own profile"
|
||||
end
|
||||
|
||||
test "update_event/3 should check end time is after the beginning time", %{
|
||||
|
||||
@@ -38,7 +38,7 @@ defmodule Mobilizon.Web.Resolvers.GroupTest do
|
||||
|> post("/api", AbsintheHelpers.mutation_skeleton(mutation))
|
||||
|
||||
assert hd(json_response(res, 200)["errors"])["message"] ==
|
||||
"Creator actor id is not owned by the current user"
|
||||
"Creator profile is not owned by the current user"
|
||||
end
|
||||
|
||||
test "create_group/3 creates a group and check a group with this name does not already exist",
|
||||
@@ -323,7 +323,7 @@ defmodule Mobilizon.Web.Resolvers.GroupTest do
|
||||
)
|
||||
|
||||
assert hd(res["errors"])["message"] ==
|
||||
"Actor id is not an administrator of the selected group"
|
||||
"Current profile is not an administrator of the selected group"
|
||||
end
|
||||
|
||||
test "delete_group/3 should check the actor is a member of this group", %{
|
||||
|
||||
@@ -135,7 +135,7 @@ defmodule Mobilizon.GraphQL.Resolvers.MemberTest do
|
||||
|> auth_conn(user)
|
||||
|> post("/api", AbsintheHelpers.mutation_skeleton(mutation))
|
||||
|
||||
assert hd(json_response(res, 200)["errors"])["message"] =~ "Group id not found"
|
||||
assert hd(json_response(res, 200)["errors"])["message"] =~ "Group not found"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -336,7 +336,7 @@ defmodule Mobilizon.GraphQL.Resolvers.MemberTest do
|
||||
}
|
||||
)
|
||||
|
||||
assert hd(res["errors"])["message"] == "Actor invited doesn't exist"
|
||||
assert hd(res["errors"])["message"] == "Profile invited doesn't exist"
|
||||
end
|
||||
|
||||
test "invite_member/3 fails to invite a non existing remote actor", %{
|
||||
@@ -358,7 +358,7 @@ defmodule Mobilizon.GraphQL.Resolvers.MemberTest do
|
||||
}
|
||||
)
|
||||
|
||||
assert hd(res["errors"])["message"] == "Actor invited doesn't exist"
|
||||
assert hd(res["errors"])["message"] == "Profile invited doesn't exist"
|
||||
end
|
||||
|
||||
test "invite_member/3 fails to invite a actor for a non-existing group", %{
|
||||
@@ -377,7 +377,7 @@ defmodule Mobilizon.GraphQL.Resolvers.MemberTest do
|
||||
}
|
||||
)
|
||||
|
||||
assert hd(res["errors"])["message"] == "Group id not found"
|
||||
assert hd(res["errors"])["message"] == "Group not found"
|
||||
end
|
||||
|
||||
test "invite_member/3 fails to invite a actor if we are not an admin for the group", %{
|
||||
|
||||
@@ -797,7 +797,7 @@ defmodule Mobilizon.GraphQL.Resolvers.ParticipantTest do
|
||||
|> post("/api", AbsintheHelpers.mutation_skeleton(mutation))
|
||||
|
||||
assert hd(json_response(res, 200)["errors"])["message"] ==
|
||||
"Provided moderator actor ID doesn't have permission on this event"
|
||||
"Provided moderator profile doesn't have permission on this event"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -941,7 +941,7 @@ defmodule Mobilizon.GraphQL.Resolvers.ParticipantTest do
|
||||
|> post("/api", AbsintheHelpers.mutation_skeleton(mutation))
|
||||
|
||||
assert hd(json_response(res, 200)["errors"])["message"] ==
|
||||
"Provided moderator actor ID doesn't have permission on this event"
|
||||
"Provided moderator profile doesn't have permission on this event"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -355,7 +355,7 @@ defmodule Mobilizon.GraphQL.Resolvers.PersonTest do
|
||||
assert json_response(res, 200)["data"]["updatePerson"] == nil
|
||||
|
||||
assert hd(json_response(res, 200)["errors"])["message"] ==
|
||||
"Actor is not owned by authenticated user"
|
||||
"Profile is not owned by authenticated user"
|
||||
end
|
||||
|
||||
test "update_person/3 should fail to update a not existing identity", context do
|
||||
@@ -381,7 +381,7 @@ defmodule Mobilizon.GraphQL.Resolvers.PersonTest do
|
||||
assert json_response(res, 200)["data"]["updatePerson"] == nil
|
||||
|
||||
assert hd(json_response(res, 200)["errors"])["message"] ==
|
||||
"Actor not found"
|
||||
"Profile not found"
|
||||
end
|
||||
|
||||
test "delete_person/3 should fail to update a not owned identity", context do
|
||||
@@ -405,7 +405,7 @@ defmodule Mobilizon.GraphQL.Resolvers.PersonTest do
|
||||
assert json_response(res, 200)["data"]["deletePerson"] == nil
|
||||
|
||||
assert hd(json_response(res, 200)["errors"])["message"] ==
|
||||
"Actor is not owned by authenticated user"
|
||||
"Profile is not owned by authenticated user"
|
||||
end
|
||||
|
||||
test "delete_person/3 should fail to delete a not existing identity", context do
|
||||
@@ -428,7 +428,7 @@ defmodule Mobilizon.GraphQL.Resolvers.PersonTest do
|
||||
assert json_response(res, 200)["data"]["deletePerson"] == nil
|
||||
|
||||
assert hd(json_response(res, 200)["errors"])["message"] ==
|
||||
"Actor not found"
|
||||
"Profile not found"
|
||||
end
|
||||
|
||||
test "delete_person/3 should fail to delete the last user identity", context do
|
||||
@@ -621,7 +621,7 @@ defmodule Mobilizon.GraphQL.Resolvers.PersonTest do
|
||||
assert res["data"]["person"]["participations"]["elements"] == nil
|
||||
|
||||
assert hd(res["errors"])["message"] ==
|
||||
"Actor id is not owned by authenticated user"
|
||||
"Profile is not owned by authenticated user"
|
||||
end
|
||||
|
||||
test "find_person/3 can return the participation for an identity on a specific event",
|
||||
|
||||
@@ -528,7 +528,7 @@ defmodule Mobilizon.GraphQL.Resolvers.PostTest do
|
||||
)
|
||||
|
||||
assert Enum.map(res["errors"], & &1["message"]) == [
|
||||
"Actor id is not member of group"
|
||||
"Profile is not member of group"
|
||||
]
|
||||
end
|
||||
end
|
||||
|
||||
@@ -130,7 +130,7 @@ defmodule Mobilizon.GraphQL.Resolvers.ReportTest do
|
||||
)
|
||||
|
||||
assert res["errors"] |> hd |> Map.get("message") ==
|
||||
"Reporter ID is not the anonymous actor id"
|
||||
"Reporter ID does not match the anonymous profile id"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -361,7 +361,7 @@ defmodule Mobilizon.GraphQL.Resolvers.ResourceTest do
|
||||
}
|
||||
)
|
||||
|
||||
assert hd(res["errors"])["message"] == "Actor is not member of group"
|
||||
assert hd(res["errors"])["message"] == "Profile is not member of group"
|
||||
end
|
||||
|
||||
test "get_resource/3 when not connected", %{
|
||||
@@ -516,7 +516,7 @@ defmodule Mobilizon.GraphQL.Resolvers.ResourceTest do
|
||||
)
|
||||
|
||||
assert Enum.map(res["errors"], & &1["message"]) == [
|
||||
"Actor id is not member of group"
|
||||
"Profile is not member of group"
|
||||
]
|
||||
end
|
||||
|
||||
@@ -545,7 +545,7 @@ defmodule Mobilizon.GraphQL.Resolvers.ResourceTest do
|
||||
)
|
||||
|
||||
assert Enum.map(res["errors"], & &1["message"]) == [
|
||||
"Parent resource doesn't match this group"
|
||||
"Parent resource doesn't belong to this group"
|
||||
]
|
||||
end
|
||||
end
|
||||
|
||||
@@ -372,7 +372,7 @@ defmodule Mobilizon.GraphQL.Resolvers.UserTest do
|
||||
|
||||
test "create_user/3 doesn't allow registration when registration is closed", %{conn: conn} do
|
||||
Config.put([:instance, :registrations_open], false)
|
||||
Config.put([:instance, :registration_email_whitelist], [])
|
||||
Config.put([:instance, :registration_email_allowlist], [])
|
||||
|
||||
mutation = """
|
||||
mutation createUser($email: String!, $password: String!) {
|
||||
@@ -393,15 +393,15 @@ defmodule Mobilizon.GraphQL.Resolvers.UserTest do
|
||||
variables: %{email: @user_creation.email, password: @user_creation.password}
|
||||
)
|
||||
|
||||
assert hd(res["errors"])["message"] == "Registrations are not enabled"
|
||||
assert hd(res["errors"])["message"] == "Registrations are not open"
|
||||
Config.put([:instance, :registrations_open], true)
|
||||
end
|
||||
|
||||
test "create_user/3 doesn't allow registration when user email is not on the whitelist", %{
|
||||
test "create_user/3 doesn't allow registration when user email is not on the allowlist", %{
|
||||
conn: conn
|
||||
} do
|
||||
Config.put([:instance, :registrations_open], false)
|
||||
Config.put([:instance, :registration_email_whitelist], ["random.org"])
|
||||
Config.put([:instance, :registration_email_allowlist], ["random.org"])
|
||||
|
||||
mutation = """
|
||||
mutation createUser($email: String!, $password: String!) {
|
||||
@@ -422,16 +422,16 @@ defmodule Mobilizon.GraphQL.Resolvers.UserTest do
|
||||
variables: %{email: @user_creation.email, password: @user_creation.password}
|
||||
)
|
||||
|
||||
assert hd(res["errors"])["message"] == "Your email is not on the whitelist"
|
||||
assert hd(res["errors"])["message"] == "Your email is not on the allowlist"
|
||||
Config.put([:instance, :registrations_open], true)
|
||||
Config.put([:instance, :registration_email_whitelist], [])
|
||||
Config.put([:instance, :registration_email_allowlist], [])
|
||||
end
|
||||
|
||||
test "create_user/3 allows registration when user email domain is on the whitelist", %{
|
||||
test "create_user/3 allows registration when user email domain is on the allowlist", %{
|
||||
conn: conn
|
||||
} do
|
||||
Config.put([:instance, :registrations_open], false)
|
||||
Config.put([:instance, :registration_email_whitelist], ["demo.tld"])
|
||||
Config.put([:instance, :registration_email_allowlist], ["demo.tld"])
|
||||
|
||||
mutation = """
|
||||
mutation createUser($email: String!, $password: String!) {
|
||||
@@ -455,12 +455,12 @@ defmodule Mobilizon.GraphQL.Resolvers.UserTest do
|
||||
refute res["errors"]
|
||||
assert res["data"]["createUser"]["email"] == @user_creation.email
|
||||
Config.put([:instance, :registrations_open], true)
|
||||
Config.put([:instance, :registration_email_whitelist], [])
|
||||
Config.put([:instance, :registration_email_allowlist], [])
|
||||
end
|
||||
|
||||
test "create_user/3 allows registration when user email is on the whitelist", %{conn: conn} do
|
||||
test "create_user/3 allows registration when user email is on the allowlist", %{conn: conn} do
|
||||
Config.put([:instance, :registrations_open], false)
|
||||
Config.put([:instance, :registration_email_whitelist], [@user_creation.email])
|
||||
Config.put([:instance, :registration_email_allowlist], [@user_creation.email])
|
||||
|
||||
mutation = """
|
||||
mutation createUser($email: String!, $password: String!) {
|
||||
@@ -484,7 +484,7 @@ defmodule Mobilizon.GraphQL.Resolvers.UserTest do
|
||||
refute res["errors"]
|
||||
assert res["data"]["createUser"]["email"] == @user_creation.email
|
||||
Config.put([:instance, :registrations_open], true)
|
||||
Config.put([:instance, :registration_email_whitelist], [])
|
||||
Config.put([:instance, :registration_email_allowlist], [])
|
||||
end
|
||||
|
||||
test "register_person/3 doesn't register a profile from an unknown email", context do
|
||||
|
||||
Reference in New Issue
Block a user