Git Product home page Git Product logo

Comments (4)

Tieske avatar Tieske commented on July 29, 2024 2

the kong-plugin repo was lacking updates for both the change to routes and services, as well as the older update with the new dao.

I updated that repo, so please pull the latest master and try again.

from kong-vagrant.

peter-evans avatar peter-evans commented on July 29, 2024

Running tests for other plugins works fine though. Running the following passes all the tests.

bin/busted /kong/spec/03-plugins/17-jwt

I'm thinking it still might have something to do with the new services and routes and helpers.dao.apis:insert doesn't work anymore.

from kong-vagrant.

peter-evans avatar peter-evans commented on July 29, 2024

I fixed the myplugin tests by using a route instead of an api and removing the mockbin dependency.
If you like I can pull request this, but it won't work with older versions of Kong so I'm not sure how you want to handle it.

local helpers = require "spec.helpers"

for _, strategy in helpers.each_strategy() do
  describe("Demo-Plugin: myplugin (access) [#" .. strategy .. "]", function()
    local client

    setup(function()
      local bp = helpers.get_db_utils(strategy)

      local route1 = bp.routes:insert {
        hosts = { "test1.com" },
      }

      bp.plugins:insert {
        name = "myplugin",
        route_id = route1.id,
      }

      -- start kong, while setting the config item `custom_plugins` to make sure our
      -- plugin gets loaded
      assert(helpers.start_kong {
        database = strategy,
        nginx_conf = "spec/fixtures/custom_nginx.template",
        custom_plugins = "myplugin",
      })
    end)

    teardown(function()
      helpers.stop_kong()
    end)

    before_each(function()
      client = helpers.proxy_client()
    end)

    after_each(function()
      if client then client:close() end
    end)

    describe("request", function()
      it("gets a 'hello-world' header", function()
        local r = assert(client:send {
          method = "GET",
          path = "/status/200",
          headers = {
            host = "test1.com"
          }
        })
        -- validate that the request succeeded, response status 200
        assert.response(r).has.status(200)
        -- now check the request to have the header
        local header_value = assert.request(r).has.header("hello-world")
        -- validate the value of that header
        assert.equal("this is on a request", header_value)
      end)
    end)

    describe("response", function()
      it("gets a 'bye-world' header", function()
        local r = assert(client:send {
          method = "GET",
          path = "/status/200",
          headers = {
            host = "test1.com"
          }
        })
        -- validate that the request succeeded, response status 200
        assert.response(r).has.status(200)
        -- now check the response to have the header
        local header_value = assert.response(r).has.header("bye-world")
        -- validate the value of that header
        assert.equal("this is on the response", header_value)
      end)
    end)

  end)
end

from kong-vagrant.

peter-evans avatar peter-evans commented on July 29, 2024

@Tieske Looks like I was on the right track with the changes I made above. Thank you for the update. I tested it and it works fine now.

from kong-vagrant.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.