Sha256: fadbe8c2d26cad0b4dd8bb1676a12d1df8eb605542f60b5b1976a45ce4df88b3
Contents?: true
Size: 1.86 KB
Versions: 12
Compression:
Stored size: 1.86 KB
Contents
require 'minitest/autorun' require 'shoulda' require 'fileutils' require 'nexus/cipher' class ConfigTest < ::MiniTest::Unit::TestCase include ShouldaContextLoadable context 'no token' do should 'create token' do c = Nexus::Cipher.new( 'behappy' ) assert_equal( c.token.nil?, false ) assert_equal( c.iv.nil?, true ) end should 'en/decrypt data' do c = Nexus::Cipher.new( 'behappy' ) encrypted = c.encrypt( 'something' ) cc = Nexus::Cipher.new( 'behappy', c.token ) cc.iv = c.iv plain = cc.decrypt( encrypted ) assert_equal( plain, 'something' ) end should 'en/decrypt data using the same cipher' do c = Nexus::Cipher.new( 'behappy' ) encrypted = c.encrypt( 'something' ) plain = c.decrypt( encrypted ) assert_equal( plain, 'something' ) end end context 'with token' do should 'not create token' do c = Nexus::Cipher.new( 'behappy', "UvChT3jkwD7jXFd8mTWJ087i2Xb3tlGmPWUSYtAiRJM=" ) assert_equal( c.token, "UvChT3jkwD7jXFd8mTWJ087i2Xb3tlGmPWUSYtAiRJM=" ) assert_equal( c.iv.nil?, true ) end should 'en/decrypt data' do c = Nexus::Cipher.new( 'behappy', "UvChT3jkwD7jXFd8mTWJ087i2Xb3tlGmPWUSYtAiRJM=" ) encrypted = c.encrypt( 'something' ) cc = Nexus::Cipher.new( 'behappy', "UvChT3jkwD7jXFd8mTWJ087i2Xb3tlGmPWUSYtAiRJM=" ) cc.iv = c.iv plain = cc.decrypt( encrypted ) assert_equal( plain, 'something' ) end should 'en/decrypt data using the same cipher' do c = Nexus::Cipher.new( 'behappy', "UvChT3jkwD7jXFd8mTWJ087i2Xb3tlGmPWUSYtAiRJM=" ) encrypted = c.encrypt( 'something' ) plain = c.decrypt( encrypted ) assert_equal( plain, 'something' ) end end end
Version data entries
12 entries across 12 versions & 2 rubygems