Compare commits

...

10 commits

6 changed files with 119 additions and 36 deletions

View file

@ -21,6 +21,13 @@ We got feedback from cool people and have collected the ideas around:
* https://www.youtube.com/watch?v=cru7E96pLAM - youtube series for implementing the souk poc * https://www.youtube.com/watch?v=cru7E96pLAM - youtube series for implementing the souk poc
* [doc/ideaForParsing.md](doc/ideaForParsing.md) - ideas for parsing with jena from a nice conversation with Eric Scott * [doc/ideaForParsing.md](doc/ideaForParsing.md) - ideas for parsing with jena from a nice conversation with Eric Scott
## Cool readings about decentralized authorization
* https://spritely.institute/news/introducing-ocapn-interoperable-capabilities-over-the-network.html
* https://forgefed.org/blog/projects-and-ocap-chains/
## Development & mirrors ## Development & mirrors
Development happens at: https://repo.prod.meissa.de/meissa/activity-pub-poc.git Development happens at: https://repo.prod.meissa.de/meissa/activity-pub-poc.git

View file

@ -5,8 +5,6 @@
[org.domaindrivenarchitecture.fed-poc.owl :as owl] [org.domaindrivenarchitecture.fed-poc.owl :as owl]
[org.domaindrivenarchitecture.fed-poc.xsd :as xsd])) [org.domaindrivenarchitecture.fed-poc.xsd :as xsd]))
;======================= ;=======================
;http://www.w3.org/ns/activitystreams#Object ;http://www.w3.org/ns/activitystreams#Object
@ -40,6 +38,12 @@
::Object ::Object
(sh/map-spec (s/keys :opt [::object])))) (sh/map-spec (s/keys :opt [::object]))))
;http://www.w3.org/ns/activitystreams#Dislike
(s/def ::Dislike
(s/and
::owl/Class
::Activity))
;http://www.w3.org/ns/activitystreams#Like ;http://www.w3.org/ns/activitystreams#Like
(s/def ::Like (s/def ::Like
(s/and (s/and

View file

@ -1,8 +1,8 @@
(ns org.domaindrivenarchitecture.fed-poc.forge (ns org.domaindrivenarchitecture.fed-poc.forgefed
(:require [clojure.spec.alpha :as s] (:require [clojure.spec.alpha :as s]
[orchestra.core :refer [defn-spec]] [orchestra.core :refer [defn-spec]]
[org.domaindrivenarchitecture.fed-poc.spec-helper :as sh] [org.domaindrivenarchitecture.fed-poc.spec-helper :as sh]
[org.domaindrivenarchitecture.fed-poc.owl :as owl] [org.domaindrivenarchitecture.fed-poc.activitystreams2 :as as]
[org.domaindrivenarchitecture.fed-poc.xsd :as xsd] [org.domaindrivenarchitecture.fed-poc.xsd :as xsd]
[org.domaindrivenarchitecture.fed-poc.activitystreams2 :as as])) [org.domaindrivenarchitecture.fed-poc.activitystreams2 :as as]))
@ -12,3 +12,18 @@
(s/and (s/and
::as/Object ::as/Object
(sh/map-spec (s/keys :opt [])))) (sh/map-spec (s/keys :opt []))))
;https://forgefed.org/ns#Star
(s/def ::Star
(s/merge
::as/Activity
(sh/map-spec (s/keys :opt [::source]))))
;https://forgefed.org/ns#Unstar
(s/def ::Unstar
(s/merge
::as/Activity
(sh/map-spec (s/keys :opt [::source]))))
(s/def ::source
(sh/seq-spec ::xsd/anyURI))

View file

@ -78,18 +78,55 @@
::sut/object {::sut/type "Note", ::sut/object {::sut/type "Note",
::sut/name "A Note"}}))) ::sut/name "A Note"}})))
(deftest Dislike-test
(testing "dislikes for mastodon notes"
(is (s/valid? ::sut/Dislike
{::sut/summary "Sally disliked a post",
::sut/type "Dislike",
::sut/actor {::sut/type "Person",
::sut/name "Sally"},
::sut/object "http://example.org/posts/1"}))
(testing "dislikes for forgejo repositories"
(is (s/valid? ::sut/Dislike
{::sut/id "https://repo.prod.meissa.de/activitypub/user-id/1/outbox/12346",
::sut/type "Dislike",
::sut/actor "https://repo.prod.meissa.de/activitypub/user-id/1",
::sut/object "https://codeberg.org/forgejo/forgejo.git"})))
))
(deftest Like-test (deftest Like-test
(is (s/valid? ::sut/Like (testing "likes for mastodon notes"
{::sut/summary "Sally liked a note", (is (s/valid? ::sut/Like
::sut/type "Like", {::sut/summary "Sally liked a note",
::sut/actor {::sut/type "Person", ::sut/type "Like",
::sut/name "Sally"}, ::sut/actor {::sut/type "Person",
::sut/object "http://example.org/notes/1"})) ::sut/name "Sally"},
(is (s/valid? ::sut/Like ::sut/object "http://example.org/notes/1"}))
{::sut/id "foo", (is (s/valid? ::sut/Like
::sut/type "Like", {::sut/id "foo",
::sut/actor "https://social.bla/alyssa", ::sut/type "Like",
::sut/object "http://example.org/notes/1"}))) ::sut/actor "https://social.bla/alyssa",
::sut/object "http://example.org/notes/1"})))
(testing "likes for forgejo repositories"
(testing "using public uris for id refernce"
(is (s/valid? ::sut/Like
{::sut/id "https://repo.prod.meissa.de/jem/like/12345",
::sut/type "Like",
::sut/actor "https://repo.prod.meissa.de/jem",
::sut/object "https://codeberg.org/forgejo/forgejo.git"})))
(testing "using api resource uris for id refernce"
(is (s/valid? ::sut/Like
{::sut/id "https://repo.prod.meissa.de/api/users/jem/like/12345",
::sut/type "Like",
::sut/actor "https://repo.prod.meissa.de/api/users/jem",
::sut/object "https://codeberg.org/api/repos/forgejo/forgejo"})))
(testing "using activitypub api uris for id refernce"
(is (s/valid? ::sut/Like
{::sut/id "https://repo.prod.meissa.de/api/activitypub/user-id/1/outbox/12345",
::sut/type "Like",
::sut/actor "https://repo.prod.meissa.de/api/activitypub/user-id/1",
::sut/object "https://codeberg.org/api/repos/forgejo/forgejo"})))
))
(deftest Object-test (deftest Object-test
(is (s/valid? ::sut/Object (is (s/valid? ::sut/Object

View file

@ -1,21 +0,0 @@
(ns org.domaindrivenarchitecture.fed-poc.forge-test
(:require
[clojure.test :refer [deftest is are testing run-tests]]
[clojure.spec.alpha :as s]
[org.domaindrivenarchitecture.fed-poc.security :as sec]
[org.domaindrivenarchitecture.fed-poc.activitystreams2 :as as]
[org.domaindrivenarchitecture.fed-poc.forge :as sut]))
(deftest Repository-test
(is (s/valid? ::sut/Repository
{::as/id "https://dev.example/aviva/treesim",
::as/type "Repository",
:sec/publicKey {::sec/id "https://dev.example/aviva/treesim#main-key",
::sec/owner "https://dev.example/aviva/treesim",
::sec/publicKeyPem "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhki....."},
::sut/inbox "https://dev.example/aviva/treesim/inbox",
::sut/outbox "https://dev.example/aviva/treesim/outbox",
::sut/followers "https://dev.example/aviva/treesim/followers",
::sut/team "https://dev.example/aviva/treesim/team",
::sut/name "Tree Growth 3D Simulation",
::sut/summary "<p>Tree growth 3D simulator for my nature exploration game</p>"})))

View file

@ -0,0 +1,41 @@
(ns org.domaindrivenarchitecture.fed-poc.forgefed-test
(:require
[clojure.test :refer [deftest is are testing run-tests]]
[clojure.spec.alpha :as s]
[org.domaindrivenarchitecture.fed-poc.security :as sec]
[org.domaindrivenarchitecture.fed-poc.activitystreams2 :as as]
[org.domaindrivenarchitecture.fed-poc.forgefed :as sut]))
(deftest Repository-test
(is (s/valid? ::sut/Repository
{::as/id "https://dev.example/aviva/treesim",
::as/type "Repository",
:sec/publicKey {::sec/id "https://dev.example/aviva/treesim#main-key",
::sec/owner "https://dev.example/aviva/treesim",
::sec/publicKeyPem "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhki....."},
::sut/inbox "https://dev.example/aviva/treesim/inbox",
::sut/outbox "https://dev.example/aviva/treesim/outbox",
::sut/followers "https://dev.example/aviva/treesim/followers",
::sut/team "https://dev.example/aviva/treesim/team",
::sut/name "Tree Growth 3D Simulation",
::sut/summary "<p>Tree growth 3D simulator for my nature exploration game</p>"})))
(deftest Star-test
(testing "stars for forgejo repositories"
(testing "using activitypub api uris for id refernce"
(is (s/valid? ::sut/Star
{::as/id "https://repo.prod.meissa.de/api/activitypub/user-id/1/outbox/12345",
::as/type "Star",
::sut/source "forgejo",
::as/actor "https://repo.prod.meissa.de/api/activitypub/user-id/1",
::as/object "https://codeberg.org/api/repos/forgejo/forgejo"})))))
(deftest Unstar-test
(testing "stars for forgejo repositories"
(testing "using activitypub api uris for id refernce"
(is (s/valid? ::sut/Unstar
{::as/id "https://repo.prod.meissa.de/api/activitypub/user-id/1/outbox/12345",
::as/type "Unstar",
::sut/source "forgejo",
::as/actor "https://repo.prod.meissa.de/api/activitypub/user-id/1",
::as/object "https://codeberg.org/api/repos/forgejo/forgejo"})))))