Skip to content

Commit

Permalink
Merge pull request #270 from saidone75/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
saidone75 authored May 18, 2024
2 parents 188c923 + 693db64 commit 42e0125
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 11 deletions.
2 changes: 1 addition & 1 deletion project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.

(defproject org.saidone/cral "0.3.2-SNAPSHOT"
(defproject org.saidone/cral "0.3.2"
:description "A library for consuming Alfresco Content Services public REST API"
:url "https://saidone.org"
:license {:name "GNU General Public License v3.0"
Expand Down
11 changes: 5 additions & 6 deletions src/cral/api/core/audit.clj
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
GetAuditEntryQueryParams
ListAuditApplicationEntriesQueryParams
ListAuditApplicationsQueryParams
ListNodeAuditEntryQueryParams
ListNodeAuditEntriesQueryParams
UpdateAuditApplicationInfoBody
UpdateAuditApplicationInfoQueryParams)))

Expand Down Expand Up @@ -148,20 +148,19 @@
{}
opts)))

(defn list-node-audit-entry
(defn list-node-audit-entries
"Gets a list of audit entries for node `node-id`.
The list can be filtered by **createdByUser** and for a given inclusive time period.
The default sort order is **createdAt** ascending, but you can use an optional **ASC** or **DESC** modifier to specify an ascending or descending sort order.
For example, specifying `order-by=createdAt DESC` returns audit entries in descending **createdAt** order.
This relies on the pre-configured 'alfresco-access' audit application.\\
More info [here](https://api-explorer.alfresco.com/api-explorer/?urls.primaryName=Core%20API#/audit/listAuditEntriesForNode)."
([^Ticket ticket ^String node-id]
(list-node-audit-entry ticket node-id nil))
([^Ticket ticket ^String node-id ^ListNodeAuditEntryQueryParams query-params & [^PersistentHashMap opts]]
(list-node-audit-entries ticket node-id nil))
([^Ticket ticket ^String node-id ^ListNodeAuditEntriesQueryParams query-params & [^PersistentHashMap opts]]
(utils/call-rest
client/get
(format "%s/nodes/%s/audit-entries" (config/get-url 'core) node-id)
ticket
{:query-params query-params}
opts)))

opts)))
2 changes: 1 addition & 1 deletion src/cral/model/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
(defrecord GetAuditEntryQueryParams
[^PersistentVector fields])

(defrecord ListNodeAuditEntryQueryParams
(defrecord ListNodeAuditEntriesQueryParams
[^Integer skip-count
^PersistentVector order-by
^Integer max-items
Expand Down
24 changes: 21 additions & 3 deletions test/cral/audit_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,13 @@
(:require [clojure.test :refer :all]
[cral.api.auth :as auth]
[cral.api.core.audit :as audit]
[cral.fixtures :as fixtures]
[cral.api.core.nodes :as nodes]
[cral.config :as c]
[cral.model.core :as model]))
[cral.fixtures :as fixtures]
[cral.model.alfresco.cm :as cm]
[cral.model.core :as model]
[cral.test-utils :as tu])
(:import (java.util UUID)))

(use-fixtures :once fixtures/setup)
(def alfresco-access "alfresco-access")
Expand Down Expand Up @@ -78,4 +82,18 @@
;; get an audit application id
list-audit-application-entries-response (audit/list-application-audit-entries ticket alfresco-access)
entry (rand-nth (get-in list-audit-application-entries-response [:body :list :entries]))]
(is (= (:status (audit/delete-audit-entry ticket alfresco-access (get-in entry [:entry :id]))) 204))))
(is (= (:status (audit/delete-audit-entry ticket alfresco-access (get-in entry [:entry :id]))) 204))))

(deftest list-node-audit-entries-test
(let [ticket (get-in (auth/create-ticket c/user c/password) [:body :entry])
;; create a node
parent-id (tu/get-guest-home ticket)
;; create a node
created-node-id (->> (model/map->CreateNodeBody {:name (.toString (UUID/randomUUID)) :node-type cm/type-content})
(nodes/create-node ticket parent-id)
(#(get-in % [:body :entry :id])))
list-audit-application-entries-response (audit/list-node-audit-entries ticket created-node-id)]
(is (= (:status list-audit-application-entries-response) 200))
(is (not (nil? (get-in list-audit-application-entries-response [:body :list :entries]))))
;; clean up
(is (= (:status (nodes/delete-node ticket created-node-id {:permanent true})) 204))))

0 comments on commit 42e0125

Please sign in to comment.