Sha256: 427f22d36efc907719b7729363fb080c92beaf7de17b44fc31cb39c42e60a7f3

Contents?: true

Size: 1.92 KB

Versions: 3

Compression:

Stored size: 1.92 KB

Contents

require './test/env.rb'

describe 'registering apns applications' do
  it 'should fail without input' do
    post '/register_application'
    resp[:application_id].must_be_nil
    resp[:error][:type].must_equal 'missing_apns_certificate'
  end

  it 'fails with bad cert' do
    post '/register_application', apns_p12: File.read('./test/files/example.pem'), apns_mode: 'production'
    resp[:application_id].must_be_nil
    resp[:error][:type].must_equal 'invalid_apns_p12'
  end

  it 'works' do
    post '/register_application', apns_p12: File.read('./test/files/example.p12'), apns_mode: 'production'
    resp[:application_id].wont_be_nil
  end

  it 'works with provided id' do
    post '/register_application', apns_p12: File.read('./test/files/example.p12'), application_id: 'specialapp', apns_mode: 'production'
    resp[:application_id].must_equal 'specialapp'
  end

  it 'fails for passworded p12 with bad pass' do
    post '/register_application', apns_p12: File.read('./test/files/example_with_pass.p12'), apns_p12_pass: 'fail', apns_mode: 'production'
    resp[:application_id].must_be_nil
    resp[:error][:type].must_equal 'invalid_apns_p12'
  end

  it 'works with pass' do
    post '/register_application', apns_p12: File.read('./test/files/example_with_pass.p12'), apns_p12_pass: 'test', apns_mode: 'production'
    resp[:application_id].wont_be_nil
  end

  it 'works with pem instead of p12' do
    post '/register_application', apns_pem: File.read('./test/files/example.pem'), apns_mode: 'production'
    resp[:application_id].wont_be_nil
  end

  it 'fails if no apns_mode provided' do
    post '/register_application', apns_pem: File.read('./test/files/example.pem')
    resp[:error][:type].must_equal 'apns_mode_required'
  end

  it 'fails on invalid apns_mode' do
    post '/register_application', apns_pem: File.read('./test/files/example.pem'), apns_mode: 'whatever'
    resp[:error][:type].must_equal 'apns_mode_required'
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pushlet-0.2.5 test/register_application_test.rb
pushlet-0.2.3 test/register_application_test.rb
pushlet-0.2.0 test/register_application_test.rb