|
| 1 | +# class WoocommerceApi::OauthTest < Minitest::Test |
| 2 | +# def setup |
| 3 | +# @oauth = WooCommerce::API.new( |
| 4 | +# "http://dev.test/", |
| 5 | +# "user", |
| 6 | +# "pass" |
| 7 | +# ) |
| 8 | +# end |
| 9 | + |
| 10 | +# def test_oauth_get |
| 11 | +# FakeWeb.register_uri(:get, /http:\/\/dev\.test\/wc-api\/v3\/customers\?oauth_consumer_key=user&oauth_nonce=(.*)&(.*)oauth_signature_method=HMAC-SHA256&oauth_timestamp=(.*)/, |
| 12 | +# body: '{"customers":[]}', |
| 13 | +# content_type: "application/json" |
| 14 | +# ) |
| 15 | +# response = @oauth.get "customers" |
| 16 | + |
| 17 | +# assert_equal 200, response.code |
| 18 | +# end |
| 19 | + |
| 20 | +# def test_oauth_get_puts_data_in_alpha_order |
| 21 | +# FakeWeb.register_uri(:get, /http:\/\/dev\.test\/wc-api\/v3\/customers\?abc=123&oauth_consumer_key=user&oauth_d=456&oauth_nonce=(.*)&(.*)oauth_signature_method=HMAC-SHA256&oauth_timestamp=(.*)&xyz=789/, |
| 22 | +# body: '{"customers":[]}', |
| 23 | +# content_type: "application/json" |
| 24 | +# ) |
| 25 | +# response = @oauth.get "customers", abc: '123', oauth_d: '456', xyz: '789' |
| 26 | + |
| 27 | +# assert_equal 200, response.code |
| 28 | +# end |
| 29 | + |
| 30 | +# def test_oauth_post |
| 31 | +# FakeWeb.register_uri(:post, /http:\/\/dev\.test\/wc-api\/v3\/products\?oauth_consumer_key=user&oauth_nonce=(.*)&(.*)oauth_signature_method=HMAC-SHA256&oauth_timestamp=(.*)/, |
| 32 | +# body: '{"products":[]}', |
| 33 | +# content_type: "application/json", |
| 34 | +# status: ["201", "Created"] |
| 35 | +# ) |
| 36 | + |
| 37 | +# data = { |
| 38 | +# product: { |
| 39 | +# title: "Testing product" |
| 40 | +# } |
| 41 | +# } |
| 42 | +# response = @oauth.post "products", data |
| 43 | + |
| 44 | +# assert_equal 201, response.code |
| 45 | +# end |
| 46 | + |
| 47 | +# def test_oauth_put |
| 48 | +# FakeWeb.register_uri(:put, /http:\/\/dev\.test\/wc-api\/v3\/products\?oauth_consumer_key=user&oauth_nonce=(.*)&(.*)oauth_signature_method=HMAC-SHA256&oauth_timestamp=(.*)/, |
| 49 | +# body: '{"products":[]}', |
| 50 | +# content_type: "application/json" |
| 51 | +# ) |
| 52 | + |
| 53 | +# data = { |
| 54 | +# product: { |
| 55 | +# title: "Updating product title" |
| 56 | +# } |
| 57 | +# } |
| 58 | +# response = @oauth.put "products", data |
| 59 | + |
| 60 | +# assert_equal 200, response.code |
| 61 | +# end |
| 62 | + |
| 63 | +# def test_oauth_put |
| 64 | +# FakeWeb.register_uri(:delete, /http:\/\/dev\.test\/wc-api\/v3\/products\/1234\?force=true&oauth_consumer_key=user&oauth_nonce=(.*)&(.*)oauth_signature_method=HMAC-SHA256&oauth_timestamp=(.*)/, |
| 65 | +# body: '{"message":"Permanently deleted product"}', |
| 66 | +# content_type: "application/json", |
| 67 | +# status: ["202", "Accepted"] |
| 68 | +# ) |
| 69 | + |
| 70 | +# response = @oauth.delete "products/1234?force=true" |
| 71 | + |
| 72 | +# assert_equal 202, response.code |
| 73 | +# assert_equal '{"message":"Permanently deleted product"}', response.to_json |
| 74 | +# end |
| 75 | + |
| 76 | +# def test_adding_query_params |
| 77 | +# url = @oauth.send(:add_query_params, 'foo.com', filter: { sku: '123' }, order: 'created_at') |
| 78 | +# assert_equal url, CGI::escape('foo.com?filter[sku]=123&order=created_at') |
| 79 | +# end |
| 80 | +# end |
0 commit comments