summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorKamil Trzcinski <ayufan@ayufan.eu>2015-07-03 15:47:41 +0200
committerKamil Trzcinski <ayufan@ayufan.eu>2015-07-13 12:10:26 +0200
commit9c2faf400a602a76d75b8c5da7692ee3ccd3aa5e (patch)
treecb3ad2b36f7e43b43156a77f4c48314393647286 /spec
parent1c57a4b92b66b91f4defd569666bed6f2d7a4428 (diff)
downloadgitlab-ci-9c2faf400a602a76d75b8c5da7692ee3ccd3aa5e.tar.gz
Added specs
Diffstat (limited to 'spec')
-rw-r--r--spec/models/variable_spec.rb44
1 files changed, 44 insertions, 0 deletions
diff --git a/spec/models/variable_spec.rb b/spec/models/variable_spec.rb
new file mode 100644
index 0000000..fd1ce1e
--- /dev/null
+++ b/spec/models/variable_spec.rb
@@ -0,0 +1,44 @@
+# == Schema Information
+#
+# Table name: variables
+#
+# id :integer not null, primary key
+# project_id :integer not null
+# key :string(255)
+# value :text
+# encrypted_value :string(255)
+# encrypted_value_salt :string(255)
+# encrypted_value_iv :string(255)
+#
+
+require 'spec_helper'
+
+describe Variable do
+ subject { Variable.new }
+
+ let(:secret_value) { 'secret' }
+
+ before :each do
+ subject.value = secret_value
+ end
+
+ describe :value do
+ it 'stores the encrypted value' do
+ subject.encrypted_value.should_not be_nil
+ end
+
+ it 'stores an iv for value' do
+ subject.encrypted_value_iv.should_not be_nil
+ end
+
+ it 'stores a salt for value' do
+ subject.encrypted_value_salt.should_not be_nil
+ end
+
+ it 'fails to decrypt if iv is incorrect' do
+ subject.encrypted_value_iv = nil
+ subject.instance_variable_set(:@value, nil)
+ expect { subject.value }.to raise_error
+ end
+ end
+end