Sha256: c02b45812bcc4bd52fc1d2d7477a549df9223fb968c6e28ad95233e5b87c0ffa

Contents?: true

Size: 683 Bytes

Versions: 10

Compression:

Stored size: 683 Bytes

Contents

require "spec_helper"

describe Rack::API::Middleware::SSL do
  let(:action) { proc {|env| [200, {}, ["success"]] } }

  it "denies http requests" do
    env = Rack::MockRequest.env_for("/v1", "rack.url_scheme" => "http")
    status, headers, response = Rack::API::Middleware::SSL.new(action).call(env)

    status.should == 400
    headers["Content-Type"].should == "text/plain"
    response.should include("Only HTTPS requests are supported by now.")
  end

  it "accepts https requests" do
    env = Rack::MockRequest.env_for("/v1", "rack.url_scheme" => "https")
    status, headers, response = Rack::API::Middleware::SSL.new(action).call(env)

    status.should == 200
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
rack-api-1.1.0 spec/rack-api/ssl_spec.rb
rack-api-1.0.2 spec/rack-api/ssl_spec.rb
rack-api-1.0.1 spec/rack-api/ssl_spec.rb
rack-api-1.0.0 spec/rack-api/ssl_spec.rb
rack-api-0.3.1 spec/rack-api/ssl_spec.rb
rack-api-0.3.0 spec/rack-api/ssl_spec.rb
rack-api-0.2.2 spec/rack-api/ssl_spec.rb
rack-api-0.2.1 spec/rack-api/ssl_spec.rb
rack-api-0.2.0 spec/rack-api/ssl_spec.rb
rack-api-0.1.2 spec/rack-api/ssl_spec.rb