diff options
| author | William Pitcock <nenolod@dereferenced.org> | 2018-11-17 20:07:49 +0000 | 
|---|---|---|
| committer | William Pitcock <nenolod@dereferenced.org> | 2018-11-17 20:16:03 +0000 | 
| commit | 1a940cb46e1fb06b391043ae2efa3ac0d3c49fe0 (patch) | |
| tree | 62c5f1d011bd3992aa799e306752228ab9d73c12 /test/web | |
| parent | daa8ec3d6273b7002ddee041686adf7652ec8e18 (diff) | |
| download | pleroma-1a940cb46e1fb06b391043ae2efa3ac0d3c49fe0.tar.gz pleroma-1a940cb46e1fb06b391043ae2efa3ac0d3c49fe0.zip  | |
tests: add tests for contain_origin_from_id()
Diffstat (limited to 'test/web')
| -rw-r--r-- | test/web/activity_pub/transmogrifier_test.exs | 38 | 
1 files changed, 38 insertions, 0 deletions
diff --git a/test/web/activity_pub/transmogrifier_test.exs b/test/web/activity_pub/transmogrifier_test.exs index 6320b5b6e..b8adf3b8a 100644 --- a/test/web/activity_pub/transmogrifier_test.exs +++ b/test/web/activity_pub/transmogrifier_test.exs @@ -918,4 +918,42 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do        :error = Transmogrifier.handle_incoming(data)      end    end + +  describe "general origin containment" do +    test "contain_origin_from_id() catches obvious spoofing attempts" do +      data = %{ +        "id" => "http://example.com/~alyssa/activities/1234.json" +      } + +      :error = +        Transmogrifier.contain_origin_from_id( +          "http://example.org/~alyssa/activities/1234.json", +          data +        ) +    end + +    test "contain_origin_from_id() allows alternate IDs within the same origin domain" do +      data = %{ +        "id" => "http://example.com/~alyssa/activities/1234.json" +      } + +      :ok = +        Transmogrifier.contain_origin_from_id( +          "http://example.com/~alyssa/activities/1234", +          data +        ) +    end + +    test "contain_origin_from_id() allows matching IDs" do +      data = %{ +        "id" => "http://example.com/~alyssa/activities/1234.json" +      } + +      :ok = +        Transmogrifier.contain_origin_from_id( +          "http://example.com/~alyssa/activities/1234.json", +          data +        ) +    end +  end  end  | 
