Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moves to Keycloak 24.0.5 #63

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
14 changes: 7 additions & 7 deletions deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,17 @@
com.google.cloud/google-cloud-secretmanager {:mvn/version "2.23.0"}

;; keycloak stuff
org.keycloak/keycloak-common {:mvn/version "24.0.2"}
org.keycloak/keycloak-core {:mvn/version "24.0.2"}
org.keycloak/keycloak-authz-client {:mvn/version "24.0.2"}
org.keycloak/keycloak-policy-enforcer{:mvn/version "24.0.2"}
org.keycloak/keycloak-adapter-core {:mvn/version "24.0.2"}
org.keycloak/keycloak-adapter-spi {:mvn/version "24.0.2"}
org.keycloak/keycloak-common {:mvn/version "24.0.5"}
org.keycloak/keycloak-core {:mvn/version "24.0.5"}
org.keycloak/keycloak-authz-client {:mvn/version "24.0.5"}
org.keycloak/keycloak-policy-enforcer{:mvn/version "24.0.5"}
org.keycloak/keycloak-adapter-core {:mvn/version "24.0.5"}
org.keycloak/keycloak-adapter-spi {:mvn/version "24.0.5"}
org.jboss.logging/jboss-logging {:mvn/version "3.5.3.Final"}
org.apache.httpcomponents/httpclient {:mvn/version "4.5.14"}

;;all the deps below are for the admin client (don't know why the transitive deps didn't work)
org.keycloak/keycloak-admin-client {:mvn/version "24.0.2"}
org.keycloak/keycloak-admin-client {:mvn/version "24.0.5"}
;com.fasterxml.jackson.core/jackson-core {:mvn/version "2.17.0"}
;com.fasterxml.jackson.core/jackson-databind {:mvn/version "2.17.0"}
;com.fasterxml.jackson.jaxrs/jackson-jaxrs-json-provider {:mvn/version "2.17.0"}
Expand Down
2 changes: 1 addition & 1 deletion docker/start-keycloak-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ docker run -d \
--name keycloak-dev \
-p 127.0.0.1:9990:9990 \
-p 127.0.0.1:8080:8080 \
quay.io/keycloak/keycloak:24.0.2 start-dev
quay.io/keycloak/keycloak:24.0.5 start-dev
2 changes: 1 addition & 1 deletion src/keycloak/utils.clj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
(defn keycloak-running? [keycloak-client]
(try
(-> keycloak-client (.realm "master") (.toRepresentation) bean)
; (catch javax.ws.rs.ProcessingException pe false)
; (catch jakarta.ws.rs.ProcessingException pe false)
; (catch java.net.ConnectException ce false)
))

Expand Down
6 changes: 3 additions & 3 deletions test/keycloak/backend_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@
headers
(kc-authn/auth-cookie token))}))

(defn yada-test-context [token]
{:request (request-for :get "/protected" (headers-with-token-as-header {} token))})

(def EXPIRED_TOKEN_BAD_REALM {:access_token
"eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJxYnIwakNmanZXRXJfV0tkT1FSVzdkTkNiZmZHeXZQaVROTVA2ZjdYSVpZIn0.eyJleHAiOjE2MTM3NTk5MTAsImlhdCI6MTYxMzc1OTYxMCwianRpIjoiNTdmZjFmNjktNDk2ZC00MTA5LWI1ZTctZGFlYTk1NDY4Mzg0IiwiaXNzIjoiaHR0cDovL2xvZ2luLmRlZmF1bHQubWluaWt1YmUuZGV2bWFjaGluZS9hdXRoL3JlYWxtcy9lbGVjdHJlIiwiYXVkIjoiYWNjb3VudCIsInN1YiI6ImRkMTdlODkzLTFmYWYtNDBjMi04MzA0LTFiZjI1NjMxOTkxOCIsInR5cCI6IkJlYXJlciIsImF6cCI6ImRpZmZ1c2lvbi1mcm9udGVuZCIsInNlc3Npb25fc3RhdGUiOiI3MzgzMGM1Mi03YWE2LTRmMWYtOTFmZS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wMCr9OHYKe50YRax5RjH72fY7m2WIpZyeaS6ZNi_Ud5nxTRFJHBhhRARLltjaUpB_Guv-6TGYDI46jNCozgJMlYiJkaTOy1o3s10jVowqXNxxaCNQP1zOX7Swri6UCkleuhiG4AOxA1XjRcg",
:expires_in 300,
Expand Down Expand Up @@ -78,6 +75,9 @@
(:body options) (update :body b/to-byte-buffers)
true (update :headers #(merge {"host" "localhost"} %))))))

(defn yada-test-context [token]
{:request (request-for :get "/protected" (headers-with-token-as-header {} token))})

(defn yada-test-context-missing-token []
{:request (request-for :get "/protected" {:headers {"content-type" "application/transit+json"
"accept" "application/transit+json"}})})
Expand Down
2 changes: 1 addition & 1 deletion test/keycloak/deployment_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
(is (= username (:username extracted-token)))))))))
(testing "realm deletion"
(delete-realm! admin-client realm-name)
(is (thrown? javax.ws.rs.NotFoundException (get-realm admin-client realm-name))))))))
(is (thrown? jakarta.ws.rs.NotFoundException (get-realm admin-client realm-name))))))))

