Skip to content

Commit

Permalink
Exchange the POST and PUT http methods (#84)
Browse files Browse the repository at this point in the history
* exchange the behaviour of PUT and POST

* assert post and put in respect of their privileges

* bump the version number
  • Loading branch information
dimos-flexiana authored May 4, 2021
1 parent ea4da99 commit fc16b85
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion project.clj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(defproject com.flexiana/framework "0.2.1"
(defproject com.flexiana/framework "0.2.2"
:description "Framework"
:url "https://github.com/Flexiana/framework"
:license {:name "FIXME" :url "FIXME"}
Expand Down
8 changes: 4 additions & 4 deletions src/framework/acl/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

(def action-mapping
{:get :read
:post :update
:put :create
:post :create
:put :update
:delete :delete})

(defn- ->resource
Expand Down Expand Up @@ -35,8 +35,8 @@
|req: | action: |
|------- |---------|
|:get | :read |
|:post | :update |
|:put | :create |
|:post | :create |
|:put | :update |
|:delete | :delete |"
([{{user :user} :session-data
roles :acl/roles
Expand Down
4 changes: 4 additions & 0 deletions test/framework/acl/core_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@
(get-error (is-allowed (state-with-user-request guest "/items/" :post)))))
(is (= :own
(get-ok (is-allowed (state-with-user-request member "/addresses/" :post)))))
(is (= :own
(get-ok (is-allowed (state-with-user-request member "/users/" :put)))))
(is (= {:status 401, :body "Authorization error"}
(get-error (is-allowed (state-with-user-request member "/users/" :post)))))
(is (= :all
(get-ok (is-allowed (state-with-user-request admin "/items/" :get)))))
(is (= :all
Expand Down

0 comments on commit fc16b85

Please sign in to comment.