require 'helper'
require 'aws_lambda_code_signing_configs'
require 'aws-sdk-core'

class AWSLambdaCodeSigningConfigsConstructorTest < Minitest::Test

  def test_empty_params_ok
    AWSLambdaCodeSigningConfigs.new(client_args: { stub_responses: true })
  end

  def test_param_arg_not_ok
    assert_raises(ArgumentError) { AWSLambdaCodeSigningConfigs.new(unexpected: 9, client_args: { stub_responses: true }) }
  end

  def test_rejects_unrecognized_params
    assert_raises(ArgumentError) { AWSLambdaCodeSigningConfigs.new(unexpected: 9) }
  end
end

class AWSLambdaCodeSigningConfigsSuccessPathTest < Minitest::Test

  def setup
    data = {}
    data[:method] = :list_code_signing_configs
    mock_data = {}
    mock_data[:code_signing_config_id] = 'test1'
    mock_data[:code_signing_config_arn] = 'test1'
    mock_data[:description] = 'test1'
    mock_data[:allowed_publishers] = {
      signing_profile_version_arns: ['test1']
    }
    mock_data[:code_signing_policies] = {
      untrusted_artifact_on_deployment: 'test1'
    }
    mock_data[:last_modified] = Time.now
    data[:data] = { code_signing_configs: [mock_data] }
    data[:client] = Aws::Lambda::Client
    @resp = AWSLambdaCodeSigningConfigs.new(client_args: { stub_responses: true }, stub_data: [data])
  end

  def test_code_signing_configs_exist
    assert @resp.exists?
  end

  def test_code_signing_config_ids
    assert_equal(@resp.code_signing_config_ids, ['test1'])
  end

  def test_code_signing_config_arns
    assert_equal(@resp.code_signing_config_arns, ['test1'])
  end

  def test_descriptions
    assert_equal(@resp.descriptions, ['test1'])
  end
end