(defn delete-realms-except [realms-to-keep]
(let [admin-client (deployment/keycloak-client integration-test-conf admin-login admin-password)
Expand Down
8 changes: 4 additions & 4 deletions test/keycloak/reconciliation_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
(is (= "to-be-modified-1" (:username (first (:user/updates plan)))))))
(testing "realm deletion"
(admin/delete-realm! admin-client realm-name)
(is (thrown? javax.ws.rs.NotFoundException (admin/get-realm admin-client realm-name)))))))
(is (thrown? jakarta.ws.rs.NotFoundException (admin/get-realm admin-client realm-name)))))))
(testing "Fetch the existing users and diff the one that need update or creation"
(let [])))

Expand Down Expand Up @@ -189,7 +189,7 @@
(-> (get plan :user/updates) first :groups) => [{:path "/group2"}])))))))
(testing "realm deletion"
(admin/delete-realm! admin-client realm-name)
(is (thrown? javax.ws.rs.NotFoundException (admin/get-realm admin-client realm-name))))))))
(is (thrown? jakarta.ws.rs.NotFoundException (admin/get-realm admin-client realm-name))))))))

(defn- get-roles->users [admin-client realm-name roles]
(into {} (map (fn [[role users]] [role (into [] (map bean/UserRepresentation->map users))]) (user/get-users-aggregated-by-realm-roles admin-client realm-name roles))))
Expand Down Expand Up @@ -246,7 +246,7 @@
(get empty-plan :realm-role-mappings/deletions) => empty?)))))
(testing " finally realm is deleted"
(admin/delete-realm! admin-client realm-name)
(is (thrown? javax.ws.rs.NotFoundException (admin/get-realm admin-client realm-name))))))))
(is (thrown? jakarta.ws.rs.NotFoundException (admin/get-realm admin-client realm-name))))))))

(deftest ^:integration groups-test
(let [admin-client (deployment/keycloak-client integration-test-conf admin-login admin-password)]
Expand Down Expand Up @@ -313,7 +313,7 @@
(get empty-plan :groups/deletions) => empty?)))))
(testing " finally realm is deleted"
(admin/delete-realm! admin-client realm-name)
(is (thrown? javax.ws.rs.NotFoundException (admin/get-realm admin-client realm-name))))))))
(is (thrown? jakarta.ws.rs.NotFoundException (admin/get-realm admin-client realm-name))))))))


(comment
Expand Down
4 changes: 2 additions & 2 deletions test/keycloak/starter_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
(fact secret-value => (comp not str/blank?)))))))
(testing "realm deletion"
(delete-realm! admin-client realm-name)
(is (thrown? javax.ws.rs.NotFoundException (get-realm admin-client realm-name)))
(is (thrown? jakarta.ws.rs.NotFoundException (get-realm admin-client realm-name)))
))))

(deftest ^:integration starter-reconciliation-test
Expand All @@ -137,7 +137,7 @@
(starter/init! admin-client (assoc-in config [:realm :name] realm-name) infra-context {:dry-run? true :apply-deletions? true}))
(testing "realm deletion"
(delete-realm! admin-client realm-name)
(is (thrown? javax.ws.rs.NotFoundException (get-realm admin-client realm-name)))))))
(is (thrown? jakarta.ws.rs.NotFoundException (get-realm admin-client realm-name)))))))

(deftest config-test
(let [environment (sci/new-var 'environment "staging")
Expand Down