summaryrefslogtreecommitdiff
path: root/spec/models/aws/role_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/models/aws/role_spec.rb')
-rw-r--r--spec/models/aws/role_spec.rb34
1 files changed, 34 insertions, 0 deletions
diff --git a/spec/models/aws/role_spec.rb b/spec/models/aws/role_spec.rb
new file mode 100644
index 00000000000..c40752e40a6
--- /dev/null
+++ b/spec/models/aws/role_spec.rb
@@ -0,0 +1,34 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe Aws::Role do
+ it { is_expected.to belong_to(:user) }
+ it { is_expected.to validate_length_of(:role_external_id).is_at_least(1).is_at_most(64) }
+
+ describe 'custom validations' do
+ subject { role.valid? }
+
+ context ':role_arn' do
+ let(:role) { build(:aws_role, role_arn: role_arn) }
+
+ context 'length is zero' do
+ let(:role_arn) { '' }
+
+ it { is_expected.to be_falsey }
+ end
+
+ context 'length is longer than 2048' do
+ let(:role_arn) { '1' * 2049 }
+
+ it { is_expected.to be_falsey }
+ end
+
+ context 'ARN is valid' do
+ let(:role_arn) { 'arn:aws:iam::123456789012:role/test-role' }
+
+ it { is_expected.to be_truthy }
+ end
+ end
+ end
+end