Sha256: bb6eecaae18da552d39277c89a93d727246ea562d94e70b86ce7228831448be2

Contents?: true

Size: 877 Bytes

Versions: 3

Compression:

Stored size: 877 Bytes

Contents

require "test_helper"
require "web-puppet"

class AppTest < Test::Unit::TestCase
  include Rack::Test::Methods

  def app
    WebPuppet::App.new
  end

  def test_view_renders_successfully
    get "/"
    assert last_response.ok?
  end

  def test_view_returns_json
    get "/"
    json = JSON.load(last_response.body)
  end

end

class AuthenticationTest < Test::Unit::TestCase
  include Rack::Test::Methods

  def app
    conf = mock()
    conf.expects(:get_value).with('username').returns("admin")
    conf.expects(:get_value).with('password').returns("password")
    WebPuppet::App.new().add_auth(conf)
  end

  def test_view_requires_authentication
    authorize 'evil', 'password'
    get "/"
    assert_equal 401, last_response.status
  end

  def test_view_renders_with_auth_details
    authorize 'admin', 'password'
    get "/"
    assert last_response.ok?
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
web-puppet-0.2.0 test/integration_test.rb
web-puppet-0.1.1 test/integration_test.rb
web-puppet-0.1.0 test/integration_test.rb