Skip to content

Commit

Permalink
OY-4903 katselmointihuomiot
Browse files Browse the repository at this point in the history
  • Loading branch information
marjakari committed Nov 16, 2023
1 parent 57acfe8 commit dfcc7f7
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 6 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,5 @@ npm-debug.log*
/docker/ataru-cypress-http-proxy/etc/nginx/nginx.conf
.clj-kondo/.cache
.java
.java-version
.lsp
.calva
37 changes: 37 additions & 0 deletions spec/ataru/applications/application_access_control_spec.clj
Original file line number Diff line number Diff line change
Expand Up @@ -339,3 +339,40 @@
["application-1-oid" "application-2-oid"]
[:view-applications])]
(should= false result))))))


(describe "applications-review-authorized?"
(tags :unit)
(it "returns true if user has edit rights to all hakukohteet"
(let [session (session-with-rights :edit-applications
["1.2.246.562.10.10826252480" "1.2.246.562.10.10826252479"])
result (aac/applications-review-authorized?
organization-service
tarjonta-service
session
[:1.2.246.562.20.49028100004 :1.2.246.562.20.49028196522]
[:edit-applications])]
(should= true result)))

(it "returns false if user has edit rights to only some of hakukohteet"
(let [session (session-with-rights :edit-applications ["1.2.246.562.10.10826252480"]
:view-applications ["1.2.246.562.10.10826252479"])
result (aac/applications-review-authorized?
organization-service
tarjonta-service
session
[:1.2.246.562.20.49028100004 :1.2.246.562.20.49028196522]
[:edit-applications])]
(should= false result)))

(it "returns true if user has edit rights to hakukohderyhma"
(let [session (session-with-rights :edit-applications ["1.2.246.562.28.00000000001"]
:view-applications ["1.2.246.562.10.10826252479"])
result (aac/applications-review-authorized?
organization-service
tarjonta-service
session
[:1.2.246.562.20.49028196522]
[:edit-applications])]
(should= false result))))

7 changes: 3 additions & 4 deletions src/clj/ataru/applications/application_access_control.clj
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,8 @@

(defn all-hakukohteet-authorized-by-tarjoajat?
[authorized-organization-oids hakukohteet]
(boolean
(every? #(authorized-by-tarjoaja? authorized-organization-oids %)
hakukohteet)))
(every? #(authorized-by-tarjoaja? authorized-organization-oids %)
hakukohteet))

(defn authorized-by-hakukohde?
[authorized-organization-oids hakukohde]
Expand Down Expand Up @@ -180,7 +179,7 @@
rights
(constantly false)
#(all-hakukohteet-authorized-by-tarjoajat? %
(tarjonta-protocol/get-hakukohteet tarjonta-service (into (vector) (map name hakukohde-oids))))
(tarjonta-protocol/get-hakukohteet tarjonta-service (vec (map name hakukohde-oids))))
(constantly true))))

(defn- authenticate-by-opinto-ohjaaja-fn
Expand Down
2 changes: 1 addition & 1 deletion src/clj/ataru/virkailija/virkailija_routes.clj
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,7 @@
nil (response/unauthorized {:error (str "Hakemuksen "
(:application-key review)
" käsittely ei ole sallittu")})
(-> (response/ok result)))))
(response/ok result))))

(api/POST "/information-request" {session :session}
:body [information-request ataru-schema/NewInformationRequest]
Expand Down

0 comments on commit dfcc7f7

Please sign in to comment.