Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Refactor tests slightly

  • Loading branch information...
commit dce350e5986fe6bab0ff2c216307b89c95a9c5e7 1 parent c6e20b9
Stephen Touset authored
21 test/sodium/auth/hmacsha256_test.rb
View
@@ -3,21 +3,26 @@
describe Sodium::Auth::HMACSHA256 do
subject { self.klass.new(self.key) }
- let(:klass) { Sodium::Auth::HMACSHA256 }
+ let(:klass) { Sodium::Auth::HMACSHA256 }
+ let(:primitive) { :hmacsha256 }
+
+ let :constants do
+ { :BYTES => 32,
+ :KEYBYTES => 32, }
+ end
+
let(:key) { Base64.decode64 'XMfWD8/yrcNDzJyGhxRIwi5tSGKf8D0ul9FyX/djvjg=' }
let(:authenticator) { Base64.decode64 '6WDKvxKevcZts0Yc1HWGnylNYEpcxPO9tVtApEK8XWc=' }
let(:plaintext) { 'message' }
it '::primitive must be correct' do
- self.klass.primitive.must_equal :hmacsha256
- end
-
- it '::BYTES must be correct' do
- self.klass::BYTES.must_equal 32
+ self.klass.primitive.must_equal self.primitive
end
- it '::KEYBYTES must be correct' do
- self.klass::KEYBYTES.must_equal 32
+ it 'must have correct values for its constants' do
+ self.constants.each_pair do |name, value|
+ self.klass[name].must_equal value
+ end
end
it 'must mint keys' do
24 test/sodium/auth/hmacsha512256_test.rb
View
@@ -3,26 +3,30 @@
describe Sodium::Auth::HMACSHA512256 do
subject { self.klass.new(self.key) }
- let(:klass) { Sodium::Auth::HMACSHA512256 }
+ let(:klass) { Sodium::Auth::HMACSHA512256 }
+ let(:primitive) { :hmacsha512256 }
+
+ let :constants do
+ { :BYTES => 32,
+ :KEYBYTES => 32, }
+ end
+
let(:key) { Base64.decode64 'XMfWD8/yrcNDzJyGhxRIwi5tSGKf8D0ul9FyX/djvjg=' }
let(:authenticator) { Base64.decode64 '6BN5+HNq0F8skQKkta+CLiBJ7mrrJaGw3G2J7jMT2qA=' }
let(:plaintext) { 'message' }
it '::primitive must be correct' do
- self.klass.primitive.must_equal :hmacsha512256
- end
-
- it '::BYTES must be correct' do
- self.klass::BYTES.must_equal 32
+ self.klass.primitive.must_equal self.primitive
end
- it '::KEYBYTES must be correct' do
- self.klass::KEYBYTES.must_equal 32
+ it 'must have correct values for its constants' do
+ self.constants.each_pair do |name, value|
+ self.klass[name].must_equal value
+ end
end
it 'must mint keys' do
- self.klass.key.length.
- must_equal self.klass::KEYBYTES
+ self.klass.key.length.must_equal self.klass[:KEYBYTES]
end
it 'must generate authenticators' do
Please sign in to comment.
Something went wrong with that request. Please try again.