Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions deps.edn
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{:deps {org.clojure/clojure {:mvn/version "1.11.3"}
org.clojure/core.async {:mvn/version "1.6.681"}
com.fluree/db {:git/url "https://github.com/fluree/db.git"
:git/sha "af564dbf2b3d90503a9f7de8143ffcfcd9767dd1"}
com.fluree/json-ld {:mvn/version "1.0.1"}
:git/sha "e6df029c3bf4f3117c3b0402aeea401fbed2d871"}
com.fluree/json-ld {:git/url "https://github.com/fluree/json-ld.git"
:git/sha "74083536c84d77f8cdd4b686b5661714010baad3"}

integrant/integrant {:mvn/version "0.10.0"}
com.fluree/crypto {:git/url "https://github.com/fluree/fluree.crypto.git"
Expand Down
6 changes: 3 additions & 3 deletions src/fluree/server/config.clj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(ns fluree.server.config
(:require [clojure.java.io :as io]
[fluree.db.connection.config :as conn-config]
[fluree.db.util :as util :refer [get-id get-first-value]]
[fluree.db.util :as util :refer [get-id get-first-value of-type?]]
[fluree.db.util.log :as log]
[fluree.server.config.vocab :as vocab]
[fluree.server.consensus :as-alias consensus]
Expand Down Expand Up @@ -62,7 +62,7 @@

(defn consensus?
[node]
(conn-config/type? node vocab/consensus-type))
(of-type? node vocab/consensus-type))

(defn raft-consensus?
[node]
Expand All @@ -76,7 +76,7 @@

(defn http-api?
[node]
(and (conn-config/type? node vocab/api-type)
(and (of-type? node vocab/api-type)
(contains? node vocab/http-port)))

(defn jetty-api?
Expand Down
60 changes: 30 additions & 30 deletions src/fluree/server/system.clj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[fluree.db.connection.config :as conn-config]
[fluree.db.connection.system :as conn-system]
[fluree.db.connection.vocab :as conn-vocab]
[fluree.db.util :as util :refer [get-first]]
[fluree.db.util :as util :refer [get-first of-type?]]
[fluree.db.util.json :as json]
[fluree.db.util.log :as log]
[fluree.server :as-alias server]
Expand Down Expand Up @@ -153,38 +153,38 @@

(defn log-config-summary
[parsed-config]
(let [connection-config (some #(when (conn-config/type? % conn-vocab/connection-type) %)
(let [connection-config (some #(when (of-type? % conn-vocab/connection-type) %)
(vals parsed-config))
storage-config (some #(when (conn-config/type? % conn-vocab/storage-type) %)
(vals parsed-config))
consensus-config (some #(when (config/consensus? %) %)
(vals parsed-config))
http-config (some #(when (config/http-api? %) %)
(vals parsed-config))
cache-mb (when connection-config
(conn-config/get-first-integer connection-config conn-vocab/cache-max-mb))
storage-type (when storage-config
(let [storage-id (:id storage-config)]
(cond
(conn-config/get-first-string storage-config conn-vocab/file-path)
(str "File storage at " (conn-config/get-first-string storage-config conn-vocab/file-path))

(conn-config/get-first-string storage-config conn-vocab/s3-bucket)
(str "S3 storage (bucket: " (conn-config/get-first-string storage-config conn-vocab/s3-bucket) ")")

(conn-config/get-first-string storage-config conn-vocab/ipfs-endpoint)
(str "IPFS storage (endpoint: " (conn-config/get-first-string storage-config conn-vocab/ipfs-endpoint) ")")

:else
(str "Storage type: " (name (or storage-id "unknown"))))))
consensus-type (when consensus-config
(util/get-first-value consensus-config server-vocab/consensus-protocol))
storage-config (some #(when (of-type? % conn-vocab/storage-type) %)
(vals parsed-config))
consensus-config (some #(when (config/consensus? %) %)
(vals parsed-config))
http-config (some #(when (config/http-api? %) %)
(vals parsed-config))
cache-mb (when connection-config
(conn-config/get-first-integer connection-config conn-vocab/cache-max-mb))
storage-type (when storage-config
(let [storage-id (:id storage-config)]
(cond
(conn-config/get-first-string storage-config conn-vocab/file-path)
(str "File storage at " (conn-config/get-first-string storage-config conn-vocab/file-path))

(conn-config/get-first-string storage-config conn-vocab/s3-bucket)
(str "S3 storage (bucket: " (conn-config/get-first-string storage-config conn-vocab/s3-bucket) ")")

(conn-config/get-first-string storage-config conn-vocab/ipfs-endpoint)
(str "IPFS storage (endpoint: " (conn-config/get-first-string storage-config conn-vocab/ipfs-endpoint) ")")

:else
(str "Storage type: " (name (or storage-id "unknown"))))))
consensus-type (when consensus-config
(util/get-first-value consensus-config server-vocab/consensus-protocol))
max-pending-txns (when (and consensus-config (= "standalone" consensus-type))
(conn-config/get-first-integer consensus-config server-vocab/max-pending-txns))
http-port (when http-config
(conn-config/get-first-integer http-config server-vocab/http-port))
closed-mode (when http-config
(conn-config/get-first-boolean http-config server-vocab/closed-mode))]
http-port (when http-config
(conn-config/get-first-integer http-config server-vocab/http-port))
closed-mode (when http-config
(conn-config/get-first-boolean http-config server-vocab/closed-mode))]
(log/info "Server configuration summary:")
(log/info " HTTP port:" (or http-port "Not configured"))
(log/info " Consensus mode:" (or consensus-type "Not configured"))
Expand Down
6 changes: 3 additions & 3 deletions test/fluree/server/integration/policy_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@
(json/stringify
(assoc secret-query
"opts" {"policyClass" "ex:EmployeePolicy"
"policyValues" ["?$identity" [alice-did]]}))
"policyValues" ["?$identity" [{"@type" "@id" "@value" alice-did}]]}))
:headers json-headers}
query-res (api-post :query query-req)]

Expand All @@ -316,7 +316,7 @@
schema:ssn ?ssn.}")
:headers (assoc sparql-headers
"Fluree-Policy-Class" "ex:EmployeePolicy"
"Fluree-Policy-Values" (json/stringify ["?$identity" [alice-did]]))}
"Fluree-Policy-Values" (json/stringify ["?$identity" [{"@type" "@id" "@value" alice-did}]]))}
query-res (api-post :query query-req)]

