Sha256: a1ff9650c44fff2e44e4e4434b61c5ae27f86e51cc24e03d283f26a69bceabfe

Contents?: true

Size: 1.49 KB

Versions: 3

Compression:

Stored size: 1.49 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/spec_helper')

describe Trinidad::Extensions::SandboxServerExtension do
  subject { Trinidad::Extensions::SandboxServerExtension.new({}) }

  before(:each) do
    @tomcat = Trinidad::Tomcat::Tomcat.new
  end

  it 'includes a default path for the sandbox' do
    opts = subject.prepare_options
    opts[:context_path].should == '/sandbox'
  end

  it 'allows to override the default path' do
    ext = Trinidad::Extensions::SandboxServerExtension.new({
      :context_path => '/trinidad'
    })

    ext.prepare_options[:context_path].should == '/trinidad'
  end

  it 'adds a new application to the host' do
    subject.configure(@tomcat)

    @tomcat.host.findChildren().should have(1).children
  end

  it 'gives privileges to the applications context' do
    subject.configure(@tomcat)

    @tomcat.host.findChildren().first.privileged.should be_true
  end

  it 'adds the sandbox servlet to the application context' do
    app = subject.configure(@tomcat)
    app.context.findChild('SandboxServlet').should_not be_nil
  end

  it 'adds provided credentials to the servlet context' do
    opts = subject.prepare_options
    opts[:username] = 'foo'
    opts[:password] = 'bar'

    ext = Trinidad::Extensions::SandboxServerExtension.new(opts)

    app_ctx = ext.create_application_context(@tomcat, opts)

    app_ctx.servlet_context.getAttribute('sandbox_username').should == 'foo'
    app_ctx.servlet_context.getAttribute('sandbox_password').should == 'bar'    
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
trinidad_sandbox_extension-0.3.0 spec/trinidad_sandbox_extension_spec.rb
trinidad_sandbox_extension-0.2.0 spec/trinidad_sandbox_extension_spec.rb
trinidad_sandbox_extension-0.1.0 spec/trinidad_sandbox_extension_spec.rb