class RubyKong::Request::Plugin::Stub

Public Class Methods

create() click to toggle source
# File lib/ruby-kong/request/plugin.rb, line 248
def self.create
  path = RubyKong.paths[:plugin][:create]
  path.gsub!(':api_id', 'shipit')
  url = RubyKong::Utils.endpoint_builder(path)

  RubyKong::Stub.request(
    :method   => :post,
    :url      => url,
    :request  => {
      :body => {
        :name => 'key-auth'
      }
    },
    :response => {
      :status => 201,
      :body   => {
        'api_id'     => 'ec60e4c9-11e2-4748-817d-56b2bf69bd60',
        'id'         => '90e6e8f4-2d51-444d-ac28-3f1dc1b3b3ed',
        'created_at' => 1458809572000,
        'enabled'    => true,
        'name'       => 'key-auth',
        'config'     => {
          'key_names'        => ['apikey'],
          'hide_credentials' => false
        }
      }.to_s
    }
  )
end
list() click to toggle source
# File lib/ruby-kong/request/plugin.rb, line 187
def self.list
  path = RubyKong.paths[:plugin][:list]
  url = RubyKong::Utils.endpoint_builder(path)

  RubyKong::Stub.request(
    :method   => :get,
    :url      => url,
    :response => {
      :status => 200,
      :body   => {
        "data"  =>
        [
          {
            'api_id'     => 'ec60e4c9-11e2-4748-817d-56b2bf69bd60',
            'id'         => '90e6e8f4-2d51-444d-ac28-3f1dc1b3b3ed',
            'created_at' => 1458809572000,
            'enabled'    => true,
            'name'       => 'key-auth',
            'config'     => {
              'key_names'        => ['apikey'],
              'hide_credentials' => false
            }
          }
        ],
        "total" => 1
      }.to_s
    }
  )
end
list_by_api() click to toggle source
# File lib/ruby-kong/request/plugin.rb, line 217
def self.list_by_api
  path = RubyKong.paths[:plugin][:list_by_api]
  path.gsub!(':api_id', 'shipit')
  url = RubyKong::Utils.endpoint_builder(path)

  RubyKong::Stub.request(
    :method   => :get,
    :url      => url,
    :response => {
      :status => 200,
      :body   => {
        "data"  =>
        [
          {
            'api_id'     => 'ec60e4c9-11e2-4748-817d-56b2bf69bd60',
            'id'         => '90e6e8f4-2d51-444d-ac28-3f1dc1b3b3ed',
            'created_at' => 1458809572000,
            'enabled'    => true,
            'name'       => 'key-auth',
            'config'     => {
              'key_names'        => ['apikey'],
              'hide_credentials' => false
            }
          }
        ],
        "total" => 1
      }.to_s
    }
  )
end
retrieve() click to toggle source
# File lib/ruby-kong/request/plugin.rb, line 103
def self.retrieve
  path = RubyKong.paths[:plugin][:retrieve]
  path.gsub!(':plugin_id', '90e6e8f4-2d51-444d-ac28-3f1dc1b3b3ed')
  url = RubyKong::Utils.endpoint_builder(path)

  RubyKong::Stub.request(
    :method   => :get,
    :url      => url,
    :response => {
      :status => 200,
      :body   => {
        'api_id'     => 'ec60e4c9-11e2-4748-817d-56b2bf69bd60',
        'id'         => '90e6e8f4-2d51-444d-ac28-3f1dc1b3b3ed',
        'created_at' => 1458809572000,
        'enabled'    => true,
        'name'       => 'key-auth',
        'config'     => {
          'key_names'        => ['apikey'],
          'hide_credentials' => false
        }
      }.to_s
    }
  )
end
retrieve_enabled() click to toggle source
# File lib/ruby-kong/request/plugin.rb, line 128
def self.retrieve_enabled
  path = RubyKong.paths[:plugin][:retrieve_enabled]
  url = RubyKong::Utils.endpoint_builder(path)

  RubyKong::Stub.request(
    :method   => :get,
    :url      => url,
    :response => {
      :status => 200,
      :body   => {
        "enabled_plugins": [
            "ssl",
            "jwt",
            "acl",
            "cors",
            "oauth2",
            "tcp-log",
            "udp-log",
            "file-log",
            "http-log",
            "key-auth",
            "hmac-auth",
            "basic-auth",
            "ip-restriction",
            "mashape-analytics",
            "request-transformer",
            "response-transformer",
            "request-size-limiting",
            "rate-limiting",
            "response-ratelimiting"
        ]
      }.to_s
    }
  )
end
retrieve_schema() click to toggle source
# File lib/ruby-kong/request/plugin.rb, line 164
def self.retrieve_schema
  path = RubyKong.paths[:plugin][:retrieve_schema]
  path.gsub!(':plugin_name', 'basic-auth')
  url = RubyKong::Utils.endpoint_builder(path)

  RubyKong::Stub.request(
    :method   => :get,
    :url      => url,
    :response => {
      :status => 200,
      :body   => {
        "fields": {
          "hide_credentials": {
            "type":"boolean",
            "default":false
          }
        },
        "no_consumer":true
      }.to_s
    }
  )
end
update() click to toggle source

def self.delete

# Mock with /plugins/lamdt path
path = RubyKong.paths[:plugin][:delete] + 'lamdt'
url  = RubyKong::Utils.endpoint_builder(path)

RubyKong::Stub.request(
  :method   => :delete,
  :url      => url,
  :response => {
    :status => 204,
    :body   => ""
  }
)

end

# File lib/ruby-kong/request/plugin.rb, line 74
def self.update
  path      = RubyKong.paths[:plugin][:update]
  path.gsub!(':api_id', 'shipit')
  path.gsub!(':plugin_id', '90e6e8f4-2d51-444d-ac28-3f1dc1b3b3ed')
  url = RubyKong::Utils.endpoint_builder(path)

  RubyKong::Stub.request(
    :method   => :patch,
    :url      => url,
    :request  => {
      :body => {}
    },
    :response => {
      :status => 200,
      :body   => {
        'api_id'     => 'ec60e4c9-11e2-4748-817d-56b2bf69bd60',
        'id'         => '90e6e8f4-2d51-444d-ac28-3f1dc1b3b3ed',
        'created_at' => 1458809572000,
        'enabled'    => true,
        'name'       => 'key-auth',
        'config'     => {
          'key_names'        => ['apikey'],
          'hide_credentials' => false
        }
      }.to_s
    }
  )
end