Commit b713c947 authored by Philip Cunningham's avatar Philip Cunningham

Validate for presence of dast_site_profile_id

- Adds missing validation to Dast::SiteProfileSecretVariable
- Adds spec
parent 05a6be0c
......@@ -18,6 +18,8 @@ module Dast
key: Settings.attr_encrypted_db_key_base_32,
encode: false # No need to encode for binary column https://github.com/attr-encrypted/attr_encrypted#the-encode-encode_iv-encode_salt-and-default_encoding-options
validates :dast_site_profile_id, presence: true
# Secret variables must be masked to prevent them being readable in CI jobs
validates :masked, inclusion: { in: [true] }
validates :variable_type, inclusion: { in: ['env_var'] }
......
......@@ -27,6 +27,7 @@ RSpec.describe Dast::SiteProfileSecretVariable, type: :model do
it { is_expected.to be_valid }
it { is_expected.to include_module(Ci::Maskable) }
it { is_expected.to include_module(Ci::HasVariable) }
it { is_expected.to validate_presence_of(:dast_site_profile_id) }
it { is_expected.to validate_inclusion_of(:masked).in_array([true]) }
it { is_expected.to validate_uniqueness_of(:key).scoped_to(:dast_site_profile_id).with_message(/\(\w+\) has already been taken/) }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment