Sha256: 6648dd9808704823b25e2bdc05b0b4961a3584513310eda7406e217ae71602b6

Contents?: true

Size: 1.54 KB

Versions: 4

Compression:

Stored size: 1.54 KB

Contents

describe AwsRotate::Key do
  let(:keys) do
    AwsRotate::Keys.new(options)
  end
  let(:options) { {select: select, reject: reject } }
  let(:select)  { nil }
  let(:reject)  { nil }

  context "no filters" do
    it "always returns true" do
      result = keys.filter_match?("my-account")
      expect(result).to be true
      result = keys.filter_match?("whatever")
      expect(result).to be true
    end
  end

  context "select filter string match" do
    let(:select) { ["my"] }
    it "test" do
      result = keys.filter_match?("my-account")
      expect(result).to be true
      result = keys.filter_match?("whatever")
      expect(result).to be false
    end
  end

  context "select filter regexp match" do
    let(:select) { ["^my"] }
    it "test" do
      result = keys.filter_match?("my-account")
      expect(result).to be true
      result = keys.filter_match?("test-my-test")
      expect(result).to be false
    end
  end

  context "reject filter" do
    let(:reject) { ["my"] }
    it "test" do
      result = keys.filter_match?("my-account")
      expect(result).to be false
      result = keys.filter_match?("whatever")
      expect(result).to be true
    end
  end

  context "both select and reject filters" do
    let(:select) { ["my"] }
    let(:reject) { ["test"] }
    it "test" do
      result = keys.filter_match?("my-account")
      expect(result).to be true
      result = keys.filter_match?("my-test-account")
      expect(result).to be false
      result = keys.filter_match?("whatever")
      expect(result).to be false
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
aws-rotate-0.4.0 spec/lib/keys_spec.rb
aws-rotate-0.3.0 spec/lib/keys_spec.rb
aws-rotate-0.2.0 spec/lib/keys_spec.rb
aws-rotate-0.1.0 spec/lib/keys_spec.rb