Sha256: bf54b892590dac4eea83346a61c044273391aa7037f6eb1602d641135743076f

Contents?: true

Size: 1.7 KB

Versions: 3

Compression:

Stored size: 1.7 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)
    context = @tomcat.host.findChildren().first
    listener = context.find_lifecycle_listeners.select do |l|
      l.instance_of?(Trinidad::Lifecycle::Default)
    end.first
    listener.configure_defaults(context)
    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.4.2 spec/trinidad_sandbox_extension_spec.rb
trinidad_sandbox_extension-0.4.1 spec/trinidad_sandbox_extension_spec.rb
trinidad_sandbox_extension-0.4.0 spec/trinidad_sandbox_extension_spec.rb