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
4 changes: 2 additions & 2 deletions src/raven_clj/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
[ts key secret]
(->> ["Sentry sentry_version=2.0"
(format "sentry_client=%s" sentry-client)
(format "sentry_timestamp=%s" ts)
(format "sentry_timestamp=%d" ts)
(format "sentry_key=%s" key)
(when secret
(format "sentry_secret=%s" secret))]
Expand Down Expand Up @@ -68,7 +68,7 @@
{:level "error"
:platform "clojure"
:server_name (.getHostName (InetAddress/getLocalHost))
:ts (str (Timestamp. (.getTime (Date.))))}
:ts (.getTime (Date.))}
event-info
{:event_id (generate-uuid)})))

Expand Down
32 changes: 28 additions & 4 deletions test/raven_clj/core_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

(deftest test-make-sentry-header
(testing "sentry header"
(let [ts (str (Timestamp. (.getTime (Date.))))
(let [ts (.getTime (Date.))
key "b70a31b3510c4cf793964a185cfe1fd0"
secret "b7d80b520139450f903720eb7991bf3d"
client-version (version)
Expand All @@ -30,13 +30,30 @@
"includes sentry version")
(is (.contains hdr (str "sentry_client=raven-clj/" client-version))
"includes client version")
(is (.contains hdr (format "sentry_timestamp=%s" ts))
(is (.contains hdr (format "sentry_timestamp=%d" ts))
"includes timestamp")
(is (.contains hdr (str "sentry_key=" key))
"includes key")
(is (.contains hdr (str "sentry_secret=" secret))
"includes secret")
(is (= hdr (format "Sentry sentry_version=2.0, sentry_client=raven-clj/%s, sentry_timestamp=%s, sentry_key=%s, sentry_secret=%s" client-version ts key secret))))))
(is (= hdr (format "Sentry sentry_version=2.0, sentry_client=raven-clj/%s, sentry_timestamp=%d, sentry_key=%s, sentry_secret=%s" client-version ts key secret)))))

(testing "sentry header without secret"
(let [ts (.getTime (Date.))
key "b70a31b3510c4cf793964a185cfe1fd0"
secret nil
client-version (version)
hdr (make-sentry-header ts key secret)]

(is (.contains hdr "sentry_version=2.0")
"includes sentry version")
(is (.contains hdr (str "sentry_client=raven-clj/" client-version))
"includes client version")
(is (.contains hdr (format "sentry_timestamp=%d" ts))
"includes timestamp")
(is (.contains hdr (str "sentry_key=" key))
"includes key")
(is (= hdr (format "Sentry sentry_version=2.0, sentry_client=raven-clj/%s, sentry_timestamp=%d, sentry_key=%s" client-version ts key))))))

(deftest test-send-packet
(testing "send-packet"
Expand All @@ -45,7 +62,7 @@
:secret "secret"
:uri "uri"
:project-id "project-id"
:ts "ts"}]
:ts 123456789}]
(with-redefs [http/post (fn [url opts]
(reset! actual-opts opts))]
(send-packet packet)
Expand All @@ -62,6 +79,13 @@
:uri "https://example.com"
:project-id 1})))

(testing "dsn parsing without secret"
(is (= (parse-dsn "https://[email protected]/1")
{:key "b70a31b3510c4cf793964a185cfe1fd0"
:secret nil
:uri "https://example.com"
:project-id 1})))

(testing "dsn parsing with path"
(is (= (parse-dsn "https://b70a31b3510c4cf793964a185cfe1fd0:[email protected]/sentry/1")
{:key "b70a31b3510c4cf793964a185cfe1fd0"
Expand Down