1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.EctoType.ActivityPub.ObjectValidators.ObjectIDTest do
6 alias Pleroma.EctoType.ActivityPub.ObjectValidators.ObjectID
10 "http://lain.com/users/lain",
12 "https://lain.com/object/1"
23 test "it accepts http uris" do
24 Enum.each(@uris, fn uri ->
25 assert {:ok, uri} == ObjectID.cast(uri)
29 test "it accepts an object with a nested uri id" do
30 Enum.each(@uris, fn uri ->
31 assert {:ok, uri} == ObjectID.cast(%{"id" => uri})
35 test "it rejects non-uri strings" do
36 Enum.each(@non_uris, fn non_uri ->
37 assert :error == ObjectID.cast(non_uri)
38 assert :error == ObjectID.cast(%{"id" => non_uri})