k1LoW / awspec

RSpec tests for your AWS resources.
MIT License
1.17k stars 194 forks source link

Apigateway resource, probable bug in https://github.com/k1LoW/awspec/blob/master/lib/awspec/type/apigateway.rb#L34 #523

Open RamanVaskevich1984 opened 4 years ago

RamanVaskevich1984 commented 4 years ago

Probably there is a bug in apigateway resource type code https://github.com/k1LoW/awspec/blob/master/lib/awspec/type/apigateway.rb#L34. According to AWS design there is no http_method for integration like 'AWS'. 'AWS' can be one of integration types for aws_api_gateway_integration. That causes an error when running apigateway resource kitchen tests for: have_integration_path have_integration_method.

glasswalk3r commented 3 years ago

@RamanVaskevich1984 , can you please provide references about AWS not being an integration method?

I found this document that provides AWS as one of the available integration methods:

Represents an HTTP, HTTP_PROXY, AWS, AWS_PROXY, or Mock integration.

The code seems to be wrong, specially because:

    def has_integration_path?(path)
      check_existence
      self.api_resources.each do |resource|
        next if resource.resource_methods.nil?
        resource.resource_methods.each do |_, method|
          if method.method_integration.http_method == 'AWS'
            aws_path = method.method_integration.uri.match(%r{(\/[^\?]+)\??.*$}).captures[0] # Matches for ARN type path
            return resource if aws_path == path
          end
          uri = Addressable::URI.parse(method.method_integration.uri)
          return resource if uri.path == path
        end
      end
      nil
    end

On the other hand, AWS is used in stub response from the AWS API (lib/awspec/stub/apigateway.rb), but I don't have an API Gateway available for validating the response neither the theory about how this is suppose to work.

Can you please shed some light on this @RamanVaskevich1984 ?