From 237a8fc974a3db58e1f16d26fe3b46e3ef10a3a9 Mon Sep 17 00:00:00 2001 From: joshuapinter Date: Tue, 29 Oct 2013 16:23:00 -0600 Subject: [PATCH 01/34] Added simple gem install instructions under Getting Started. --- README.markdown | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.markdown b/README.markdown index 5d8dfcb..e0db607 100644 --- a/README.markdown +++ b/README.markdown @@ -46,6 +46,12 @@ Zencoder.base_url = "https://app.zencoder.com/api/v1" ## Getting Started +To install the gem on Rails, simply add it to your Gemfile: + +```ruby +gem "zencoder", "~> 2.0" +``` + The first thing you'll need to interact with the Zencoder API is your API key. You can use your API key in one of three ways. The first and easiest is to set it and forget it on the Zencoder module like so: ```ruby From eeaa1b4fb743c4972daca1c6edd86fde6bb1496c Mon Sep 17 00:00:00 2001 From: Michael Reinsch Date: Thu, 24 Oct 2013 18:15:51 +0900 Subject: [PATCH 02/34] save the request, so it can be inspected in case it fails --- README.markdown | 1 + lib/zencoder/http.rb | 4 ++++ lib/zencoder/http/net_http.rb | 12 ++++++------ lib/zencoder/http/typhoeus.rb | 1 + lib/zencoder/response.rb | 2 +- 5 files changed, 13 insertions(+), 7 deletions(-) diff --git a/README.markdown b/README.markdown index e0db607..bdce6f8 100644 --- a/README.markdown +++ b/README.markdown @@ -79,6 +79,7 @@ response.code # => 200 response.body # => the JSON-parsed body or raw body if unparseable response.raw_body # => the body pre-JSON-parsing response.raw_response # => the raw Net::HTTP or Typhoeus response (see below for how to use Typhoeus) +response.request # => the request object, you can inspect it if you need details on the request to debug it ``` ### Parameters diff --git a/lib/zencoder/http.rb b/lib/zencoder/http.rb index 8de528d..e08428e 100644 --- a/lib/zencoder/http.rb +++ b/lib/zencoder/http.rb @@ -75,11 +75,15 @@ def default_options self.class.default_options end + def inspect + "#{method.to_s.upcase} #{url}\nOptions: " + options.inspect + end protected def process(http_response) response = Response.new + response.request = self response.code = http_response.code begin diff --git a/lib/zencoder/http/net_http.rb b/lib/zencoder/http/net_http.rb index d8555bf..23fa6dc 100644 --- a/lib/zencoder/http/net_http.rb +++ b/lib/zencoder/http/net_http.rb @@ -7,12 +7,12 @@ class NetHTTP def initialize(method, url, options) @method = method @url = url - @body = options.delete(:body) - @params = options.delete(:params) - @headers = options.delete(:headers) - @timeout = options.delete(:timeout) - @skip_ssl_verify = options.delete(:skip_ssl_verify) - @options = options + @options = options.dup + @body = @options.delete(:body) + @params = @options.delete(:params) + @headers = @options.delete(:headers) + @timeout = @options.delete(:timeout) + @skip_ssl_verify = @options.delete(:skip_ssl_verify) end def self.post(url, options={}) diff --git a/lib/zencoder/http/typhoeus.rb b/lib/zencoder/http/typhoeus.rb index 2ae4ae4..5b08324 100644 --- a/lib/zencoder/http/typhoeus.rb +++ b/lib/zencoder/http/typhoeus.rb @@ -19,6 +19,7 @@ def self.delete(url, options={}) end def self.perform(method, url, options={}) + options = options.dup if options.delete(:skip_ssl_verify) options[:disable_ssl_peer_verification] = true end diff --git a/lib/zencoder/response.rb b/lib/zencoder/response.rb index 9edbe99..6c7ef04 100644 --- a/lib/zencoder/response.rb +++ b/lib/zencoder/response.rb @@ -1,7 +1,7 @@ module Zencoder class Response - attr_accessor :code, :body, :raw_body, :raw_response + attr_accessor :request, :code, :body, :raw_body, :raw_response def initialize(options={}) options.each do |k, v| From 63402c714d13f08c39f226215fedf80a52ddd721 Mon Sep 17 00:00:00 2001 From: Adam Kittelson Date: Fri, 3 Jan 2014 12:02:12 -0600 Subject: [PATCH 03/34] ignore zenflow-log --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index ce69a02..a1f9d31 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,5 @@ Gemfile.lock .bundle /zencoder*.gem /tmp -/.rbx \ No newline at end of file +/.rbx +.zenflow-log From ffeb7abc5e17788f011ceacd88d2c5d976a3d54a Mon Sep 17 00:00:00 2001 From: Adam Kittelson Date: Fri, 3 Jan 2014 12:04:07 -0600 Subject: [PATCH 04/34] add zenflow config --- .zenflow | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 .zenflow diff --git a/.zenflow b/.zenflow new file mode 100644 index 0000000..945c90d --- /dev/null +++ b/.zenflow @@ -0,0 +1,11 @@ +--- +project: zencoder-rb +development_branch: master +staging_branch: false +qa_branch: false +release_branch: false +merge_strategy: merge +remote: origin +backup_remote: false +confirm_staging: false +confirm_review: true From 01d155613a3b88cc709169fef2cfb65039d43010 Mon Sep 17 00:00:00 2001 From: Adam Kittelson Date: Fri, 3 Jan 2014 12:08:37 -0600 Subject: [PATCH 05/34] ignore rvm stuff --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index a1f9d31..be9763e 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,5 @@ Gemfile.lock /tmp /.rbx .zenflow-log +.ruby-gemset +.ruby-version From 81a036d7f64848310d003333a140008ad0651cd7 Mon Sep 17 00:00:00 2001 From: Adam Kittelson Date: Fri, 3 Jan 2014 12:26:46 -0600 Subject: [PATCH 06/34] address some warnings --- Gemfile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index 588d1cf..b6c48be 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,7 @@ -source :rubygems +source 'https://rubygems.org' gem "multi_json" +gem "rake" group :test do gem "shoulda" @@ -12,5 +13,6 @@ group :development do gem "jruby-openssl", :platforms => :jruby gem "ruby-debug", :platforms => :mri_18 gem "ruby-debug19", :platforms => :mri_19 - gem "typhoeus", :platforms => [:mri_18, :mri_19] + gem "byebug", :platforms => :mri_20 + gem "typhoeus", :platforms => [:mri_18, :mri_19, :mri_20] end From 1ad607ac28431376539183705f75f0d96d0b417f Mon Sep 17 00:00:00 2001 From: Adam Kittelson Date: Fri, 3 Jan 2014 12:48:54 -0600 Subject: [PATCH 07/34] lock down test dependencies to a version that will actually run the specs --- Gemfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index b6c48be..7523b70 100644 --- a/Gemfile +++ b/Gemfile @@ -4,7 +4,8 @@ gem "multi_json" gem "rake" group :test do - gem "shoulda" + gem "shoulda", "2.11.3" + gem "activesupport", "3.2.16" gem "mocha" gem "webmock", "~>1.6.0" end From 42ae6cec667236822eea88e4093f314554d9e42e Mon Sep 17 00:00:00 2001 From: Adam Kittelson Date: Fri, 3 Jan 2014 12:59:50 -0600 Subject: [PATCH 08/34] update minutes action to work as documented: Zencoder::Report.minutes(:from => "2013-12-27", :to => "2014-01-03") instead of Zencoder::Report.minutes(:params => {:from => "2013-12-27", :to => "2014-01-03"}) --- lib/zencoder/report.rb | 11 ++++++++++- test/zencoder/reports_test.rb | 8 ++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/lib/zencoder/report.rb b/lib/zencoder/report.rb index b10eabf..aff5943 100644 --- a/lib/zencoder/report.rb +++ b/lib/zencoder/report.rb @@ -2,7 +2,16 @@ module Zencoder class Report < Resource def self.minutes(options={}) - get("/reports/minutes", options) + options = options.dup + params = { + :from => options.delete(:from), + :to => options.delete(:to), + :grouping => options.delete(:grouping) + } + + params.delete_if { |k, v| v.nil? } + + get("/reports/minutes", merge_params(options, params)) end end diff --git a/test/zencoder/reports_test.rb b/test/zencoder/reports_test.rb index 991bd86..3ab092d 100644 --- a/test/zencoder/reports_test.rb +++ b/test/zencoder/reports_test.rb @@ -13,16 +13,16 @@ class Zencoder::ReportTest < Test::Unit::TestCase :to => "2011-06-01", :grouping => "foo"}, :headers => { "Zencoder-Api-Key" => @api_key }}).returns(Zencoder::Response.new) - assert_equal Zencoder::Response, Zencoder::Report.minutes(:api_key => @api_key, :params => { :from => "2011-01-01", - :to => "2011-06-01", - :grouping => "foo" }).class + assert_equal Zencoder::Response, Zencoder::Report.minutes(:api_key => @api_key, :from => "2011-01-01", + :to => "2011-06-01", + :grouping => "foo").class end should "merge params well" do Zencoder::HTTP.stubs(:get).with(@url, {:params => { :from => "2011-01-01", :to => "2011-06-01"}, :headers => { "Zencoder-Api-Key" => @api_key }}).returns(Zencoder::Response.new) - assert_equal Zencoder::Response, Zencoder::Report.minutes(:api_key => @api_key, :params => {:from => "2011-01-01", :to => "2011-06-01"}).class + assert_equal Zencoder::Response, Zencoder::Report.minutes(:api_key => @api_key, :from => "2011-01-01", :to => "2011-06-01").class end end From 34a2bd00aa9277345c5ab4d05744e960c9f9152d Mon Sep 17 00:00:00 2001 From: Adam Kittelson Date: Fri, 3 Jan 2014 13:15:15 -0600 Subject: [PATCH 09/34] add .all / .vod / .live reporting api endpoints --- lib/zencoder/report.rb | 23 +++++++++-- test/zencoder/reports_test.rb | 72 +++++++++++++++++++++++++++++++++++ 2 files changed, 92 insertions(+), 3 deletions(-) diff --git a/lib/zencoder/report.rb b/lib/zencoder/report.rb index aff5943..233dad8 100644 --- a/lib/zencoder/report.rb +++ b/lib/zencoder/report.rb @@ -2,6 +2,25 @@ module Zencoder class Report < Resource def self.minutes(options={}) + get("/reports/minutes", merge_params(*extract_params(options))) + end + + def self.all(options={}) + get("/reports/all", merge_params(*extract_params(options))) + end + + def self.live(options={}) + get("/reports/live", merge_params(*extract_params(options))) + end + + def self.vod(options={}) + get("/reports/vod", merge_params(*extract_params(options))) + end + + + protected + + def self.extract_params(options={}) options = options.dup params = { :from => options.delete(:from), @@ -9,9 +28,7 @@ def self.minutes(options={}) :grouping => options.delete(:grouping) } - params.delete_if { |k, v| v.nil? } - - get("/reports/minutes", merge_params(options, params)) + return options, params.delete_if { |k, v| v.nil? } end end diff --git a/test/zencoder/reports_test.rb b/test/zencoder/reports_test.rb index 3ab092d..12a2d58 100644 --- a/test/zencoder/reports_test.rb +++ b/test/zencoder/reports_test.rb @@ -26,4 +26,76 @@ class Zencoder::ReportTest < Test::Unit::TestCase end end + context ".all" do + setup do + @api_key = "abcd123" + @url = "#{Zencoder.base_url}/reports/all" + end + + should "GET the correct url and return a response" do + Zencoder::HTTP.stubs(:get).with(@url, {:params => { :from => "2011-01-01", + :to => "2011-06-01", + :grouping => "foo"}, + :headers => { "Zencoder-Api-Key" => @api_key }}).returns(Zencoder::Response.new) + assert_equal Zencoder::Response, Zencoder::Report.all(:api_key => @api_key, :from => "2011-01-01", + :to => "2011-06-01", + :grouping => "foo").class + end + + should "merge params well" do + Zencoder::HTTP.stubs(:get).with(@url, {:params => { :from => "2011-01-01", + :to => "2011-06-01"}, + :headers => { "Zencoder-Api-Key" => @api_key }}).returns(Zencoder::Response.new) + assert_equal Zencoder::Response, Zencoder::Report.all(:api_key => @api_key, :from => "2011-01-01", :to => "2011-06-01").class + end + end + + context ".vod" do + setup do + @api_key = "abcd123" + @url = "#{Zencoder.base_url}/reports/vod" + end + + should "GET the correct url and return a response" do + Zencoder::HTTP.stubs(:get).with(@url, {:params => { :from => "2011-01-01", + :to => "2011-06-01", + :grouping => "foo"}, + :headers => { "Zencoder-Api-Key" => @api_key }}).returns(Zencoder::Response.new) + assert_equal Zencoder::Response, Zencoder::Report.vod(:api_key => @api_key, :from => "2011-01-01", + :to => "2011-06-01", + :grouping => "foo").class + end + + should "merge params well" do + Zencoder::HTTP.stubs(:get).with(@url, {:params => { :from => "2011-01-01", + :to => "2011-06-01"}, + :headers => { "Zencoder-Api-Key" => @api_key }}).returns(Zencoder::Response.new) + assert_equal Zencoder::Response, Zencoder::Report.vod(:api_key => @api_key, :from => "2011-01-01", :to => "2011-06-01").class + end + end + + context ".live" do + setup do + @api_key = "abcd123" + @url = "#{Zencoder.base_url}/reports/live" + end + + should "GET the correct url and return a response" do + Zencoder::HTTP.stubs(:get).with(@url, {:params => { :from => "2011-01-01", + :to => "2011-06-01", + :grouping => "foo"}, + :headers => { "Zencoder-Api-Key" => @api_key }}).returns(Zencoder::Response.new) + assert_equal Zencoder::Response, Zencoder::Report.live(:api_key => @api_key, :from => "2011-01-01", + :to => "2011-06-01", + :grouping => "foo").class + end + + should "merge params well" do + Zencoder::HTTP.stubs(:get).with(@url, {:params => { :from => "2011-01-01", + :to => "2011-06-01"}, + :headers => { "Zencoder-Api-Key" => @api_key }}).returns(Zencoder::Response.new) + assert_equal Zencoder::Response, Zencoder::Report.live(:api_key => @api_key, :from => "2011-01-01", :to => "2011-06-01").class + end + end + end From f0e9329e925fd3f5cf895b43ebc547ae749925fa Mon Sep 17 00:00:00 2001 From: Adam Kittelson Date: Fri, 3 Jan 2014 13:20:59 -0600 Subject: [PATCH 10/34] update README --- README.markdown | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/README.markdown b/README.markdown index e0db607..a7c464e 100644 --- a/README.markdown +++ b/README.markdown @@ -35,6 +35,9 @@ With the release of version two of the Zencoder API, there are some new methods * Zencoder::Input.progress(input\_id) * Zencoder::Output.details(output\_id) * Zencoder::Report.minutes(:from => "2011-01-01", :to => "2011-03-01") +* Zencoder::Report.all(:from => "2011-01-01", :to => "2011-03-01") +* Zencoder::Report.live(:from => "2011-01-01", :to => "2011-03-01") +* Zencoder::Report.vod(:from => "2011-01-01", :to => "2011-03-01") These new methods will not work with older versions of the API. Please see the [Zencoder documentation](https://app.zencoder.com/docs) and our [blog post on the subject](http://blog.zencoder.com/2012/01/05/announcing-zencoder-api-v2/) for more information on APIv2. @@ -279,6 +282,30 @@ This will list the minutes used for your account within a certain, configurable Zencoder::Report.minutes(:from => "2011-10-30", :to => "2011-11-24") ``` +### all + +This will list all usage, including VOD and Live for your account within a certain, configurable range. + +```ruby +Zencoder::Report.all(:from => "2011-10-30", :to => "2011-11-24") +``` + +### vod + +This will list just VOD usage for your account within a certain, configurable range. + +```ruby +Zencoder::Report.vod(:from => "2011-10-30", :to => "2011-11-24") +``` + +### live + +This will list just Live usage for your account within a certain, configurable range. + +```ruby +Zencoder::Report.live(:from => "2011-10-30", :to => "2011-11-24") +``` + ## Advanced HTTP ### Alternate HTTP Libraries From 277fa6affceeaccaa708c251e759d6ddd58b129f Mon Sep 17 00:00:00 2001 From: Adam Kittelson Date: Fri, 3 Jan 2014 13:32:55 -0600 Subject: [PATCH 11/34] add Ruby 2.0.0-p353 to tested versions --- README.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/README.markdown b/README.markdown index a7c464e..2c1c77a 100644 --- a/README.markdown +++ b/README.markdown @@ -11,6 +11,7 @@ Tested on the following versions of Ruby: * Ruby 1.8.7-p352 * Ruby 1.9.2-p290 * Ruby 1.9.3-p0 +* Ruby 2.0.0-p353 * Rubinius 2.0.0dev * jRuby 1.6.5 From 57bb2fd842b8ed683f7b939fcc956cf21627c74f Mon Sep 17 00:00:00 2001 From: Adam Kittelson Date: Fri, 3 Jan 2014 13:43:00 -0600 Subject: [PATCH 12/34] version bump --- lib/zencoder/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/zencoder/version.rb b/lib/zencoder/version.rb index 8e73603..173bce6 100644 --- a/lib/zencoder/version.rb +++ b/lib/zencoder/version.rb @@ -1,3 +1,3 @@ module Zencoder - GEM_VERSION = '2.4.4' + GEM_VERSION = '2.4.5' end From 570d1a212dd4aea3d1ef2f054a116822dcfbb139 Mon Sep 17 00:00:00 2001 From: Pedro Coelho Date: Thu, 3 Apr 2014 00:39:26 +0100 Subject: [PATCH 13/34] Adding the finish method to Job so it can finish live streaming jobs --- lib/zencoder/job.rb | 4 ++++ test/zencoder/job_test.rb | 12 ++++++++++++ 2 files changed, 16 insertions(+) diff --git a/lib/zencoder/job.rb b/lib/zencoder/job.rb index c72169d..43076b8 100644 --- a/lib/zencoder/job.rb +++ b/lib/zencoder/job.rb @@ -30,5 +30,9 @@ def self.cancel(job_id, options={}) put("/jobs/#{job_id}/cancel", nil, options) end + def self.finish(job_id, options={}) + put("/jobs/#{job_id}/finish", nil, options) + end + end end diff --git a/test/zencoder/job_test.rb b/test/zencoder/job_test.rb index f323c83..1f704e8 100644 --- a/test/zencoder/job_test.rb +++ b/test/zencoder/job_test.rb @@ -101,5 +101,17 @@ class Zencoder::JobTest < Test::Unit::TestCase end end + context ".finish" do + setup do + @job_id = 1 + @url = "#{Zencoder.base_url}/jobs/#{@job_id}/finish" + end + + should "PUT the correct url and return a response" do + Zencoder::HTTP.stubs(:put).with(@url, nil, :headers => {"Zencoder-Api-Key" => @api_key}).returns(Zencoder::Response.new) + assert_equal Zencoder::Response, Zencoder::Job.finish(1, :api_key => @api_key).class + end + end + end end From 76d18fc9b2cb833e7f4d3f0fcd1ad1c9c2920b97 Mon Sep 17 00:00:00 2001 From: Nathan Sutton Date: Wed, 2 Apr 2014 16:48:31 -0700 Subject: [PATCH 14/34] Bumping the version to 2.4.6. --- lib/zencoder/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/zencoder/version.rb b/lib/zencoder/version.rb index 173bce6..c0f7325 100644 --- a/lib/zencoder/version.rb +++ b/lib/zencoder/version.rb @@ -1,3 +1,3 @@ module Zencoder - GEM_VERSION = '2.4.5' + GEM_VERSION = '2.4.6' end From 9853448033a8cb6e9f4f0a7ca9d5bf1ec7078aff Mon Sep 17 00:00:00 2001 From: Nathan Sutton Date: Wed, 2 Apr 2014 16:50:57 -0700 Subject: [PATCH 15/34] Get rid of unused rdoc and rcov tasks --- Rakefile | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/Rakefile b/Rakefile index 406fe18..ab875f7 100644 --- a/Rakefile +++ b/Rakefile @@ -9,28 +9,3 @@ Rake::TestTask.new(:test) do |test| end task :default => :test - -require 'rdoc/task' - -Rake::RDocTask.new do |rdoc| - version = File.exist?('VERSION') ? File.read('VERSION') : "" - - rdoc.rdoc_dir = 'rdoc' - rdoc.title = "zencoder-rb #{version}" - rdoc.rdoc_files.include('README*') - rdoc.rdoc_files.include('lib/**/*.rb') -end - -begin - require 'rcov/rcovtask' - Rcov::RcovTask.new do |test| - test.libs << 'test' - test.pattern = 'test/**/*_test.rb' - test.verbose = true - test.rcov_opts << '--exclude "gems/*"' - end -rescue LoadError - task :rcov do - abort "RCov is not available. In order to run rcov, you must: sudo gem install rcov" - end -end From 0a0fe232a217fbc4880d7e857420410e201d6454 Mon Sep 17 00:00:00 2001 From: Nathan Sutton Date: Wed, 23 Jul 2014 16:11:25 -0500 Subject: [PATCH 16/34] Removing the bundling of the zencoder ca chain and allow users to specify cert paths --- lib/zencoder/http.rb | 2 - lib/zencoder/http/net_http.rb | 9 ++- .../http/resources/zencoder_ca_chain.crt | 62 ------------------- lib/zencoder/http/typhoeus.rb | 8 +++ test/zencoder/http/net_http_test.rb | 19 +++++- test/zencoder/http/typhoeus_test.rb | 10 +++ 6 files changed, 40 insertions(+), 70 deletions(-) delete mode 100644 lib/zencoder/http/resources/zencoder_ca_chain.crt diff --git a/lib/zencoder/http.rb b/lib/zencoder/http.rb index e08428e..e3007e4 100644 --- a/lib/zencoder/http.rb +++ b/lib/zencoder/http.rb @@ -1,8 +1,6 @@ module Zencoder class HTTP - CA_CHAIN_PATH = File.expand_path(File.join(File.dirname(__FILE__), "http", "resources", "zencoder_ca_chain.crt")) - include Zencoder::Serializer attr_accessor :url, :options, :method diff --git a/lib/zencoder/http/net_http.rb b/lib/zencoder/http/net_http.rb index 23fa6dc..b02dd0a 100644 --- a/lib/zencoder/http/net_http.rb +++ b/lib/zencoder/http/net_http.rb @@ -2,7 +2,7 @@ module Zencoder class HTTP class NetHTTP - attr_accessor :method, :url, :uri, :body, :params, :headers, :timeout, :skip_ssl_verify, :options + attr_accessor :method, :url, :uri, :body, :params, :headers, :timeout, :skip_ssl_verify, :options, :ca_file, :ca_path def initialize(method, url, options) @method = method @@ -13,6 +13,8 @@ def initialize(method, url, options) @headers = @options.delete(:headers) @timeout = @options.delete(:timeout) @skip_ssl_verify = @options.delete(:skip_ssl_verify) + @ca_file = @options.delete(:ca_file) + @ca_path = @options.delete(:ca_path) end def self.post(url, options={}) @@ -59,10 +61,11 @@ def http if skip_ssl_verify http.verify_mode = OpenSSL::SSL::VERIFY_NONE else - http.ca_file = Zencoder::HTTP::CA_CHAIN_PATH http.verify_mode = OpenSSL::SSL::VERIFY_PEER - http.verify_depth = 5 end + + http.ca_file = ca_file if ca_file + http.ca_path = ca_path if ca_path end http diff --git a/lib/zencoder/http/resources/zencoder_ca_chain.crt b/lib/zencoder/http/resources/zencoder_ca_chain.crt deleted file mode 100644 index e0de7e6..0000000 --- a/lib/zencoder/http/resources/zencoder_ca_chain.crt +++ /dev/null @@ -1,62 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDJzCCApCgAwIBAgIBATANBgkqhkiG9w0BAQQFADCBzjELMAkGA1UEBhMCWkEx -FTATBgNVBAgTDFdlc3Rlcm4gQ2FwZTESMBAGA1UEBxMJQ2FwZSBUb3duMR0wGwYD -VQQKExRUaGF3dGUgQ29uc3VsdGluZyBjYzEoMCYGA1UECxMfQ2VydGlmaWNhdGlv -biBTZXJ2aWNlcyBEaXZpc2lvbjEhMB8GA1UEAxMYVGhhd3RlIFByZW1pdW0gU2Vy -dmVyIENBMSgwJgYJKoZIhvcNAQkBFhlwcmVtaXVtLXNlcnZlckB0aGF3dGUuY29t -MB4XDTk2MDgwMTAwMDAwMFoXDTIwMTIzMTIzNTk1OVowgc4xCzAJBgNVBAYTAlpB -MRUwEwYDVQQIEwxXZXN0ZXJuIENhcGUxEjAQBgNVBAcTCUNhcGUgVG93bjEdMBsG -A1UEChMUVGhhd3RlIENvbnN1bHRpbmcgY2MxKDAmBgNVBAsTH0NlcnRpZmljYXRp -b24gU2VydmljZXMgRGl2aXNpb24xITAfBgNVBAMTGFRoYXd0ZSBQcmVtaXVtIFNl -cnZlciBDQTEoMCYGCSqGSIb3DQEJARYZcHJlbWl1bS1zZXJ2ZXJAdGhhd3RlLmNv -bTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA0jY2aovXwlue2oFBYo847kkE -VdbQ7xwblRZH7xhINTpS9CtqBo87L+pW46+GjZ4X9560ZXUCTe/LCaIhUdib0GfQ -ug2SBhRz1JPLlyoAnFxODLz6FVL88kRu2hFKbgifLy3j+ao6hnO2RlNYyIkFvYMR -uHM/qgeN9EJN50CdHDcCAwEAAaMTMBEwDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG -9w0BAQQFAAOBgQAmSCwWwlj66BZ0DKqqX1Q/8tfJeGBeXm43YyJ3Nn6yF8Q0ufUI -hfzJATj/Tb7yFkJD57taRvvBxhEf8UqwKEbJw8RCfbz6q1lu1bdRiBHjpIUZa4JM -pAwSremkrj/xw0llmozFyD4lt5SZu5IycQfwhl7tUCemDaYj+bvLpgcUQg== ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIE2DCCBEGgAwIBAgIEN0rSQzANBgkqhkiG9w0BAQUFADCBwzELMAkGA1UEBhMC -VVMxFDASBgNVBAoTC0VudHJ1c3QubmV0MTswOQYDVQQLEzJ3d3cuZW50cnVzdC5u -ZXQvQ1BTIGluY29ycC4gYnkgcmVmLiAobGltaXRzIGxpYWIuKTElMCMGA1UECxMc -KGMpIDE5OTkgRW50cnVzdC5uZXQgTGltaXRlZDE6MDgGA1UEAxMxRW50cnVzdC5u -ZXQgU2VjdXJlIFNlcnZlciBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw05OTA1 -MjUxNjA5NDBaFw0xOTA1MjUxNjM5NDBaMIHDMQswCQYDVQQGEwJVUzEUMBIGA1UE -ChMLRW50cnVzdC5uZXQxOzA5BgNVBAsTMnd3dy5lbnRydXN0Lm5ldC9DUFMgaW5j -b3JwLiBieSByZWYuIChsaW1pdHMgbGlhYi4pMSUwIwYDVQQLExwoYykgMTk5OSBF -bnRydXN0Lm5ldCBMaW1pdGVkMTowOAYDVQQDEzFFbnRydXN0Lm5ldCBTZWN1cmUg -U2VydmVyIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIGdMA0GCSqGSIb3DQEBAQUA -A4GLADCBhwKBgQDNKIM0VBuJ8w+vN5Ex/68xYMmo6LIQaO2f55M28Qpku0f1BBc/ -I0dNxScZgSYMVHINiC3ZH5oSn7yzcdOAGT9HZnuMNSjSuQrfJNqc1lB5gXpa0zf3 -wkrYKZImZNHkmGw6AIr1NJtl+O3jEP/9uElY3KDegjlrgbEWGWG5VLbmQwIBA6OC -AdcwggHTMBEGCWCGSAGG+EIBAQQEAwIABzCCARkGA1UdHwSCARAwggEMMIHeoIHb -oIHYpIHVMIHSMQswCQYDVQQGEwJVUzEUMBIGA1UEChMLRW50cnVzdC5uZXQxOzA5 -BgNVBAsTMnd3dy5lbnRydXN0Lm5ldC9DUFMgaW5jb3JwLiBieSByZWYuIChsaW1p -dHMgbGlhYi4pMSUwIwYDVQQLExwoYykgMTk5OSBFbnRydXN0Lm5ldCBMaW1pdGVk -MTowOAYDVQQDEzFFbnRydXN0Lm5ldCBTZWN1cmUgU2VydmVyIENlcnRpZmljYXRp -b24gQXV0aG9yaXR5MQ0wCwYDVQQDEwRDUkwxMCmgJ6AlhiNodHRwOi8vd3d3LmVu -dHJ1c3QubmV0L0NSTC9uZXQxLmNybDArBgNVHRAEJDAigA8xOTk5MDUyNTE2MDk0 -MFqBDzIwMTkwNTI1MTYwOTQwWjALBgNVHQ8EBAMCAQYwHwYDVR0jBBgwFoAU8Bdi -E1U9s/8KAGv7UISX8+1i0BowHQYDVR0OBBYEFPAXYhNVPbP/CgBr+1CEl/PtYtAa -MAwGA1UdEwQFMAMBAf8wGQYJKoZIhvZ9B0EABAwwChsEVjQuMAMCBJAwDQYJKoZI -hvcNAQEFBQADgYEAkNwwAvpkdMKnCqV8IY00F6j7Rw7/JXyNEwr75Ji174z4xRAN -95K+8cPV1ZVqBLssziY2ZcgxxufuP+NXdYR6Ee9GTxj005i7qIcyunL2POI9n9cd -2cNgQ4xYDiKWL2KjLB+6rQXvqzJ4h6BUcxm1XAX5Uj5tLUUL9wqT6u0G+bI= ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIICWjCCAcMCAgGlMA0GCSqGSIb3DQEBBAUAMHUxCzAJBgNVBAYTAlVTMRgwFgYD -VQQKEw9HVEUgQ29ycG9yYXRpb24xJzAlBgNVBAsTHkdURSBDeWJlclRydXN0IFNv -bHV0aW9ucywgSW5jLjEjMCEGA1UEAxMaR1RFIEN5YmVyVHJ1c3QgR2xvYmFsIFJv -b3QwHhcNOTgwODEzMDAyOTAwWhcNMTgwODEzMjM1OTAwWjB1MQswCQYDVQQGEwJV -UzEYMBYGA1UEChMPR1RFIENvcnBvcmF0aW9uMScwJQYDVQQLEx5HVEUgQ3liZXJU -cnVzdCBTb2x1dGlvbnMsIEluYy4xIzAhBgNVBAMTGkdURSBDeWJlclRydXN0IEds -b2JhbCBSb290MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCVD6C28FCc6HrH -iM3dFw4usJTQGz0O9pTAipTHBsiQl8i4ZBp6fmw8U+E3KHNgf7KXUwefU/ltWJTS -r41tiGeA5u2ylc9yMcqlHHK6XALnZELn+aks1joNrI1CqiQBOeacPwGFVw1Yh0X4 -04Wqk2kmhXBIgD8SFcd5tB8FLztimQIDAQABMA0GCSqGSIb3DQEBBAUAA4GBAG3r -GwnpXtlR22ciYaQqPEh346B8pt5zohQDhT37qw4wxYMWM4ETCJ57NE7fQMh017l9 -3PR2VX2bY1QY6fDq81yx2YtCHrnAlU66+tXifPVoYb+O7AWXX1uw16OFNMQkpw0P -lZPvy5TYnh+dXIVtx6quTx8itc2VrbqnzPmrC3p/ ------END CERTIFICATE----- \ No newline at end of file diff --git a/lib/zencoder/http/typhoeus.rb b/lib/zencoder/http/typhoeus.rb index 5b08324..667687e 100644 --- a/lib/zencoder/http/typhoeus.rb +++ b/lib/zencoder/http/typhoeus.rb @@ -24,6 +24,14 @@ def self.perform(method, url, options={}) options[:disable_ssl_peer_verification] = true end + if ca_file = options.delete(:ca_file) + options[:sslcert] = ca_file + end + + if ca_path = options.delete(:ca_path) + options[:capath] = ca_path + end + ::Typhoeus::Request.send(method, url, options) end diff --git a/test/zencoder/http/net_http_test.rb b/test/zencoder/http/net_http_test.rb index 2edc230..cd843e4 100644 --- a/test/zencoder/http/net_http_test.rb +++ b/test/zencoder/http/net_http_test.rb @@ -41,12 +41,25 @@ class Zencoder::HTTP::NetHTTPTest < Test::Unit::TestCase end context "SSL verification" do + setup do + @http_stub = stub(:use_ssl= => true, :request => true, :verify_mode= => true) + ::Net::HTTP.expects(:new).returns(@http_stub) + end + should "not verify when set to skip ssl verification" do - http_stub = stub(:use_ssl= => true, :request => true) - http_stub.expects(:verify_mode=).with(OpenSSL::SSL::VERIFY_NONE) - ::Net::HTTP.expects(:new).returns(http_stub) + @http_stub.expects(:verify_mode=).with(OpenSSL::SSL::VERIFY_NONE) Zencoder::HTTP::NetHTTP.post('https://example.com/path', :skip_ssl_verify => true) end + + should "set the ca_file" do + @http_stub.expects(:ca_file=).with("/foo/bar/baz.crt") + Zencoder::HTTP::NetHTTP.post('https://example.com/path', :ca_file => "/foo/bar/baz.crt") + end + + should "set the ca_path" do + @http_stub.expects(:ca_path=).with("/foo/bar/") + Zencoder::HTTP::NetHTTP.post('https://example.com/path', :ca_path => "/foo/bar/") + end end context ".post" do diff --git a/test/zencoder/http/typhoeus_test.rb b/test/zencoder/http/typhoeus_test.rb index 9fa9005..c4a43d8 100644 --- a/test/zencoder/http/typhoeus_test.rb +++ b/test/zencoder/http/typhoeus_test.rb @@ -44,6 +44,16 @@ module Request Typhoeus::Request.expects(:get).with('https://example.com', {:disable_ssl_peer_verification => true}) Zencoder::HTTP::Typhoeus.get('https://example.com', {:skip_ssl_verify => true}) end + + should "use the path to the cert file" do + Typhoeus::Request.expects(:get).with('https://example.com', {:disable_ssl_peer_verification => true, :sslcert => "/foo/bar/baz.crt"}) + Zencoder::HTTP::Typhoeus.get('https://example.com', {:skip_ssl_verify => true, :ca_file => "/foo/bar/baz.crt"}) + end + + should "use the path to the certs directory" do + Typhoeus::Request.expects(:get).with('https://example.com', {:disable_ssl_peer_verification => true, :capath => "/foo/bar/baz.crt"}) + Zencoder::HTTP::Typhoeus.get('https://example.com', {:skip_ssl_verify => true, :ca_path => "/foo/bar/baz.crt"}) + end end end From 534cb596f8dce671e54819fd390fff04a5981643 Mon Sep 17 00:00:00 2001 From: Nathan Sutton Date: Wed, 23 Jul 2014 16:12:05 -0500 Subject: [PATCH 17/34] Bumping the version to 2.5.0 --- lib/zencoder/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/zencoder/version.rb b/lib/zencoder/version.rb index c0f7325..0466240 100644 --- a/lib/zencoder/version.rb +++ b/lib/zencoder/version.rb @@ -1,3 +1,3 @@ module Zencoder - GEM_VERSION = '2.4.6' + GEM_VERSION = '2.5.0' end From c67f7860abc84b842cb4d2a3c2d83f03494298c6 Mon Sep 17 00:00:00 2001 From: Nathan Sutton Date: Wed, 23 Jul 2014 16:21:44 -0500 Subject: [PATCH 18/34] Update the documentation to reflect the ssl cert bundling change. --- README.markdown | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/README.markdown b/README.markdown index 13877ca..1e7d34b 100644 --- a/README.markdown +++ b/README.markdown @@ -15,6 +15,12 @@ Tested on the following versions of Ruby: * Rubinius 2.0.0dev * jRuby 1.6.5 +## 2.5 WARNING!!! + +Version 2.5 brings a single, significant change to the gem which you should be aware of: + +* __The Zencoder SSL CA chain is no longer bundled.__ Our cert is expiring and the necessary file may change in the future. You can now specify the CA file or CA path along with the request. + ## v2.4 WARNING!!! Version 2.4 brings some significant changes to the gem, ones which you should be aware of: @@ -335,7 +341,25 @@ Zencoder::Job.create({:input => 's3://bucket/key.mp4'}, {:timeout => 1000}) ### SSL Verification -We will use our bundled SSL CA chain for SSL peer verification which should almost always work without a hitch. However, if you'd like to skip SSL verification you can pass an option in the secondary options hash. +SSL verification using the default Net::HTTP backend requires that your ruby be appropriately configured with up to date path to a cert bundle on your system or by specifying the a CA file or CA path when sending requests. + +```ruby +Zencoder::Job.create({:input => 's3://bucket/key.mp4'}, {:ca_path => "/path/to/certs/"}) +# or +Zencoder::Job.create({:input => 's3://bucket/key.mp4'}, {:ca_file => "/path/to/certs/zen.crt"}) +``` + +Alternatively you can add it to the default options. + +```ruby +Zencoder::HTTP.default_options.merge!(:ca_path => "/path/to/certs/") +# or +Zencoder::HTTP.default_options.merge!(:ca_file => "/path/to/certs/zen.crt") +``` + +You can get a CA bundle from [the curl website](http://curl.haxx.se/docs/caextract.html), but it is recommended that you use your system's package manager to install these certs and keep them up to date. + +However, if you'd like to skip SSL verification you can pass an option in the secondary options hash. **NOTE: WE HIGHLY DISCOURAGE THIS! THIS WILL LEAVE YOU VULNERABLE TO MAN-IN-THE-MIDDLE ATTACKS!** From beed837db7711a94e32a0e82fe45d52e8c5e75cd Mon Sep 17 00:00:00 2001 From: Nathan Sutton Date: Thu, 24 Jul 2014 13:45:04 -0500 Subject: [PATCH 19/34] Added a note about Mislav's excellent post on ruby and SSL --- README.markdown | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.markdown b/README.markdown index 1e7d34b..e075aab 100644 --- a/README.markdown +++ b/README.markdown @@ -19,7 +19,9 @@ Tested on the following versions of Ruby: Version 2.5 brings a single, significant change to the gem which you should be aware of: -* __The Zencoder SSL CA chain is no longer bundled.__ Our cert is expiring and the necessary file may change in the future. You can now specify the CA file or CA path along with the request. +* __The Zencoder SSL CA chain is no longer bundled.__ Our intermediate SSL cert is expiring and the necessary file may change in the future. You can now specify the CA file or CA path along with the request. + +[We recommend installing a CA bundle (probably cURL's) in your OS and have ruby use that.](http://mislav.uniqpath.com/2013/07/ruby-openssl/) ## v2.4 WARNING!!! From 925b58de8bfff26896a829bf7f3171d2c42a2d0d Mon Sep 17 00:00:00 2001 From: Chris Warren Date: Thu, 24 Jul 2014 11:47:00 -0700 Subject: [PATCH 20/34] Update Readme to include password_confirmation Account creation requires password_confirmation be sent if password is. Updating docs to reflect this. --- README.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/README.markdown b/README.markdown index e075aab..ad5c3b2 100644 --- a/README.markdown +++ b/README.markdown @@ -254,6 +254,7 @@ Zencoder::Account.create({:terms_of_service => 1, Zencoder::Account.create({:terms_of_service => 1, :email => 'bob@example.com', :password => 'abcd1234', + :password_confirmation => 'abcd1234', :affiliate_code => 'abcd1234'}) ``` From 09b97434cabf907c5ab532ed18c6c86d2654cd20 Mon Sep 17 00:00:00 2001 From: Nathan Sutton Date: Thu, 31 Jul 2014 15:30:08 -0500 Subject: [PATCH 21/34] Setup a cert store for https connections so we can set the default paths --- lib/zencoder/http/net_http.rb | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/zencoder/http/net_http.rb b/lib/zencoder/http/net_http.rb index b02dd0a..df4d421 100644 --- a/lib/zencoder/http/net_http.rb +++ b/lib/zencoder/http/net_http.rb @@ -62,10 +62,17 @@ def http http.verify_mode = OpenSSL::SSL::VERIFY_NONE else http.verify_mode = OpenSSL::SSL::VERIFY_PEER - end - http.ca_file = ca_file if ca_file - http.ca_path = ca_path if ca_path + http.cert_store = OpenSSL::X509::Store.new + http.cert_store.set_default_paths + + if defined?(OpenSSL::X509::V_FLAG_CRL_CHECK_ALL) + http.cert_store.flags = OpenSSL::X509::V_FLAG_CRL_CHECK_ALL + end + + http.cert_store.add_file(ca_file) if ca_file + http.cert_store.add_path(ca_path) if ca_path + end end http From 24b5f16c5fe9c8e6792df7103715b7875baf7de7 Mon Sep 17 00:00:00 2001 From: Nathan Sutton Date: Thu, 31 Jul 2014 15:49:32 -0500 Subject: [PATCH 22/34] Test the custom cert store for the net/http adapter --- test/test_helper.rb | 9 +++++- test/zencoder/http/net_http_test.rb | 43 +++++++++++++++++++++-------- 2 files changed, 40 insertions(+), 12 deletions(-) diff --git a/test/test_helper.rb b/test/test_helper.rb index de6ce0c..0d065bc 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -2,7 +2,14 @@ require 'bundler' Bundler.setup Bundler.require(:default, :test) -require 'mocha/integration/test_unit' # Bundler load-order hax + +begin + require "minitest/unit" + require "mocha/mini_test" +rescue LoadError + require "test/unit" + require "mocha/test_unit" +end $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) $LOAD_PATH.unshift(File.dirname(__FILE__)) diff --git a/test/zencoder/http/net_http_test.rb b/test/zencoder/http/net_http_test.rb index cd843e4..ff617cd 100644 --- a/test/zencoder/http/net_http_test.rb +++ b/test/zencoder/http/net_http_test.rb @@ -42,24 +42,45 @@ class Zencoder::HTTP::NetHTTPTest < Test::Unit::TestCase context "SSL verification" do setup do - @http_stub = stub(:use_ssl= => true, :request => true, :verify_mode= => true) + @cert_store = stub(:add_file => true, :add_path => true, :flags= => true, :set_default_paths => true) + @http_stub = stub(:use_ssl= => true, :request => true, :verify_mode= => true, :cert_store= => true, :cert_store => @cert_store) ::Net::HTTP.expects(:new).returns(@http_stub) end - should "not verify when set to skip ssl verification" do - @http_stub.expects(:verify_mode=).with(OpenSSL::SSL::VERIFY_NONE) - Zencoder::HTTP::NetHTTP.post('https://example.com/path', :skip_ssl_verify => true) - end + context "when set to skip ssl verification" do + should "not verify" do + @http_stub.expects(:verify_mode=).with(OpenSSL::SSL::VERIFY_NONE) + Zencoder::HTTP::NetHTTP.post('https://example.com/path', :skip_ssl_verify => true) + end - should "set the ca_file" do - @http_stub.expects(:ca_file=).with("/foo/bar/baz.crt") - Zencoder::HTTP::NetHTTP.post('https://example.com/path', :ca_file => "/foo/bar/baz.crt") + should "not setup a custom cert store" do + @http_stub.expects(:cert_store=).never + Zencoder::HTTP::NetHTTP.post('https://example.com/path', :skip_ssl_verify => true) + end end - should "set the ca_path" do - @http_stub.expects(:ca_path=).with("/foo/bar/") - Zencoder::HTTP::NetHTTP.post('https://example.com/path', :ca_path => "/foo/bar/") + context "when set to do ssl verification" do + should "setup a custom cert store" do + @http_stub.expects(:cert_store=) + Zencoder::HTTP::NetHTTP.post('https://example.com/path') + end + + should "set the default paths on the custom cert store" do + @cert_store.expects(:set_default_paths) + Zencoder::HTTP::NetHTTP.post('https://example.com/path') + end + + should "set the ca_file when it is passed in" do + @cert_store.expects(:add_file).with("/foo/bar/baz.crt") + Zencoder::HTTP::NetHTTP.post('https://example.com/path', :ca_file => "/foo/bar/baz.crt") + end + + should "set the ca_path when it is passed in" do + @cert_store.expects(:add_path).with("/foo/bar/") + Zencoder::HTTP::NetHTTP.post('https://example.com/path', :ca_path => "/foo/bar/") + end end + end context ".post" do From c02b1cddf37e163aedea9d64c720991ad1b2fd0e Mon Sep 17 00:00:00 2001 From: Nathan Sutton Date: Fri, 1 Aug 2014 11:14:50 -0500 Subject: [PATCH 23/34] Adding .travis.yml --- .travis.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..4f45eb5 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,15 @@ +language: ruby +rvm: + - 2.1 + - 2.0 + - 1.9.3 + - 1.9.2 + - jruby-18mode + - jruby-19mode + - rbx-2.0.0 + - rbx-2.1.1 + - rbx-2.2.5 + - ruby-head + - jruby-head + - 1.8.7 + - ree From 8251b853317f2fd27141418093f614c6bc0dc8ee Mon Sep 17 00:00:00 2001 From: Nathan Sutton Date: Fri, 1 Aug 2014 11:19:37 -0500 Subject: [PATCH 24/34] Adding travis-ci badge --- README.markdown | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.markdown b/README.markdown index ad5c3b2..a03c73a 100644 --- a/README.markdown +++ b/README.markdown @@ -1,5 +1,7 @@ # Zencoder +[![Build Status](https://travis-ci.org/zencoder/zencoder-rb.svg?branch=master)](https://travis-ci.org/zencoder/zencoder-rb) + The gem for interacting with the API on [Zencoder](http://zencoder.com). See [http://zencoder.com/docs/api](http://zencoder.com/docs/api) for more details on the API. From 6f1f6fb8071f3e9d2a1997f2bbc9e6bf69b0fb2d Mon Sep 17 00:00:00 2001 From: Nathan Sutton Date: Fri, 1 Aug 2014 11:32:58 -0500 Subject: [PATCH 25/34] Removing 1.9.2 because you shouldn't use it anyways and nothing builds on it --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 4f45eb5..d647e25 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,6 @@ rvm: - 2.1 - 2.0 - 1.9.3 - - 1.9.2 - jruby-18mode - jruby-19mode - rbx-2.0.0 From 4b01b367dfa2b583918f44fc6e8a42a672528dba Mon Sep 17 00:00:00 2001 From: Nathan Sutton Date: Fri, 1 Aug 2014 11:36:36 -0500 Subject: [PATCH 26/34] Getting rid of ruby-head and jruby head because we don't support those --- .travis.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index d647e25..72ccd69 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,5 @@ rvm: - rbx-2.0.0 - rbx-2.1.1 - rbx-2.2.5 - - ruby-head - - jruby-head - 1.8.7 - ree From ce930fb41adcdb4aad2938c21a12830a53247b28 Mon Sep 17 00:00:00 2001 From: Nathan Sutton Date: Fri, 1 Aug 2014 12:13:35 -0500 Subject: [PATCH 27/34] Removing junk gems --- Gemfile | 9 ++++----- zencoder.gemspec | 3 --- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/Gemfile b/Gemfile index 7523b70..379c8da 100644 --- a/Gemfile +++ b/Gemfile @@ -1,19 +1,18 @@ source 'https://rubygems.org' gem "multi_json" -gem "rake" group :test do gem "shoulda", "2.11.3" - gem "activesupport", "3.2.16" gem "mocha" gem "webmock", "~>1.6.0" end group :development do gem "jruby-openssl", :platforms => :jruby - gem "ruby-debug", :platforms => :mri_18 - gem "ruby-debug19", :platforms => :mri_19 - gem "byebug", :platforms => :mri_20 gem "typhoeus", :platforms => [:mri_18, :mri_19, :mri_20] end + +group :test, :development do + gem "rake" +end \ No newline at end of file diff --git a/zencoder.gemspec b/zencoder.gemspec index 703fb29..a1e32ec 100644 --- a/zencoder.gemspec +++ b/zencoder.gemspec @@ -15,9 +15,6 @@ Gem::Specification.new do |s| s.description = "Zencoder integration library." s.rubyforge_project = "zencoder" s.add_dependency "multi_json" - s.add_development_dependency "shoulda" - s.add_development_dependency "mocha" - s.add_development_dependency "webmock" s.files = Dir.glob("bin/**/*") + Dir.glob("lib/**/*") + %w(LICENSE README.markdown Rakefile) s.require_path = "lib" end From 79cae19b1f35fea560db9d22e5032de98aa0f325 Mon Sep 17 00:00:00 2001 From: Nathan Sutton Date: Fri, 1 Aug 2014 12:14:55 -0500 Subject: [PATCH 28/34] Adding typhoeus for ruby 2.1 --- Gemfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index 379c8da..10ed641 100644 --- a/Gemfile +++ b/Gemfile @@ -10,9 +10,9 @@ end group :development do gem "jruby-openssl", :platforms => :jruby - gem "typhoeus", :platforms => [:mri_18, :mri_19, :mri_20] + gem "typhoeus", :platforms => [:mri_18, :mri_19, :mri_20, :mri_21] end group :test, :development do gem "rake" -end \ No newline at end of file +end From 9c55396e5f2279fda70993e316e7d6036048abad Mon Sep 17 00:00:00 2001 From: Nathan Sutton Date: Fri, 1 Aug 2014 13:01:21 -0500 Subject: [PATCH 29/34] Bumping the version to 2.5.1 --- lib/zencoder/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/zencoder/version.rb b/lib/zencoder/version.rb index 0466240..b0ca1e5 100644 --- a/lib/zencoder/version.rb +++ b/lib/zencoder/version.rb @@ -1,3 +1,3 @@ module Zencoder - GEM_VERSION = '2.5.0' + GEM_VERSION = '2.5.1' end From 42eb801fafb12805a4a5314a235d34f28312ec07 Mon Sep 17 00:00:00 2001 From: Chris Warren Date: Tue, 27 Feb 2018 11:40:22 -0600 Subject: [PATCH 30/34] Change docs URL to new site --- README.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.markdown b/README.markdown index a03c73a..887e712 100644 --- a/README.markdown +++ b/README.markdown @@ -4,7 +4,7 @@ The gem for interacting with the API on [Zencoder](http://zencoder.com). -See [http://zencoder.com/docs/api](http://zencoder.com/docs/api) for more details on the API. +See [https://support.brightcove.com/zencoder](https://support.brightcove.com/zencoder) for more details on the API. Tested on the following versions of Ruby: From 3124ff0c44a8500757d98fc2704009a3e8c78d6f Mon Sep 17 00:00:00 2001 From: Nathan Sutton Date: Fri, 12 Oct 2018 18:30:53 -0500 Subject: [PATCH 31/34] Update the list of supported rubies --- .travis.yml | 15 +++++---------- README.markdown | 13 +++++-------- 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/.travis.yml b/.travis.yml index 72ccd69..6b483f1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,12 +1,7 @@ language: ruby rvm: - - 2.1 - - 2.0 - - 1.9.3 - - jruby-18mode - - jruby-19mode - - rbx-2.0.0 - - rbx-2.1.1 - - rbx-2.2.5 - - 1.8.7 - - ree + - 2.5 + - 2.4 + - 2.3 + - 2.2 + - jruby diff --git a/README.markdown b/README.markdown index 887e712..811d7e1 100644 --- a/README.markdown +++ b/README.markdown @@ -8,14 +8,11 @@ See [https://support.brightcove.com/zencoder](https://support.brightcove.com/zen Tested on the following versions of Ruby: -* Ruby 1.8.6-p420 -* Ruby 1.8.7-p249 -* Ruby 1.8.7-p352 -* Ruby 1.9.2-p290 -* Ruby 1.9.3-p0 -* Ruby 2.0.0-p353 -* Rubinius 2.0.0dev -* jRuby 1.6.5 +* Ruby 2.2 +* Ruby 2.3 +* Ruby 2.4 +* Ruby 2.5 +* Latest jRuby ## 2.5 WARNING!!! From f0c4683069c5eb1c3b3b27da1510f13003e9e77c Mon Sep 17 00:00:00 2001 From: Nathan Sutton Date: Fri, 12 Oct 2018 18:36:40 -0500 Subject: [PATCH 32/34] Fixing a couple links to documentation --- README.markdown | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.markdown b/README.markdown index 811d7e1..29da5e3 100644 --- a/README.markdown +++ b/README.markdown @@ -47,7 +47,7 @@ With the release of version two of the Zencoder API, there are some new methods * Zencoder::Report.live(:from => "2011-01-01", :to => "2011-03-01") * Zencoder::Report.vod(:from => "2011-01-01", :to => "2011-03-01") -These new methods will not work with older versions of the API. Please see the [Zencoder documentation](https://app.zencoder.com/docs) and our [blog post on the subject](http://blog.zencoder.com/2012/01/05/announcing-zencoder-api-v2/) for more information on APIv2. +These new methods will not work with older versions of the API. Please see the [Zencoder documentation](https://support.brightcove.com/zencoder) for more information on APIv2. If you'd like to use the new version of the library but continue using APIv1 until you work through any integration troubles, you can do the following: @@ -113,7 +113,7 @@ There's more you can do on jobs than anything else in the API. The following met ### create -The hash you pass to the `create` method should be encodable to the [JSON you would pass to the Job creation API call on Zencoder](http://zencoder.com/docs/api/#encoding-job). We'll auto-populate your API key if you've set it already. +The hash you pass to the `create` method should be encodable to the [JSON you would pass to the Job creation API call on Zencoder](https://docs.brightcove.com/zencoder-api/v2/doc/index.html#api-Jobs-Create_a_Job). We'll auto-populate your API key if you've set it already. ```ruby Zencoder::Job.create({:input => 's3://bucket/key.mp4'}) @@ -245,7 +245,7 @@ Zencoder::Notification.list(:api_key => 'abcd1234') ### create -The hash you pass to the `create` method should be encodable to the [JSON you would pass to the Account creation API call on Zencoder](http://zencoder.com/docs/api/#accounts). No API key is required for this call, of course. +The hash you pass to the `create` method should be encodable to the [JSON you would pass to the Account creation API call on Zencoder](https://docs.brightcove.com/zencoder-api/v2/doc/index.html#api-Accounts-Create_an_Account). No API key is required for this call, of course. ```ruby Zencoder::Account.create({:terms_of_service => 1, From d1ffabd8f128d4a620c125abb2bde2058d5192a7 Mon Sep 17 00:00:00 2001 From: Nathan Sutton Date: Fri, 12 Oct 2018 19:52:10 -0500 Subject: [PATCH 33/34] Switch to rspec to get CI running --- .gitignore | 2 + .rspec | 1 + Gemfile | 17 +-- Rakefile | 13 +- spec/spec_helper.rb | 54 ++++++++ spec/zencoder/account_spec.rb | 53 ++++++++ spec/zencoder/http/net_http_spec.rb | 121 +++++++++++++++++ spec/zencoder/http/typhoeus_spec.rb | 55 ++++++++ spec/zencoder/http_spec.rb | 117 ++++++++++++++++ spec/zencoder/input_spec.rb | 31 +++++ spec/zencoder/job_spec.rb | 115 ++++++++++++++++ spec/zencoder/notification_spec.rb | 17 +++ spec/zencoder/output_spec.rb | 31 +++++ .../zencoder/report_spec.rb | 68 +++++----- spec/zencoder/response_spec.rb | 45 +++++++ spec/zencoder/zencoder_spec.rb | 37 ++++++ test/test_helper.rb | 32 ----- test/zencoder/account_test.rb | 56 -------- test/zencoder/http/net_http_test.rb | 125 ------------------ test/zencoder/http/typhoeus_test.rb | 59 --------- test/zencoder/http_test.rb | 120 ----------------- test/zencoder/input_test.rb | 34 ----- test/zencoder/job_test.rb | 117 ---------------- test/zencoder/notification_test.rb | 21 --- test/zencoder/output_test.rb | 34 ----- test/zencoder/response_test.rb | 49 ------- test/zencoder/zencoder_test.rb | 38 ------ zencoder.gemspec | 12 +- 28 files changed, 730 insertions(+), 744 deletions(-) create mode 100644 .rspec create mode 100644 spec/spec_helper.rb create mode 100644 spec/zencoder/account_spec.rb create mode 100644 spec/zencoder/http/net_http_spec.rb create mode 100644 spec/zencoder/http/typhoeus_spec.rb create mode 100644 spec/zencoder/http_spec.rb create mode 100644 spec/zencoder/input_spec.rb create mode 100644 spec/zencoder/job_spec.rb create mode 100644 spec/zencoder/notification_spec.rb create mode 100644 spec/zencoder/output_spec.rb rename test/zencoder/reports_test.rb => spec/zencoder/report_spec.rb (67%) create mode 100644 spec/zencoder/response_spec.rb create mode 100644 spec/zencoder/zencoder_spec.rb delete mode 100644 test/test_helper.rb delete mode 100644 test/zencoder/account_test.rb delete mode 100644 test/zencoder/http/net_http_test.rb delete mode 100644 test/zencoder/http/typhoeus_test.rb delete mode 100644 test/zencoder/http_test.rb delete mode 100644 test/zencoder/input_test.rb delete mode 100644 test/zencoder/job_test.rb delete mode 100644 test/zencoder/notification_test.rb delete mode 100644 test/zencoder/output_test.rb delete mode 100644 test/zencoder/response_test.rb delete mode 100644 test/zencoder/zencoder_test.rb diff --git a/.gitignore b/.gitignore index be9763e..820d634 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,5 @@ Gemfile.lock .zenflow-log .ruby-gemset .ruby-version +/.byebug-history +/.tool-versions diff --git a/.rspec b/.rspec new file mode 100644 index 0000000..c99d2e7 --- /dev/null +++ b/.rspec @@ -0,0 +1 @@ +--require spec_helper diff --git a/Gemfile b/Gemfile index 10ed641..fa75df1 100644 --- a/Gemfile +++ b/Gemfile @@ -1,18 +1,3 @@ source 'https://rubygems.org' -gem "multi_json" - -group :test do - gem "shoulda", "2.11.3" - gem "mocha" - gem "webmock", "~>1.6.0" -end - -group :development do - gem "jruby-openssl", :platforms => :jruby - gem "typhoeus", :platforms => [:mri_18, :mri_19, :mri_20, :mri_21] -end - -group :test, :development do - gem "rake" -end +gemspec diff --git a/Rakefile b/Rakefile index ab875f7..77f8a53 100644 --- a/Rakefile +++ b/Rakefile @@ -1,11 +1,8 @@ require 'rubygems' -require 'rake' -require 'rake/testtask' -Rake::TestTask.new(:test) do |test| - test.libs << 'lib' << 'test' - test.pattern = 'test/**/*_test.rb' - test.verbose = true +begin + require 'rspec/core/rake_task' + RSpec::Core::RakeTask.new(:spec) + task :default => :spec +rescue LoadError end - -task :default => :test diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100644 index 0000000..7dc92cf --- /dev/null +++ b/spec/spec_helper.rb @@ -0,0 +1,54 @@ +require "rubygems" +require "bundler" +Bundler.setup +Bundler.require(:default, :test, :development) +require 'test/unit/assertions' +require 'webmock/rspec' + +RSpec.configure do |config| + config.include Test::Unit::Assertions + + def assert_same_elements(a1, a2, msg = nil) + [:select, :inject, :size].each do |m| + [a1, a2].each {|a| assert_respond_to(a, m, "Are you sure that #{a.inspect} is an array? It doesn't respond to #{m}.") } + end + + assert a1h = a1.inject({}) { |h,e| h[e] ||= a1.select { |i| i == e }.size; h } + assert a2h = a2.inject({}) { |h,e| h[e] ||= a2.select { |i| i == e }.size; h } + + assert_equal(a1h, a2h, msg) + end + + config.after(:example) do + ENV["ZENCODER_API_KEY"] = nil + Zencoder.api_key = nil + end + + config.expect_with :rspec do |expectations| + expectations.include_chain_clauses_in_custom_matcher_descriptions = true + end + + config.mock_with :rspec do |mocks| + mocks.verify_partial_doubles = true + end + + config.shared_context_metadata_behavior = :apply_to_host_groups + + config.filter_run_when_matching :focus + + # config.example_status_persistence_file_path = "spec/examples.txt" + + config.disable_monkey_patching! + + config.warnings = true + + if config.files_to_run.one? + config.default_formatter = "doc" + end + + # config.profile_examples = 10 + + config.order = :random + + Kernel.srand config.seed +end diff --git a/spec/zencoder/account_spec.rb b/spec/zencoder/account_spec.rb new file mode 100644 index 0000000..b68e22a --- /dev/null +++ b/spec/zencoder/account_spec.rb @@ -0,0 +1,53 @@ +require "spec_helper" + +RSpec.describe Zencoder::Account do + before do + @api_key = 'abc123' + end + + describe ".create" do + before do + @url = "#{Zencoder.base_url}/account" + @params = {:api_key => @api_key} + @params_as_json = Zencoder::Serializer.encode(@params) + end + + it "POSTs to the correct url and return a response" do + expect(Zencoder::HTTP).to receive(:post).with(@url, @params_as_json, {}).and_return(Zencoder::Response.new) + assert_equal Zencoder::Response, Zencoder::Account.create(@params).class + end + end + + describe ".details" do + before do + @url = "#{Zencoder.base_url}/account" + end + + it "GETs the correct url and return a response" do + expect(Zencoder::HTTP).to receive(:get).with(@url, :headers => { "Zencoder-Api-Key" => @api_key }).and_return(Zencoder::Response.new) + assert_equal Zencoder::Response, Zencoder::Account.details(:api_key => @api_key).class + end + end + + describe ".integration" do + before do + @url = "#{Zencoder.base_url}/account/integration" + end + + it "PUTs the correct url and return a response" do + expect(Zencoder::HTTP).to receive(:put).with(@url, nil, :headers => { "Zencoder-Api-Key" => @api_key }).and_return(Zencoder::Response.new) + assert_equal Zencoder::Response, Zencoder::Account.integration(:api_key => @api_key).class + end + end + + describe ".live" do + before do + @url = "#{Zencoder.base_url}/account/live" + end + + it "PUTs the correct url and return a response" do + expect(Zencoder::HTTP).to receive(:put).with(@url, nil, :headers => { "Zencoder-Api-Key" => @api_key }).and_return(Zencoder::Response.new) + assert_equal Zencoder::Response, Zencoder::Account.live(:api_key => @api_key).class + end + end +end diff --git a/spec/zencoder/http/net_http_spec.rb b/spec/zencoder/http/net_http_spec.rb new file mode 100644 index 0000000..fcebcbf --- /dev/null +++ b/spec/zencoder/http/net_http_spec.rb @@ -0,0 +1,121 @@ +require "spec_helper" + +RSpec.describe Zencoder::HTTP::NetHTTP do + + describe "call options" do + it "requests with timeout" do + stub_request(:post, "https://example.com") + expect(Timeout).to receive(:timeout).with(0.001) + Zencoder::HTTP::NetHTTP.post('https://example.com', :timeout => 1) + end + + it "requests without timeout" do + stub_request(:post, "https://example.com") + allow(Timeout).to receive(:timeout).and_raise(Timeout::Error) + assert_nothing_raised do + Zencoder::HTTP::NetHTTP.post('https://example.com', :timeout => nil) + end + end + + it "adds params to the query string if passed" do + stub_request(:post, "https://example.com/path?some=param") + Zencoder::HTTP::NetHTTP.post('https://example.com/path', {:params => {:some => 'param'}}) + end + + it "adds params to the existing query string if passed" do + stub_request(:post,'https://example.com/path?original=param&some=param') + Zencoder::HTTP::NetHTTP.post('https://example.com/path?original=param', {:params => {:some => 'param'}}) + end + + it "adds headers" do + stub_request(:post,'https://example.com/path').with(:headers => {'some' => 'header'}) + Zencoder::HTTP::NetHTTP.post('https://example.com/path', {:headers => {:some => 'header'}}) + end + + it "adds the body to the request" do + stub_request(:post, 'https://example.com/path').with(:body => '{"some": "body"}') + Zencoder::HTTP::NetHTTP.post('https://example.com/path', {:body => '{"some": "body"}'}) + end + end + + describe "SSL verification" do + before do + @cert_store = double(:add_file => true, :add_path => true, :flags= => true, :set_default_paths => true).as_null_object + @http_stub = double(:use_ssl= => true, :request => true, :verify_mode= => true, :cert_store= => true, :cert_store => @cert_store).as_null_object + expect(::Net::HTTP).to receive(:new).and_return(@http_stub) + end + + describe "when set to skip ssl verification" do + it "nots verify" do + expect(@http_stub).to receive(:verify_mode=).with(OpenSSL::SSL::VERIFY_NONE) + Zencoder::HTTP::NetHTTP.post('https://example.com/path', :skip_ssl_verify => true) + end + + it "nots setup a custom cert store" do + expect(@http_stub).to_not receive(:cert_store=) + Zencoder::HTTP::NetHTTP.post('https://example.com/path', :skip_ssl_verify => true) + end + end + + describe "when set to do ssl verification" do + it "setups a custom cert store" do + expect(@http_stub).to receive(:cert_store=) + Zencoder::HTTP::NetHTTP.post('https://example.com/path') + end + + it "sets the default paths on the custom cert store" do + expect(@cert_store).to receive(:set_default_paths) + Zencoder::HTTP::NetHTTP.post('https://example.com/path') + end + + it "sets the ca_file when it is passed in" do + expect(@cert_store).to receive(:add_file).with("/foo/bar/baz.crt") + Zencoder::HTTP::NetHTTP.post('https://example.com/path', :ca_file => "/foo/bar/baz.crt") + end + + it "sets the ca_path when it is passed in" do + expect(@cert_store).to receive(:add_path).with("/foo/bar/") + Zencoder::HTTP::NetHTTP.post('https://example.com/path', :ca_path => "/foo/bar/") + end + end + + end + + describe ".post" do + it "POSTs to specified body to the specified path" do + stub_request(:post, 'https://example.com').with(:body => '{}') + Zencoder::HTTP::NetHTTP.post('https://example.com', :body => '{}') + end + + it "POSTs with an empty body if none is provided" do + stub_request(:post, 'https://example.com').with(:body => '') + Zencoder::HTTP::NetHTTP.post('https://example.com') + end + end + + describe ".put" do + it "PUTs to specified body to the specified path" do + stub_request(:put, 'https://example.com').with(:body => '{}') + Zencoder::HTTP::NetHTTP.put('https://example.com', :body => '{}') + end + + it "PUTs with an empty body if none is provided" do + stub_request(:put, 'https://example.com').with(:body => '') + Zencoder::HTTP::NetHTTP.put('https://example.com') + end + end + + describe ".get" do + it "GETs to specified body to the specified path" do + stub_request(:get, 'https://example.com') + Zencoder::HTTP::NetHTTP.get('https://example.com') + end + end + + describe ".delete" do + it "DELETEs to specified body to the specified path" do + stub_request(:delete, 'https://example.com') + Zencoder::HTTP::NetHTTP.delete('https://example.com') + end + end +end diff --git a/spec/zencoder/http/typhoeus_spec.rb b/spec/zencoder/http/typhoeus_spec.rb new file mode 100644 index 0000000..df2b1e7 --- /dev/null +++ b/spec/zencoder/http/typhoeus_spec.rb @@ -0,0 +1,55 @@ +require "spec_helper" + +# Most useless tests ever, but who knows, right? + +if !defined?(Typhoeus) + module ::Typhoeus + module Request + end + end +end + +RSpec.describe Zencoder::HTTP::Typhoeus do + describe ".post" do + it "POSTs using Typhoeus" do + expect(Typhoeus::Request).to receive(:post).with('https://example.com', {:some => 'options'}) + Zencoder::HTTP::Typhoeus.post('https://example.com', {:some => 'options'}) + end + end + + describe ".put" do + it "PUTs using Typhoeus" do + expect(Typhoeus::Request).to receive(:put).with('https://example.com', {:some => 'options'}) + Zencoder::HTTP::Typhoeus.put('https://example.com', {:some => 'options'}) + end + end + + describe ".get" do + it "GETs using Typhoeus" do + expect(Typhoeus::Request).to receive(:get).with('https://example.com', {:some => 'options'}) + Zencoder::HTTP::Typhoeus.get('https://example.com', {:some => 'options'}) + end + end + + describe ".delete" do + it "DELETEs using Typhoeus" do + expect(Typhoeus::Request).to receive(:delete).with('https://example.com', {:some => 'options'}) + Zencoder::HTTP::Typhoeus.delete('https://example.com', {:some => 'options'}) + end + end + + it "skips ssl verification" do + expect(Typhoeus::Request).to receive(:get).with('https://example.com', {:disable_ssl_peer_verification => true}) + Zencoder::HTTP::Typhoeus.get('https://example.com', {:skip_ssl_verify => true}) + end + + it "uses the path to the cert file" do + expect(Typhoeus::Request).to receive(:get).with('https://example.com', {:disable_ssl_peer_verification => true, :sslcert => "/foo/bar/baz.crt"}) + Zencoder::HTTP::Typhoeus.get('https://example.com', {:skip_ssl_verify => true, :ca_file => "/foo/bar/baz.crt"}) + end + + it "uses the path to the certs directory" do + expect(Typhoeus::Request).to receive(:get).with('https://example.com', {:disable_ssl_peer_verification => true, :capath => "/foo/bar/baz.crt"}) + Zencoder::HTTP::Typhoeus.get('https://example.com', {:skip_ssl_verify => true, :ca_path => "/foo/bar/baz.crt"}) + end +end diff --git a/spec/zencoder/http_spec.rb b/spec/zencoder/http_spec.rb new file mode 100644 index 0000000..46ce002 --- /dev/null +++ b/spec/zencoder/http_spec.rb @@ -0,0 +1,117 @@ +require "spec_helper" + +RSpec.describe Zencoder::HTTP do + it "haves a default_options hash" do + assert Zencoder::HTTP.default_options.is_a?(Hash) + end + + it "haves a default HTTP backend" do + assert Zencoder::HTTP.http_backend + end + + it "allows the changing of the HTTP backend" do + assert_not_equal Zencoder::HTTP.http_backend, Zencoder::HTTP::Typhoeus + + assert_nothing_raised do + Zencoder::HTTP.http_backend = Zencoder::HTTP::Typhoeus + end + + assert_equal Zencoder::HTTP.http_backend, Zencoder::HTTP::Typhoeus + end + + it "raises a Zencoder::HTTPError when there is an HTTP error" do + expect(Zencoder::HTTP.http_backend).to receive(:get). + with('https://example.com', Zencoder::HTTP.default_options). + at_least(:once). + and_raise(Errno::ECONNREFUSED) + + assert_raises Zencoder::HTTPError do + Zencoder::HTTP.get('https://example.com') + end + + begin + Zencoder::HTTP.get('https://example.com') + rescue Zencoder::HTTPError => e + assert_no_match(/perform_method/, e.backtrace.first) + end + end + + it "returns a Zencoder::Response" do + allow(Zencoder::HTTP.http_backend).to receive(:post).and_return(double(:code => 200, :body => '{"some": "hash"}').as_null_object) + allow(Zencoder::HTTP.http_backend).to receive(:put).and_return(double(:code => 200, :body => '{"some": "hash"}').as_null_object) + allow(Zencoder::HTTP.http_backend).to receive(:get).and_return(double(:code => 200, :body => '{"some": "hash"}').as_null_object) + allow(Zencoder::HTTP.http_backend).to receive(:delete).and_return(double(:code => 200, :body => '{"some": "hash"}').as_null_object) + + assert Zencoder::HTTP.post('https://example.com', '{"some": "hash"}').is_a?(Zencoder::Response) + assert Zencoder::HTTP.put('https://example.com', '{"some": "hash"}').is_a?(Zencoder::Response) + assert Zencoder::HTTP.get('https://example.com').is_a?(Zencoder::Response) + assert Zencoder::HTTP.delete('https://example.com').is_a?(Zencoder::Response) + end + + it "stores the raw response" do + post_stub = double(:code => 200, :body => '{"some": "hash"}').as_null_object + allow(Zencoder::HTTP.http_backend).to receive(:post).and_return(post_stub) + assert_equal post_stub, Zencoder::HTTP.post('https://example.com', '{"some": "hash"}').raw_response + end + + it "stores the raw response body" do + allow(Zencoder::HTTP.http_backend).to receive(:post).and_return(double(:code => 200, :body => '{"some": "hash"}').as_null_object) + assert_equal '{"some": "hash"}', Zencoder::HTTP.post('https://example.com', '{"some": "hash"}').raw_body + end + + it "stores the response code" do + allow(Zencoder::HTTP.http_backend).to receive(:post).and_return(double(:code => 200, :body => '{"some": "hash"}').as_null_object) + assert_equal 200, Zencoder::HTTP.post('https://example.com', '{"some": "hash"}').code + end + + it "JSONs parse the response body" do + allow(Zencoder::HTTP.http_backend).to receive(:put).and_return(double(:code => 200, :body => '{"some": "hash"}').as_null_object) + assert_equal({'some' => 'hash'}, Zencoder::HTTP.put('https://example.com', '{"some": "hash"}').body) + end + + it "stores the raw body if the body fails to be JSON parsed" do + allow(Zencoder::HTTP.http_backend).to receive(:put).and_return(double(:code => 200, :body => '{"some": bad json').as_null_object) + assert_equal '{"some": bad json', Zencoder::HTTP.put('https://example.com', '{"some": "hash"}').body + end + + describe ".post" do + it "calls post on the http_backend" do + expect(Zencoder::HTTP.http_backend).to receive(:post). + with('https://example.com', Zencoder::HTTP.default_options.merge(:body => '{}')). + and_return(Zencoder::Response.new) + + Zencoder::HTTP.post('https://example.com', '{}') + end + end + + describe ".put" do + it "calls put on the http_backend" do + expect(Zencoder::HTTP.http_backend).to receive(:put). + with('https://example.com', Zencoder::HTTP.default_options.merge(:body => '{}')). + and_return(Zencoder::Response.new) + + Zencoder::HTTP.put('https://example.com', '{}') + end + end + + describe ".get" do + it "calls post on the http_backend" do + expect(Zencoder::HTTP.http_backend).to receive(:get). + with('https://example.com', Zencoder::HTTP.default_options). + and_return(Zencoder::Response.new) + + Zencoder::HTTP.get('https://example.com') + end + end + + describe ".delete" do + it "calls post on the http_backend" do + expect(Zencoder::HTTP.http_backend).to receive(:delete). + with('https://example.com', Zencoder::HTTP.default_options). + and_return(Zencoder::Response.new) + + Zencoder::HTTP.delete('https://example.com') + end + end +end + diff --git a/spec/zencoder/input_spec.rb b/spec/zencoder/input_spec.rb new file mode 100644 index 0000000..0cf055a --- /dev/null +++ b/spec/zencoder/input_spec.rb @@ -0,0 +1,31 @@ +require "spec_helper" + +RSpec.describe Zencoder::Input do + before do + @api_key = 'abc123' + end + + describe ".details" do + before do + @input_id = 1 + @url = "#{Zencoder.base_url}/inputs/#{@input_id}" + end + + it "GETs the correct url and return a response" do + allow(Zencoder::HTTP).to receive(:get).with(@url, :headers => { "Zencoder-Api-Key" => @api_key }).and_return(Zencoder::Response.new) + assert_equal Zencoder::Response, Zencoder::Input.details(@input_id, :api_key => @api_key).class + end + end + + describe ".progress" do + before do + @input_id = 1 + @url = "#{Zencoder.base_url}/inputs/#{@input_id}/progress" + end + + it "GETs the correct url and return a response" do + allow(Zencoder::HTTP).to receive(:get).with(@url, :headers => { "Zencoder-Api-Key" => @api_key }).and_return(Zencoder::Response.new) + assert_equal Zencoder::Response, Zencoder::Input.progress(@input_id, :api_key => @api_key).class + end + end +end diff --git a/spec/zencoder/job_spec.rb b/spec/zencoder/job_spec.rb new file mode 100644 index 0000000..bfeb9c5 --- /dev/null +++ b/spec/zencoder/job_spec.rb @@ -0,0 +1,115 @@ +require "spec_helper" + +RSpec.describe Zencoder::Job do + before do + @api_key = 'abc123' + end + + describe ".create" do + before do + @url = "#{Zencoder.base_url}/jobs" + @params = {:api_key => @api_key, + :input => "s3://bucket-name/file-name.avi"} + @params_as_json = Zencoder::Serializer.encode(@params) + end + + it "POSTs to the correct url and return a response" do + expect(Zencoder::HTTP).to receive(:post).with(@url, @params_as_json, {}).and_return(Zencoder::Response.new) + assert_equal Zencoder::Response, Zencoder::Job.create(@params).class + end + + it "applies the global API key as a header" do + Zencoder.api_key = 'asdfasdf' + expect(Zencoder::HTTP).to receive(:post). + with(instance_of(String), + instance_of(String), + headers: { "Zencoder-Api-Key" => Zencoder.api_key }). + and_return(Zencoder::Response.new) + Zencoder::Job.create(:input => @params[:input]) + end + end + + describe ".list" do + before do + @url = "#{Zencoder.base_url}/jobs" + end + + it "GETs the correct url and return a response" do + allow(Zencoder::HTTP).to receive(:get).with(@url, {:params => { :page => 1, + :per_page => 50, + :state => nil}, + :headers => { "Zencoder-Api-Key" => @api_key }}).and_return(Zencoder::Response.new) + assert_equal Zencoder::Response, Zencoder::Job.list(:api_key => @api_key).class + end + + it "merges params well" do + allow(Zencoder::HTTP).to receive(:get).with(@url, {:params => {:page => 1, + :per_page => 50, + :some => 'param', + :state => nil}, + :headers => { "Zencoder-Api-Key" => @api_key }}).and_return(Zencoder::Response.new) + assert_equal Zencoder::Response, Zencoder::Job.list(:api_key => @api_key, :params => {:some => 'param'}).class + end + end + + describe ".details" do + before do + @job_id = 1 + @url = "#{Zencoder.base_url}/jobs/#{@job_id}" + end + + it "GETs the correct url and return a response" do + allow(Zencoder::HTTP).to receive(:get).with(@url, :headers => { "Zencoder-Api-Key" => @api_key }).and_return(Zencoder::Response.new) + assert_equal Zencoder::Response, Zencoder::Job.details(1, :api_key => @api_key).class + end + end + + describe ".progress" do + before do + @job_id = 1 + @url = "#{Zencoder.base_url}/jobs/#{@job_id}/progress" + end + + it "GETs the correct url and return a response" do + allow(Zencoder::HTTP).to receive(:get).with(@url, :headers => { "Zencoder-Api-Key" => @api_key }).and_return(Zencoder::Response.new) + assert_equal Zencoder::Response, Zencoder::Job.progress(1, :api_key => @api_key).class + end + end + + describe ".resubmit" do + before do + @job_id = 1 + @url = "#{Zencoder.base_url}/jobs/#{@job_id}/resubmit" + end + + it "PUTs the correct url and return a response" do + allow(Zencoder::HTTP).to receive(:put).with(@url, nil, :headers => {"Zencoder-Api-Key" => @api_key}).and_return(Zencoder::Response.new) + assert_equal Zencoder::Response, Zencoder::Job.resubmit(1, :api_key => @api_key).class + end + end + + describe ".cancel" do + before do + @job_id = 1 + @url = "#{Zencoder.base_url}/jobs/#{@job_id}/cancel" + end + + it "PUTs the correct url and return a response" do + allow(Zencoder::HTTP).to receive(:put).with(@url, nil, :headers => {"Zencoder-Api-Key" => @api_key}).and_return(Zencoder::Response.new) + assert_equal Zencoder::Response, Zencoder::Job.cancel(1, :api_key => @api_key).class + end + end + + describe ".finish" do + before do + @job_id = 1 + @url = "#{Zencoder.base_url}/jobs/#{@job_id}/finish" + end + + it "PUTs the correct url and return a response" do + allow(Zencoder::HTTP).to receive(:put).with(@url, nil, :headers => {"Zencoder-Api-Key" => @api_key}).and_return(Zencoder::Response.new) + assert_equal Zencoder::Response, Zencoder::Job.finish(1, :api_key => @api_key).class + end + end + +end diff --git a/spec/zencoder/notification_spec.rb b/spec/zencoder/notification_spec.rb new file mode 100644 index 0000000..07645f1 --- /dev/null +++ b/spec/zencoder/notification_spec.rb @@ -0,0 +1,17 @@ +require "spec_helper" + +RSpec.describe Zencoder::Notification do + describe ".list" do + before do + @url = "#{Zencoder.base_url}/notifications" + @api_key = 'asdfasdf' + end + + it "GETs the correct url and return a response" do + allow(Zencoder::HTTP).to receive(:get).with(@url, {:params => { :page => 1, + :per_page => 50}, + :headers => { "Zencoder-Api-Key" => @api_key }}).and_return(Zencoder::Response.new) + assert_equal Zencoder::Response, Zencoder::Notification.list(:api_key => @api_key).class + end + end +end diff --git a/spec/zencoder/output_spec.rb b/spec/zencoder/output_spec.rb new file mode 100644 index 0000000..cb8ee8c --- /dev/null +++ b/spec/zencoder/output_spec.rb @@ -0,0 +1,31 @@ +require "spec_helper" + +RSpec.describe Zencoder::Output do + before do + @api_key = 'abc123' + end + + describe ".details" do + before do + @output_id = 1 + @url = "#{Zencoder.base_url}/outputs/#{@output_id}" + end + + it "GETs the correct url and return a response" do + allow(Zencoder::HTTP).to receive(:get).with(@url, :headers => { "Zencoder-Api-Key" => @api_key }).and_return(Zencoder::Response.new) + assert_equal Zencoder::Response, Zencoder::Output.details(@output_id, :api_key => @api_key).class + end + end + + describe ".progress" do + before do + @output_id = 1 + @url = "#{Zencoder.base_url}/outputs/#{@output_id}/progress" + end + + it "GETs the correct url and return a response" do + allow(Zencoder::HTTP).to receive(:get).with(@url, :headers => { "Zencoder-Api-Key" => @api_key }).and_return(Zencoder::Response.new) + assert_equal Zencoder::Response, Zencoder::Output.progress(@output_id, :api_key => @api_key).class + end + end +end diff --git a/test/zencoder/reports_test.rb b/spec/zencoder/report_spec.rb similarity index 67% rename from test/zencoder/reports_test.rb rename to spec/zencoder/report_spec.rb index 12a2d58..bbbc707 100644 --- a/test/zencoder/reports_test.rb +++ b/spec/zencoder/report_spec.rb @@ -1,99 +1,99 @@ -require 'test_helper' +require "spec_helper" -class Zencoder::ReportTest < Test::Unit::TestCase +RSpec.describe Zencoder::Report do - context ".minutes" do - setup do + describe ".minutes" do + before do @api_key = "abcd123" @url = "#{Zencoder.base_url}/reports/minutes" end - should "GET the correct url and return a response" do - Zencoder::HTTP.stubs(:get).with(@url, {:params => { :from => "2011-01-01", + it "GETs the correct url and return a response" do + allow(Zencoder::HTTP).to receive(:get).with(@url, {:params => { :from => "2011-01-01", :to => "2011-06-01", :grouping => "foo"}, - :headers => { "Zencoder-Api-Key" => @api_key }}).returns(Zencoder::Response.new) + :headers => { "Zencoder-Api-Key" => @api_key }}).and_return(Zencoder::Response.new) assert_equal Zencoder::Response, Zencoder::Report.minutes(:api_key => @api_key, :from => "2011-01-01", :to => "2011-06-01", :grouping => "foo").class end - should "merge params well" do - Zencoder::HTTP.stubs(:get).with(@url, {:params => { :from => "2011-01-01", + it "merges params well" do + allow(Zencoder::HTTP).to receive(:get).with(@url, {:params => { :from => "2011-01-01", :to => "2011-06-01"}, - :headers => { "Zencoder-Api-Key" => @api_key }}).returns(Zencoder::Response.new) + :headers => { "Zencoder-Api-Key" => @api_key }}).and_return(Zencoder::Response.new) assert_equal Zencoder::Response, Zencoder::Report.minutes(:api_key => @api_key, :from => "2011-01-01", :to => "2011-06-01").class end end - context ".all" do - setup do + describe ".all" do + before do @api_key = "abcd123" @url = "#{Zencoder.base_url}/reports/all" end - should "GET the correct url and return a response" do - Zencoder::HTTP.stubs(:get).with(@url, {:params => { :from => "2011-01-01", + it "GETs the correct url and return a response" do + allow(Zencoder::HTTP).to receive(:get).with(@url, {:params => { :from => "2011-01-01", :to => "2011-06-01", :grouping => "foo"}, - :headers => { "Zencoder-Api-Key" => @api_key }}).returns(Zencoder::Response.new) + :headers => { "Zencoder-Api-Key" => @api_key }}).and_return(Zencoder::Response.new) assert_equal Zencoder::Response, Zencoder::Report.all(:api_key => @api_key, :from => "2011-01-01", :to => "2011-06-01", :grouping => "foo").class end - should "merge params well" do - Zencoder::HTTP.stubs(:get).with(@url, {:params => { :from => "2011-01-01", + it "merges params well" do + allow(Zencoder::HTTP).to receive(:get).with(@url, {:params => { :from => "2011-01-01", :to => "2011-06-01"}, - :headers => { "Zencoder-Api-Key" => @api_key }}).returns(Zencoder::Response.new) + :headers => { "Zencoder-Api-Key" => @api_key }}).and_return(Zencoder::Response.new) assert_equal Zencoder::Response, Zencoder::Report.all(:api_key => @api_key, :from => "2011-01-01", :to => "2011-06-01").class end end - context ".vod" do - setup do + describe ".vod" do + before do @api_key = "abcd123" @url = "#{Zencoder.base_url}/reports/vod" end - should "GET the correct url and return a response" do - Zencoder::HTTP.stubs(:get).with(@url, {:params => { :from => "2011-01-01", + it "GETs the correct url and return a response" do + allow(Zencoder::HTTP).to receive(:get).with(@url, {:params => { :from => "2011-01-01", :to => "2011-06-01", :grouping => "foo"}, - :headers => { "Zencoder-Api-Key" => @api_key }}).returns(Zencoder::Response.new) + :headers => { "Zencoder-Api-Key" => @api_key }}).and_return(Zencoder::Response.new) assert_equal Zencoder::Response, Zencoder::Report.vod(:api_key => @api_key, :from => "2011-01-01", :to => "2011-06-01", :grouping => "foo").class end - should "merge params well" do - Zencoder::HTTP.stubs(:get).with(@url, {:params => { :from => "2011-01-01", + it "merges params well" do + allow(Zencoder::HTTP).to receive(:get).with(@url, {:params => { :from => "2011-01-01", :to => "2011-06-01"}, - :headers => { "Zencoder-Api-Key" => @api_key }}).returns(Zencoder::Response.new) + :headers => { "Zencoder-Api-Key" => @api_key }}).and_return(Zencoder::Response.new) assert_equal Zencoder::Response, Zencoder::Report.vod(:api_key => @api_key, :from => "2011-01-01", :to => "2011-06-01").class end end - context ".live" do - setup do + describe ".live" do + before do @api_key = "abcd123" @url = "#{Zencoder.base_url}/reports/live" end - should "GET the correct url and return a response" do - Zencoder::HTTP.stubs(:get).with(@url, {:params => { :from => "2011-01-01", + it "GETs the correct url and return a response" do + allow(Zencoder::HTTP).to receive(:get).with(@url, {:params => { :from => "2011-01-01", :to => "2011-06-01", :grouping => "foo"}, - :headers => { "Zencoder-Api-Key" => @api_key }}).returns(Zencoder::Response.new) + :headers => { "Zencoder-Api-Key" => @api_key }}).and_return(Zencoder::Response.new) assert_equal Zencoder::Response, Zencoder::Report.live(:api_key => @api_key, :from => "2011-01-01", :to => "2011-06-01", :grouping => "foo").class end - should "merge params well" do - Zencoder::HTTP.stubs(:get).with(@url, {:params => { :from => "2011-01-01", + it "merges params well" do + allow(Zencoder::HTTP).to receive(:get).with(@url, {:params => { :from => "2011-01-01", :to => "2011-06-01"}, - :headers => { "Zencoder-Api-Key" => @api_key }}).returns(Zencoder::Response.new) + :headers => { "Zencoder-Api-Key" => @api_key }}).and_return(Zencoder::Response.new) assert_equal Zencoder::Response, Zencoder::Report.live(:api_key => @api_key, :from => "2011-01-01", :to => "2011-06-01").class end end diff --git a/spec/zencoder/response_spec.rb b/spec/zencoder/response_spec.rb new file mode 100644 index 0000000..b6acd0d --- /dev/null +++ b/spec/zencoder/response_spec.rb @@ -0,0 +1,45 @@ +require "spec_helper" + +RSpec.describe Zencoder::Response do + describe "#success?" do + it "returns true when code is between 200 and 299" do + assert Zencoder::Response.new(:code => 200).success? + assert Zencoder::Response.new(:code => 299).success? + assert Zencoder::Response.new(:code => 250).success? + end + + it "returns false when code it less than 200 or greater than 299" do + assert !Zencoder::Response.new(:code => 300).success? + assert !Zencoder::Response.new(:code => 199).success? + end + end + + describe "#errors" do + it "returns an empty array when body is not a Hash" do + assert_equal [], Zencoder::Response.new(:body => 1).errors + assert_equal [], Zencoder::Response.new(:body => "something").errors + assert_equal [], Zencoder::Response.new(:body => [1]).errors + end + + it "returns the value of the key 'errors' as a compacted array when body is a Hash" do + assert_same_elements ['must be awesome'], Zencoder::Response.new(:body => {'errors' => ['must be awesome']}).errors + assert_same_elements ['must be awesome'], Zencoder::Response.new(:body => {'errors' => 'must be awesome'}).errors + assert_same_elements ['must be awesome'], Zencoder::Response.new(:body => {'errors' => ['must be awesome', nil]}).errors + assert_same_elements [], Zencoder::Response.new(:body => {}).errors + end + end + + describe "#body_without_wrapper" do + it "returns the body when the body is a string" do + assert_equal "some text", Zencoder::Response.new(:body => "some text").body_without_wrapper + end + + it "returns the body when the body is not wrapped in api_response and is a hash" do + assert_equal({'some' => 'hash'}, Zencoder::Response.new(:body => {'some' => 'hash'}).body_without_wrapper) + end + + it "returns body['api_response'] when body is a hash and body['api_response'] exists" do + assert_equal({'some' => 'hash'}, Zencoder::Response.new(:body => {'api_response' => {'some' => 'hash'}}).body_without_wrapper) + end + end +end diff --git a/spec/zencoder/zencoder_spec.rb b/spec/zencoder/zencoder_spec.rb new file mode 100644 index 0000000..5613c00 --- /dev/null +++ b/spec/zencoder/zencoder_spec.rb @@ -0,0 +1,37 @@ +require "spec_helper" + +RSpec.describe Zencoder do + + it "allows user to set an api key" do + Zencoder.api_key = "123" + assert_equal Zencoder::Job.api_key, "123" + end + + it "allows ENV variable to set an api key" do + ENV['ZENCODER_API_KEY'] = "321" + assert_equal Zencoder::Job.api_key, "321" + end + + it "takes user-supplie api key over ENV-supplied key" do + Zencoder.api_key = "123" + ENV['ZENCODER_API_KEY'] = "321" + assert_equal Zencoder::Job.api_key, "123" + end + + it "encodes to json" do + assert_match(/"api_request"/, Zencoder::Serializer.encode({:api_request => {:input => 'https://example.com'}})) + end + + it "nots encode when the content is a String" do + assert_match(/^api_request$/, Zencoder::Serializer.encode("api_request")) + end + + it "decodes from json" do + assert Zencoder::Serializer.decode(%@{"api_request": {"input": "https://example.com"}}@)['api_request']['input'] + end + + it "does not decode when content is not a String" do + assert_equal 1, Zencoder::Serializer.decode(1) + end + +end diff --git a/test/test_helper.rb b/test/test_helper.rb deleted file mode 100644 index 0d065bc..0000000 --- a/test/test_helper.rb +++ /dev/null @@ -1,32 +0,0 @@ -require 'rubygems' -require 'bundler' -Bundler.setup -Bundler.require(:default, :test) - -begin - require "minitest/unit" - require "mocha/mini_test" -rescue LoadError - require "test/unit" - require "mocha/test_unit" -end - -$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) -$LOAD_PATH.unshift(File.dirname(__FILE__)) - -require 'zencoder' - -begin - require 'typhoeus' -rescue LoadError # doesn't work for all ruby versions - puts - puts 'Typhoeus not loaded. If your ruby version supports native extensions' - puts 'then consider installing it.' - puts - puts ' gem install typhoeus' - puts -end - -class Test::Unit::TestCase - include WebMock::API -end diff --git a/test/zencoder/account_test.rb b/test/zencoder/account_test.rb deleted file mode 100644 index f1e4ac9..0000000 --- a/test/zencoder/account_test.rb +++ /dev/null @@ -1,56 +0,0 @@ -require 'test_helper' - -class Zencoder::AccountTest < Test::Unit::TestCase - - context Zencoder::Account do - setup do - @api_key = 'abc123' - end - - context ".create" do - setup do - @url = "#{Zencoder.base_url}/account" - @params = {:api_key => @api_key} - @params_as_json = Zencoder::Serializer.encode(@params) - end - - should "POST to the correct url and return a response" do - Zencoder::HTTP.stubs(:post).with(@url, @params_as_json, {}).returns(Zencoder::Response.new) - assert_equal Zencoder::Response, Zencoder::Account.create(@params).class - end - end - - context ".details" do - setup do - @url = "#{Zencoder.base_url}/account" - end - - should "GET the correct url and return a response" do - Zencoder::HTTP.stubs(:get).with(@url, :headers => { "Zencoder-Api-Key" => @api_key }).returns(Zencoder::Response.new) - assert_equal Zencoder::Response, Zencoder::Account.details(:api_key => @api_key).class - end - end - - context ".integration" do - setup do - @url = "#{Zencoder.base_url}/account/integration" - end - - should "PUT the correct url and return a response" do - Zencoder::HTTP.stubs(:put).with(@url, nil, :headers => { "Zencoder-Api-Key" => @api_key }).returns(Zencoder::Response.new) - assert_equal Zencoder::Response, Zencoder::Account.integration(:api_key => @api_key).class - end - end - - context ".live" do - setup do - @url = "#{Zencoder.base_url}/account/live" - end - - should "PUT the correct url and return a response" do - Zencoder::HTTP.stubs(:put).with(@url, nil, :headers => { "Zencoder-Api-Key" => @api_key }).returns(Zencoder::Response.new) - assert_equal Zencoder::Response, Zencoder::Account.live(:api_key => @api_key).class - end - end - end -end diff --git a/test/zencoder/http/net_http_test.rb b/test/zencoder/http/net_http_test.rb deleted file mode 100644 index ff617cd..0000000 --- a/test/zencoder/http/net_http_test.rb +++ /dev/null @@ -1,125 +0,0 @@ -require 'test_helper' - -class Zencoder::HTTP::NetHTTPTest < Test::Unit::TestCase - - context Zencoder::HTTP::NetHTTP do - - context "call options" do - should "request with timeout" do - stub_request(:post, "https://example.com") - Timeout.expects(:timeout).with(0.001) - Zencoder::HTTP::NetHTTP.post('https://example.com', :timeout => 1) - end - - should "request without timeout" do - stub_request(:post, "https://example.com") - Timeout.stubs(:timeout).raises(Exception) - assert_nothing_raised do - Zencoder::HTTP::NetHTTP.post('https://example.com', :timeout => nil) - end - end - - should "add params to the query string if passed" do - stub_request(:post, "https://example.com/path?some=param") - Zencoder::HTTP::NetHTTP.post('https://example.com/path', {:params => {:some => 'param'}}) - end - - should "add params to the existing query string if passed" do - stub_request(:post,'https://example.com/path?original=param&some=param') - Zencoder::HTTP::NetHTTP.post('https://example.com/path?original=param', {:params => {:some => 'param'}}) - end - - should "add headers" do - stub_request(:post,'https://example.com/path').with(:headers => {'some' => 'header'}) - Zencoder::HTTP::NetHTTP.post('https://example.com/path', {:headers => {:some => 'header'}}) - end - - should "add the body to the request" do - stub_request(:post, 'https://example.com/path').with(:body => '{"some": "body"}') - Zencoder::HTTP::NetHTTP.post('https://example.com/path', {:body => '{"some": "body"}'}) - end - end - - context "SSL verification" do - setup do - @cert_store = stub(:add_file => true, :add_path => true, :flags= => true, :set_default_paths => true) - @http_stub = stub(:use_ssl= => true, :request => true, :verify_mode= => true, :cert_store= => true, :cert_store => @cert_store) - ::Net::HTTP.expects(:new).returns(@http_stub) - end - - context "when set to skip ssl verification" do - should "not verify" do - @http_stub.expects(:verify_mode=).with(OpenSSL::SSL::VERIFY_NONE) - Zencoder::HTTP::NetHTTP.post('https://example.com/path', :skip_ssl_verify => true) - end - - should "not setup a custom cert store" do - @http_stub.expects(:cert_store=).never - Zencoder::HTTP::NetHTTP.post('https://example.com/path', :skip_ssl_verify => true) - end - end - - context "when set to do ssl verification" do - should "setup a custom cert store" do - @http_stub.expects(:cert_store=) - Zencoder::HTTP::NetHTTP.post('https://example.com/path') - end - - should "set the default paths on the custom cert store" do - @cert_store.expects(:set_default_paths) - Zencoder::HTTP::NetHTTP.post('https://example.com/path') - end - - should "set the ca_file when it is passed in" do - @cert_store.expects(:add_file).with("/foo/bar/baz.crt") - Zencoder::HTTP::NetHTTP.post('https://example.com/path', :ca_file => "/foo/bar/baz.crt") - end - - should "set the ca_path when it is passed in" do - @cert_store.expects(:add_path).with("/foo/bar/") - Zencoder::HTTP::NetHTTP.post('https://example.com/path', :ca_path => "/foo/bar/") - end - end - - end - - context ".post" do - should "POST to specified body to the specified path" do - stub_request(:post, 'https://example.com').with(:body => '{}') - Zencoder::HTTP::NetHTTP.post('https://example.com', :body => '{}') - end - - should "POST with an empty body if none is provided" do - stub_request(:post, 'https://example.com').with(:body => '') - Zencoder::HTTP::NetHTTP.post('https://example.com') - end - end - - context ".put" do - should "PUT to specified body to the specified path" do - stub_request(:put, 'https://example.com').with(:body => '{}') - Zencoder::HTTP::NetHTTP.put('https://example.com', :body => '{}') - end - - should "PUT with an empty body if none is provided" do - stub_request(:put, 'https://example.com').with(:body => '') - Zencoder::HTTP::NetHTTP.put('https://example.com') - end - end - - context ".get" do - should "GET to specified body to the specified path" do - stub_request(:get, 'https://example.com') - Zencoder::HTTP::NetHTTP.get('https://example.com') - end - end - - context ".delete" do - should "DELETE to specified body to the specified path" do - stub_request(:delete, 'https://example.com') - Zencoder::HTTP::NetHTTP.delete('https://example.com') - end - end - end - -end diff --git a/test/zencoder/http/typhoeus_test.rb b/test/zencoder/http/typhoeus_test.rb deleted file mode 100644 index c4a43d8..0000000 --- a/test/zencoder/http/typhoeus_test.rb +++ /dev/null @@ -1,59 +0,0 @@ -require 'test_helper' - -class Zencoder::HTTP::TyphoeusTest < Test::Unit::TestCase - - # Most useless tests ever, but who knows, right? - - if !defined?(Typhoeus) - module ::Typhoeus - module Request - end - end - end - - context Zencoder::HTTP::Typhoeus do - context ".post" do - should "POST using Typhoeus" do - Typhoeus::Request.expects(:post).with('https://example.com', {:some => 'options'}) - Zencoder::HTTP::Typhoeus.post('https://example.com', {:some => 'options'}) - end - end - - context ".put" do - should "PUT using Typhoeus" do - Typhoeus::Request.expects(:put).with('https://example.com', {:some => 'options'}) - Zencoder::HTTP::Typhoeus.put('https://example.com', {:some => 'options'}) - end - end - - context ".get" do - should "GET using Typhoeus" do - Typhoeus::Request.expects(:get).with('https://example.com', {:some => 'options'}) - Zencoder::HTTP::Typhoeus.get('https://example.com', {:some => 'options'}) - end - end - - context ".delete" do - should "DELETE using Typhoeus" do - Typhoeus::Request.expects(:delete).with('https://example.com', {:some => 'options'}) - Zencoder::HTTP::Typhoeus.delete('https://example.com', {:some => 'options'}) - end - end - - should "skip ssl verification" do - Typhoeus::Request.expects(:get).with('https://example.com', {:disable_ssl_peer_verification => true}) - Zencoder::HTTP::Typhoeus.get('https://example.com', {:skip_ssl_verify => true}) - end - - should "use the path to the cert file" do - Typhoeus::Request.expects(:get).with('https://example.com', {:disable_ssl_peer_verification => true, :sslcert => "/foo/bar/baz.crt"}) - Zencoder::HTTP::Typhoeus.get('https://example.com', {:skip_ssl_verify => true, :ca_file => "/foo/bar/baz.crt"}) - end - - should "use the path to the certs directory" do - Typhoeus::Request.expects(:get).with('https://example.com', {:disable_ssl_peer_verification => true, :capath => "/foo/bar/baz.crt"}) - Zencoder::HTTP::Typhoeus.get('https://example.com', {:skip_ssl_verify => true, :ca_path => "/foo/bar/baz.crt"}) - end - end - -end diff --git a/test/zencoder/http_test.rb b/test/zencoder/http_test.rb deleted file mode 100644 index bbb1d63..0000000 --- a/test/zencoder/http_test.rb +++ /dev/null @@ -1,120 +0,0 @@ -require 'test_helper' - -class Zencoder::HTTPTest < Test::Unit::TestCase - - context Zencoder::HTTP do - should "have a default_options hash" do - assert Zencoder::HTTP.default_options.is_a?(Hash) - end - - should "have a default HTTP backend" do - assert Zencoder::HTTP.http_backend - end - - should "allow the changing of the HTTP backend" do - assert_not_equal Zencoder::HTTP.http_backend, Zencoder::HTTP::Typhoeus - - assert_nothing_raised do - Zencoder::HTTP.http_backend = Zencoder::HTTP::Typhoeus - end - - assert_equal Zencoder::HTTP.http_backend, Zencoder::HTTP::Typhoeus - end - - should "raise a Zencoder::HTTPError when there is an HTTP error" do - Zencoder::HTTP.http_backend.expects(:get). - with('https://example.com', Zencoder::HTTP.default_options). - at_least_once. - raises(Errno::ECONNREFUSED) - - assert_raises Zencoder::HTTPError do - Zencoder::HTTP.get('https://example.com') - end - - begin - Zencoder::HTTP.get('https://example.com') - rescue Zencoder::HTTPError => e - assert_no_match /perform_method/, e.backtrace.first - end - end - - should "return a Zencoder::Response" do - Zencoder::HTTP.http_backend.stubs(:post).returns(stub(:code => 200, :body => '{"some": "hash"}')) - Zencoder::HTTP.http_backend.stubs(:put).returns(stub(:code => 200, :body => '{"some": "hash"}')) - Zencoder::HTTP.http_backend.stubs(:get).returns(stub(:code => 200, :body => '{"some": "hash"}')) - Zencoder::HTTP.http_backend.stubs(:delete).returns(stub(:code => 200, :body => '{"some": "hash"}')) - - assert Zencoder::HTTP.post('https://example.com', '{"some": "hash"}').is_a?(Zencoder::Response) - assert Zencoder::HTTP.put('https://example.com', '{"some": "hash"}').is_a?(Zencoder::Response) - assert Zencoder::HTTP.get('https://example.com').is_a?(Zencoder::Response) - assert Zencoder::HTTP.delete('https://example.com').is_a?(Zencoder::Response) - end - - should "store the raw response" do - post_stub = stub(:code => 200, :body => '{"some": "hash"}') - Zencoder::HTTP.http_backend.stubs(:post).returns(post_stub) - assert_equal post_stub, Zencoder::HTTP.post('https://example.com', '{"some": "hash"}').raw_response - end - - should "store the raw response body" do - Zencoder::HTTP.http_backend.stubs(:post).returns(stub(:code => 200, :body => '{"some": "hash"}')) - assert_equal '{"some": "hash"}', Zencoder::HTTP.post('https://example.com', '{"some": "hash"}').raw_body - end - - should "store the response code" do - Zencoder::HTTP.http_backend.stubs(:post).returns(stub(:code => 200, :body => '{"some": "hash"}')) - assert_equal 200, Zencoder::HTTP.post('https://example.com', '{"some": "hash"}').code - end - - should "JSON parse the response body" do - Zencoder::HTTP.http_backend.stubs(:put).returns(stub(:code => 200, :body => '{"some": "hash"}')) - assert_equal({'some' => 'hash'}, Zencoder::HTTP.put('https://example.com', '{"some": "hash"}').body) - end - - should "store the raw body if the body fails to be JSON parsed" do - Zencoder::HTTP.http_backend.stubs(:put).returns(stub(:code => 200, :body => '{"some": bad json')) - assert_equal '{"some": bad json', Zencoder::HTTP.put('https://example.com', '{"some": "hash"}').body - end - - context ".post" do - should "call post on the http_backend" do - Zencoder::HTTP.http_backend.expects(:post). - with('https://example.com', Zencoder::HTTP.default_options.merge(:body => '{}')). - returns(Zencoder::Response.new) - - Zencoder::HTTP.post('https://example.com', '{}') - end - end - - context ".put" do - should "call put on the http_backend" do - Zencoder::HTTP.http_backend.expects(:put). - with('https://example.com', Zencoder::HTTP.default_options.merge(:body => '{}')). - returns(Zencoder::Response.new) - - Zencoder::HTTP.put('https://example.com', '{}') - end - end - - context ".get" do - should "call post on the http_backend" do - Zencoder::HTTP.http_backend.expects(:get). - with('https://example.com', Zencoder::HTTP.default_options). - returns(Zencoder::Response.new) - - Zencoder::HTTP.get('https://example.com') - end - end - - context ".delete" do - should "call post on the http_backend" do - Zencoder::HTTP.http_backend.expects(:delete). - with('https://example.com', Zencoder::HTTP.default_options). - returns(Zencoder::Response.new) - - Zencoder::HTTP.delete('https://example.com') - end - end - end - -end diff --git a/test/zencoder/input_test.rb b/test/zencoder/input_test.rb deleted file mode 100644 index efa73bb..0000000 --- a/test/zencoder/input_test.rb +++ /dev/null @@ -1,34 +0,0 @@ -require 'test_helper' - -class Zencoder::InputTest < Test::Unit::TestCase - - context Zencoder::Input do - setup do - @api_key = 'abc123' - end - - context ".details" do - setup do - @input_id = 1 - @url = "#{Zencoder.base_url}/inputs/#{@input_id}" - end - - should "GET the correct url and return a response" do - Zencoder::HTTP.stubs(:get).with(@url, :headers => { "Zencoder-Api-Key" => @api_key }).returns(Zencoder::Response.new) - assert_equal Zencoder::Response, Zencoder::Input.details(@input_id, :api_key => @api_key).class - end - end - - context ".progress" do - setup do - @input_id = 1 - @url = "#{Zencoder.base_url}/inputs/#{@input_id}/progress" - end - - should "GET the correct url and return a response" do - Zencoder::HTTP.stubs(:get).with(@url, :headers => { "Zencoder-Api-Key" => @api_key }).returns(Zencoder::Response.new) - assert_equal Zencoder::Response, Zencoder::Input.progress(@input_id, :api_key => @api_key).class - end - end - end -end diff --git a/test/zencoder/job_test.rb b/test/zencoder/job_test.rb deleted file mode 100644 index 1f704e8..0000000 --- a/test/zencoder/job_test.rb +++ /dev/null @@ -1,117 +0,0 @@ -require 'test_helper' - -class Zencoder::JobTest < Test::Unit::TestCase - - context Zencoder::Job do - setup do - @api_key = 'abc123' - end - - context ".create" do - setup do - @url = "#{Zencoder.base_url}/jobs" - @params = {:api_key => @api_key, - :input => "s3://bucket-name/file-name.avi"} - @params_as_json = Zencoder::Serializer.encode(@params) - end - - should "POST to the correct url and return a response" do - Zencoder::HTTP.expects(:post).with(@url, @params_as_json, {}).returns(Zencoder::Response.new) - assert_equal Zencoder::Response, Zencoder::Job.create(@params).class - end - - should "apply the global API key as a header" do - Zencoder.api_key = 'asdfasdf' - Zencoder::HTTP.expects(:post).with do |url, params, options| - options[:headers]["Zencoder-Api-Key"] == Zencoder.api_key - end.returns(Zencoder::Response.new) - Zencoder::Job.create(:input => @params[:input]) - Zencoder.api_key = nil - end - end - - context ".list" do - setup do - @url = "#{Zencoder.base_url}/jobs" - end - - should "GET the correct url and return a response" do - Zencoder::HTTP.stubs(:get).with(@url, {:params => { :page => 1, - :per_page => 50, - :state => nil}, - :headers => { "Zencoder-Api-Key" => @api_key }}).returns(Zencoder::Response.new) - assert_equal Zencoder::Response, Zencoder::Job.list(:api_key => @api_key).class - end - - should "merge params well" do - Zencoder::HTTP.stubs(:get).with(@url, {:params => {:page => 1, - :per_page => 50, - :some => 'param', - :state => nil}, - :headers => { "Zencoder-Api-Key" => @api_key }}).returns(Zencoder::Response.new) - assert_equal Zencoder::Response, Zencoder::Job.list(:api_key => @api_key, :params => {:some => 'param'}).class - end - end - - context ".details" do - setup do - @job_id = 1 - @url = "#{Zencoder.base_url}/jobs/#{@job_id}" - end - - should "GET the correct url and return a response" do - Zencoder::HTTP.stubs(:get).with(@url, :headers => { "Zencoder-Api-Key" => @api_key }).returns(Zencoder::Response.new) - assert_equal Zencoder::Response, Zencoder::Job.details(1, :api_key => @api_key).class - end - end - - context ".progress" do - setup do - @job_id = 1 - @url = "#{Zencoder.base_url}/jobs/#{@job_id}/progress" - end - - should "GET the correct url and return a response" do - Zencoder::HTTP.stubs(:get).with(@url, :headers => { "Zencoder-Api-Key" => @api_key }).returns(Zencoder::Response.new) - assert_equal Zencoder::Response, Zencoder::Job.progress(1, :api_key => @api_key).class - end - end - - context ".resubmit" do - setup do - @job_id = 1 - @url = "#{Zencoder.base_url}/jobs/#{@job_id}/resubmit" - end - - should "PUT the correct url and return a response" do - Zencoder::HTTP.stubs(:put).with(@url, nil, :headers => {"Zencoder-Api-Key" => @api_key}).returns(Zencoder::Response.new) - assert_equal Zencoder::Response, Zencoder::Job.resubmit(1, :api_key => @api_key).class - end - end - - context ".cancel" do - setup do - @job_id = 1 - @url = "#{Zencoder.base_url}/jobs/#{@job_id}/cancel" - end - - should "PUT the correct url and return a response" do - Zencoder::HTTP.stubs(:put).with(@url, nil, :headers => {"Zencoder-Api-Key" => @api_key}).returns(Zencoder::Response.new) - assert_equal Zencoder::Response, Zencoder::Job.cancel(1, :api_key => @api_key).class - end - end - - context ".finish" do - setup do - @job_id = 1 - @url = "#{Zencoder.base_url}/jobs/#{@job_id}/finish" - end - - should "PUT the correct url and return a response" do - Zencoder::HTTP.stubs(:put).with(@url, nil, :headers => {"Zencoder-Api-Key" => @api_key}).returns(Zencoder::Response.new) - assert_equal Zencoder::Response, Zencoder::Job.finish(1, :api_key => @api_key).class - end - end - - end -end diff --git a/test/zencoder/notification_test.rb b/test/zencoder/notification_test.rb deleted file mode 100644 index ebdd830..0000000 --- a/test/zencoder/notification_test.rb +++ /dev/null @@ -1,21 +0,0 @@ -require 'test_helper' - -class Zencoder::NotificationTest < Test::Unit::TestCase - - context Zencoder::Notification do - context ".list" do - setup do - @url = "#{Zencoder.base_url}/notifications" - @api_key = 'asdfasdf' - end - - should "GET the correct url and return a response" do - Zencoder::HTTP.stubs(:get).with(@url, {:params => { :page => 1, - :per_page => 50}, - :headers => { "Zencoder-Api-Key" => @api_key }}).returns(Zencoder::Response.new) - assert_equal Zencoder::Response, Zencoder::Notification.list(:api_key => @api_key).class - end - end - end - -end diff --git a/test/zencoder/output_test.rb b/test/zencoder/output_test.rb deleted file mode 100644 index 7da0cbc..0000000 --- a/test/zencoder/output_test.rb +++ /dev/null @@ -1,34 +0,0 @@ -require 'test_helper' - -class Zencoder::OutputTest < Test::Unit::TestCase - - context Zencoder::Output do - setup do - @api_key = 'abc123' - end - - context ".details" do - setup do - @output_id = 1 - @url = "#{Zencoder.base_url}/outputs/#{@output_id}" - end - - should "GET the correct url and return a response" do - Zencoder::HTTP.stubs(:get).with(@url, :headers => { "Zencoder-Api-Key" => @api_key }).returns(Zencoder::Response.new) - assert_equal Zencoder::Response, Zencoder::Output.details(@output_id, :api_key => @api_key).class - end - end - - context ".progress" do - setup do - @output_id = 1 - @url = "#{Zencoder.base_url}/outputs/#{@output_id}/progress" - end - - should "GET the correct url and return a response" do - Zencoder::HTTP.stubs(:get).with(@url, :headers => { "Zencoder-Api-Key" => @api_key }).returns(Zencoder::Response.new) - assert_equal Zencoder::Response, Zencoder::Output.progress(@output_id, :api_key => @api_key).class - end - end - end -end diff --git a/test/zencoder/response_test.rb b/test/zencoder/response_test.rb deleted file mode 100644 index 56e9282..0000000 --- a/test/zencoder/response_test.rb +++ /dev/null @@ -1,49 +0,0 @@ -require 'test_helper' - -class Zencoder::ResponseTest < Test::Unit::TestCase - - context Zencoder::Response do - context "#success?" do - should "return true when code is between 200 and 299" do - assert Zencoder::Response.new(:code => 200).success? - assert Zencoder::Response.new(:code => 299).success? - assert Zencoder::Response.new(:code => 250).success? - end - - should "return false when code it less than 200 or greater than 299" do - assert !Zencoder::Response.new(:code => 300).success? - assert !Zencoder::Response.new(:code => 199).success? - end - end - - context "#errors" do - should "return an empty array when body is not a Hash" do - assert_equal [], Zencoder::Response.new(:body => 1).errors - assert_equal [], Zencoder::Response.new(:body => "something").errors - assert_equal [], Zencoder::Response.new(:body => [1]).errors - end - - should "return the value of the key 'errors' as a compacted array when body is a Hash" do - assert_same_elements ['must be awesome'], Zencoder::Response.new(:body => {'errors' => ['must be awesome']}).errors - assert_same_elements ['must be awesome'], Zencoder::Response.new(:body => {'errors' => 'must be awesome'}).errors - assert_same_elements ['must be awesome'], Zencoder::Response.new(:body => {'errors' => ['must be awesome', nil]}).errors - assert_same_elements [], Zencoder::Response.new(:body => {}).errors - end - end - - context "#body_without_wrapper" do - should "return the body when the body is a string" do - assert_equal "some text", Zencoder::Response.new(:body => "some text").body_without_wrapper - end - - should "return the body when the body is not wrapped in api_response and is a hash" do - assert_equal({'some' => 'hash'}, Zencoder::Response.new(:body => {'some' => 'hash'}).body_without_wrapper) - end - - should "return body['api_response'] when body is a hash and body['api_response'] exists" do - assert_equal({'some' => 'hash'}, Zencoder::Response.new(:body => {'api_response' => {'some' => 'hash'}}).body_without_wrapper) - end - end - end - -end diff --git a/test/zencoder/zencoder_test.rb b/test/zencoder/zencoder_test.rb deleted file mode 100644 index 5bf9b8f..0000000 --- a/test/zencoder/zencoder_test.rb +++ /dev/null @@ -1,38 +0,0 @@ -require 'test_helper' - -class ZencoderTest < Test::Unit::TestCase - - should "allow user to set an api key" do - Zencoder.api_key = "123" - assert_equal Zencoder::Job.api_key, "123" - end - - should "allow ENV variable to set an api key" do - Zencoder.api_key = nil - ENV['ZENCODER_API_KEY'] = "321" - assert_equal Zencoder::Job.api_key, "321" - end - - should "take user-supplie api key over ENV-supplied key" do - Zencoder.api_key = "123" - ENV['ZENCODER_API_KEY'] = "321" - assert_equal Zencoder::Job.api_key, "123" - end - - should "encode to json" do - assert_match /"api_request"/, Zencoder::Serializer.encode({:api_request => {:input => 'https://example.com'}}) - end - - should "not encode when the content is a String" do - assert_match /^api_request$/, Zencoder::Serializer.encode("api_request") - end - - should "decode from json" do - assert Zencoder::Serializer.decode(%@{"api_request": {"input": "https://example.com"}}@)['api_request']['input'] - end - - should "not decode when content is not a String" do - assert_equal 1, Zencoder::Serializer.decode(1) - end - -end diff --git a/zencoder.gemspec b/zencoder.gemspec index a1e32ec..aba19d1 100644 --- a/zencoder.gemspec +++ b/zencoder.gemspec @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- lib = File.expand_path('../lib/', __FILE__) $:.unshift lib unless $:.include?(lib) @@ -15,6 +14,17 @@ Gem::Specification.new do |s| s.description = "Zencoder integration library." s.rubyforge_project = "zencoder" s.add_dependency "multi_json" + if RUBY_PLATFORM =~ /java/ + s.platform = "java" + s.add_development_dependency "jruby-openssl" + else + s.add_development_dependency "typhoeus" + s.add_development_dependency "byebug" + end + s.add_development_dependency "rspec", "~> 3.8.0" + s.add_development_dependency "webmock", "~> 3.4.2" + s.add_development_dependency "rake" + s.add_development_dependency "test-unit" s.files = Dir.glob("bin/**/*") + Dir.glob("lib/**/*") + %w(LICENSE README.markdown Rakefile) s.require_path = "lib" end From dbb9bf5e8d18a4d133250bb428773d6602f54fb9 Mon Sep 17 00:00:00 2001 From: Nathan Sutton Date: Fri, 12 Oct 2018 19:57:25 -0500 Subject: [PATCH 34/34] Attempt to fix tests for jruby --- spec/zencoder/http/typhoeus_spec.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/spec/zencoder/http/typhoeus_spec.rb b/spec/zencoder/http/typhoeus_spec.rb index df2b1e7..ad0882f 100644 --- a/spec/zencoder/http/typhoeus_spec.rb +++ b/spec/zencoder/http/typhoeus_spec.rb @@ -5,6 +5,19 @@ if !defined?(Typhoeus) module ::Typhoeus module Request + extend self + + def get(*) + end + + def put(*) + end + + def post(*) + end + + def delete(*) + end end end end