Sha256: de186cedc26a06edd5c99541e11fbbc105ad67d8933fd4315032c236d1b8eb4b

Contents?: true

Size: 892 Bytes

Versions: 10

Compression:

Stored size: 892 Bytes

Contents

require 'tempfile'

require 'murlsh'

describe Murlsh::Auth do

  before do
    @f = Tempfile.new('murlsh_users_test')

    @a = Murlsh::Auth.new(@f.path)

    @a.add_user 'test1', 'test1@test.com', 'secret1'
    @a.add_user 'test2', 'test2@test.com', 'secret2'
  end

  after do; @f.close!; end

  it 'should authorize valid credentials' do
    @a.auth('secret1').should == {
      :name => 'test1',
      :email => Digest::MD5.hexdigest('test1@test.com')
      }
    @a.auth('secret2').should == {
      :name => 'test2',
      :email => Digest::MD5.hexdigest('test2@test.com')
      }
  end

  it 'should not authorize invalid credentials' do
    @a.auth('not there').should be_nil
  end

  it 'should be able to find user by email address' do
    @a.by_email('test1@test.com').should == {
      :name => 'test1',
      :email => Digest::MD5.hexdigest('test1@test.com')
      }
  end

end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
murlsh-1.9.3 spec/auth_spec.rb
murlsh-1.9.2 spec/auth_spec.rb
murlsh-1.9.1 spec/auth_spec.rb
murlsh-1.9.0 spec/auth_spec.rb
murlsh-1.8.0 spec/auth_spec.rb
murlsh-1.7.1 spec/auth_spec.rb
murlsh-1.7.0 spec/auth_spec.rb
murlsh-1.6.1 spec/auth_spec.rb
murlsh-1.6.0 spec/auth_spec.rb
murlsh-1.5.0 spec/auth_spec.rb