Sha256: af56fe11381606c569f934c1c8a6f02cfe56aca40e5a51f813db92e737fbb3c2

Contents?: true

Size: 997 Bytes

Versions: 18

Compression:

Stored size: 997 Bytes

Contents

require 'spec_helper'
require 'ronin/password'

describe Password do
  let(:password) { 'secret' }
  subject { Password.new(:clear_text => password) }

  it "should require a clear-text password" do
    pass = Password.new

    pass.should_not be_valid
  end

  describe "#digest" do
    let(:salt) { 'foo' }

    it "should calculate the digest of the password" do
      digest = subject.digest(:sha1)
      
      digest.should == Digest::SHA1.hexdigest(password)
    end

    it "should calculate the digest of the password and prepended salt" do
      digest = subject.digest(:sha1, :prepend_salt => salt)
      
      digest.should == Digest::SHA1.hexdigest(salt + password)
    end

    it "should calculate the digest of the password and appended salt" do
      digest = subject.digest(:sha1, :append_salt => salt)
      
      digest.should == Digest::SHA1.hexdigest(password + salt)
    end
  end

  it "should be convertable to a String" do
    subject.to_s.should == password
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
ronin-1.5.0 spec/password_spec.rb
ronin-1.5.0.rc2 spec/password_spec.rb
ronin-1.5.0.rc1 spec/password_spec.rb
ronin-1.4.1 spec/password_spec.rb
ronin-1.4.0 spec/password_spec.rb
ronin-1.4.0.rc2 spec/password_spec.rb
ronin-1.4.0.rc1 spec/password_spec.rb
ronin-1.3.0 spec/password_spec.rb
ronin-1.2.0 spec/password_spec.rb
ronin-1.1.0 spec/password_spec.rb
ronin-1.1.0.rc3 spec/password_spec.rb
ronin-1.1.0.rc2 spec/password_spec.rb
ronin-1.1.0.rc1 spec/password_spec.rb
ronin-1.0.0 spec/password_spec.rb
ronin-1.0.0.rc3 spec/password_spec.rb
ronin-1.0.0.rc2 spec/password_spec.rb
ronin-1.0.0.rc1 spec/password_spec.rb
ronin-1.0.0.pre4 spec/password_spec.rb