(is (= [["ex:alice" "111-11-1111"]]
Expand Down Expand Up @@ -380,7 +380,7 @@
"f:action" {"@id" "f:view"}
"f:query" {"@type" "@json"
"@value" {}}}]}
policy-values ["?$identity" [alice-did]]
policy-values ["?$identity" [{"@type" "@id" "@value" alice-did}]]
query-req {:body
(json/stringify
(assoc secret-query
Expand Down
42 changes: 18 additions & 24 deletions test/fluree/server/profile_test.clj
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
(ns fluree.server.profile-test
(:require [clojure.test :refer [deftest is testing]]
[fluree.db.util :as util]
[fluree.db.util.json :as json]
[fluree.server :as server]
[fluree.server.command :as command]
Expand Down Expand Up @@ -81,27 +82,23 @@
(testing "Without profile, default values are used"
(let [parsed-no-profile (config/parse json-config)]
;; Find the localStorage node
(is (some #(and (= :https<cl><sl><sl>ns<do>flur<do>ee<sl>config<sl>test<sl>/localStorage (:id %))
(is (some #(and (= :https<cl><sl><sl>ns<do>flur<do>ee<sl>config<sl>test<sl>/localStorage (util/get-id %))
(= "/opt/fluree-server/data"
(-> (get % "https://ns.flur.ee/system#filePath")
first
:value)))
(util/get-first-value % "https://ns.flur.ee/system#filePath")))
(vals parsed-no-profile)))

;; Find the connection node
(is (some #(and (= :https<cl><sl><sl>ns<do>flur<do>ee<sl>config<sl>test<sl>/connection (:id %))
(is (some #(and (= :https<cl><sl><sl>ns<do>flur<do>ee<sl>config<sl>test<sl>/connection
(util/get-id %))
(= 1000
(-> (get % "https://ns.flur.ee/system#cacheMaxMb")
first
:value)))
(util/get-first-value % "https://ns.flur.ee/system#cacheMaxMb")))
(vals parsed-no-profile)))

;; Find the consensus node
(is (some #(and (= :https<cl><sl><sl>ns<do>flur<do>ee<sl>config<sl>test<sl>/consensus (:id %))
(is (some #(and (= :https<cl><sl><sl>ns<do>flur<do>ee<sl>config<sl>test<sl>/consensus
(util/get-id %))
(= 512
(-> (get % "https://ns.flur.ee/system#maxPendingTxns")
first
:value)))
(util/get-first-value % "https://ns.flur.ee/system#maxPendingTxns")))
(vals parsed-no-profile)))))

;; Test with dev profile
Expand All @@ -110,27 +107,24 @@
parsed-with-profile (config/parse config-with-profile)]

;; Find the localStorage node - should have dev/data
(is (some #(and (= :https<cl><sl><sl>ns<do>flur<do>ee<sl>config<sl>test<sl>/localStorage (:id %))
(is (some #(and (= :https<cl><sl><sl>ns<do>flur<do>ee<sl>config<sl>test<sl>/localStorage
(util/get-id %))
(= "dev/data"
(-> (get % "https://ns.flur.ee/system#filePath")
first
:value)))
(util/get-first-value % "https://ns.flur.ee/system#filePath")))
(vals parsed-with-profile)))

;; Find the connection node - cacheMaxMb should be 200
(is (some #(and (= :https<cl><sl><sl>ns<do>flur<do>ee<sl>config<sl>test<sl>/connection (:id %))
(is (some #(and (= :https<cl><sl><sl>ns<do>flur<do>ee<sl>config<sl>test<sl>/connection
(util/get-id %))
(= 200
(-> (get % "https://ns.flur.ee/system#cacheMaxMb")
first
:value)))
(util/get-first-value % "https://ns.flur.ee/system#cacheMaxMb")))
(vals parsed-with-profile)))

;; Find the consensus node - maxPendingTxns should be 16
(is (some #(and (= :https<cl><sl><sl>ns<do>flur<do>ee<sl>config<sl>test<sl>/consensus (:id %))
(is (some #(and (= :https<cl><sl><sl>ns<do>flur<do>ee<sl>config<sl>test<sl>/consensus
(util/get-id %))
(= 16
(-> (get % "https://ns.flur.ee/system#maxPendingTxns")
first
:value)))
(util/get-first-value % "https://ns.flur.ee/system#maxPendingTxns")))
(vals parsed-with-profile)))))))

(deftest error-handling-test
Expand Down