Permalink
Browse files

Merge :form-params and :query-params when calculating signature.

  • Loading branch information...
1 parent 2144a76 commit 224304036ed2bc667fe239a07e604e9bc109202b Roman Scherer committed Oct 25, 2012
Showing with 25 additions and 3 deletions.
  1. +6 −2 src/oauth/v1.clj
  2. +19 −1 test/oauth/test/twitter.clj
View
@@ -16,7 +16,8 @@
"Returns the OAuth header of `request`."
[request]
(-> (merge (util/oauth-params (dissoc request :oauth-consumer-secret :oauth-token-secret))
- (util/oauth-params (:query-params request)))
+ (util/oauth-params (merge (:form-params request)
+ (:query-params request))))
(util/format-authorization)))
(defn oauth-authorize
@@ -28,7 +29,10 @@
[request]
(-> (merge (util/parse-body-params request)
(util/oauth-params (dissoc request :oauth-consumer-secret :oauth-token-secret))
- (transform-keys (:query-params request) name))
+ (transform-keys
+ (merge (:form-params request)
+ (:query-params request))
+ name))
(util/compact-map)))
(defn oauth-parameter-string
@@ -72,9 +72,27 @@
(let [response (meta user)]
(is (= 200 (:status response))))))
-(deftest test-update-status
+(deftest test-update-status-body
(let [status (format "Test %s" (java.util.Date.))
body (str "status=" status)
response (twitter-client {:method :post :url "https://api.twitter.com/1/statuses/update.json" :body body})]
(is (string? (:id-str response)))
(is (= status (:text response)))))
+
+(deftest test-update-status-query-params
+ (let [status (format "Test %s" (java.util.Date.))
+ response (twitter-client
+ {:method :post
+ :url "https://api.twitter.com/1/statuses/update.json"
+ :query-params {:status status}})]
+ (is (string? (:id-str response)))
+ (is (= status (:text response)))))
+
+(deftest test-update-status-form-params
+ (let [status (format "Test %s" (java.util.Date.))
+ response (twitter-client
+ {:method :post
+ :url "https://api.twitter.com/1/statuses/update.json"
+ :form-params {:status status}})]
+ (is (string? (:id-str response)))
+ (is (= status (:text response)))))

0 comments on commit 2243040

Please sign in to comment.