From 5a4e3aa715fdd588b7fefc79dc15535497513218 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Wed, 2 Feb 2022 11:02:23 -0600 Subject: [PATCH] Test that a Create/Note from Roadhouse validates --- .../create_generic_validator_test.exs | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 test/pleroma/web/activity_pub/object_validators/create_generic_validator_test.exs diff --git a/test/pleroma/web/activity_pub/object_validators/create_generic_validator_test.exs b/test/pleroma/web/activity_pub/object_validators/create_generic_validator_test.exs new file mode 100644 index 000000000..94c9f6800 --- /dev/null +++ b/test/pleroma/web/activity_pub/object_validators/create_generic_validator_test.exs @@ -0,0 +1,27 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2021 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + +defmodule Pleroma.Web.ActivityPub.ObjectValidators.CreateGenericValidatorTest do + use Pleroma.DataCase, async: true + + alias Pleroma.Web.ActivityPub.ObjectValidator + alias Pleroma.Web.ActivityPub.ObjectValidators.CreateGenericValidator + + import Pleroma.Factory + + test "a Create/Note from Roadhouse validates" do + insert(:user, ap_id: "https://macgirvin.com/channel/mike") + + note_activity = + "test/fixtures/roadhouse-create-activity.json" + |> File.read!() + |> Jason.decode!() + + # Build metadata + {:ok, object_data} = ObjectValidator.cast_and_apply(note_activity["object"]) + meta = [object_data: ObjectValidator.stringify_keys(object_data)] + + %{valid?: true} = CreateGenericValidator.cast_and_validate(note_activity, meta) + end +end