logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://hacktivis.me/git/pleroma.git

bare_uri_test.ex (812B)


  1. # Pleroma: A lightweight social networking server
  2. # Copyright © 2017-2023 Pleroma Authors <https://pleroma.social/>
  3. # SPDX-License-Identifier: AGPL-3.0-only
  4. defmodule Pleroma.EctoType.ActivityPub.ObjectValidators.BareUriTest do
  5. use Pleroma.DataCase, async: true
  6. alias Pleroma.EctoType.ActivityPub.ObjectValidators.BareUri
  7. test "diaspora://" do
  8. text = "diaspora://alice@fediverse.example/post/deadbeefdeadbeefdeadbeefdeadbeef"
  9. assert {:ok, text} = BareUri.cast(text)
  10. end
  11. test "nostr:" do
  12. text = "nostr:note1gwdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef"
  13. assert {:ok, text} = BareUri.cast(text)
  14. end
  15. test "errors for non-URIs" do
  16. assert :error == SafeText.cast(1)
  17. assert :error == SafeText.cast("foo")
  18. assert :error == SafeText.cast("foo bar")
  19. end
  20. end