<commit_before>local helpers = require "spec.helpers"
local new_tab = require "table.new"

for _, strategy in helpers.each_strategy() do
  describe("Plugin: Session (kong storage adapter) [#" .. strategy .. "]", function()
    local client, bp

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

      local route1 = bp.routes:insert {
        paths    = {"/test1"},
        hosts = {"httpbin.org"}
      }

      local route2 = bp.routes:insert {
        paths    = {"/test2"},
        hosts = {"httpbin.org"}
      }
      
      assert(bp.plugins:insert {
        name = "session",
        route_id = route1.id,
        config = {
          storage = "kong",
          secret = "ultra top secret session",
        }
      })
      
      assert(bp.plugins:insert {
        name = "session",
        route_id = route2.id,
        config = {
          secret = "super secret session secret",
          storage = "kong",
          cookie_renew = 600,
          cookie_lifetime = 601,
        }
      })

      local consumer = bp.consumers:insert { username = "coop" }
      bp.keyauth_credentials:insert {
        key = "kong",
        consumer_id = consumer.id,
      }

      local anonymous = bp.consumers:insert { username = "anon" }
      bp.plugins:insert {
        name = "key-auth",
        route_id = route1.id,
        config = {
          anonymous = anonymous.id
        }
      }

      bp.plugins:insert {
        name = "key-auth",
        route_id = route2.id,
        config = {
          anonymous = anonymous.id
        }
      }

      bp.plugins:insert {
        name = "request-termination",
        consumer_id = anonymous.id,
        config = {
          status_code = 403,
          message = "So it goes.",
        }
      }

      assert(helpers.start_kong {
        custom_plugins = "session",
        database   = strategy,
        nginx_conf = "spec/fixtures/custom_nginx.template",
      })
    end)

    teardown(function()
      helpers.stop_kong(nil, true)
    end)

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

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

    describe("kong adapter - ", function()
      it("kong adapter stores consumer", function()  
        local res, cookie
        local request = {
          method = "GET",
          path = "/test1/status/200",
          headers = { host = "httpbin.org", },<commit_msg>tests(session) remove unnecessary preserve options<commit_after>local helpers = require "spec.helpers"
local new_tab = require "table.new"

for _, strategy in helpers.each_strategy() do
  describe("Plugin: Session (kong storage adapter) [#" .. strategy .. "]", function()
    local client, bp

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

      local route1 = bp.routes:insert {
        paths    = {"/test1"},
        hosts = {"httpbin.org"}
      }

      local route2 = bp.routes:insert {
        paths    = {"/test2"},
        hosts = {"httpbin.org"}
      }
      
      assert(bp.plugins:insert {
        name = "session",
        route_id = route1.id,
        config = {
          storage = "kong",
          secret = "ultra top secret session",
        }
      })
      
      assert(bp.plugins:insert {
        name = "session",
        route_id = route2.id,
        config = {
          secret = "super secret session secret",
          storage = "kong",
          cookie_renew = 600,
          cookie_lifetime = 601,
        }
      })

      local consumer = bp.consumers:insert { username = "coop" }
      bp.keyauth_credentials:insert {
        key = "kong",
        consumer_id = consumer.id,
      }

      local anonymous = bp.consumers:insert { username = "anon" }
      bp.plugins:insert {
        name = "key-auth",
        route_id = route1.id,
        config = {
          anonymous = anonymous.id
        }
      }

      bp.plugins:insert {
        name = "key-auth",
        route_id = route2.id,
        config = {
          anonymous = anonymous.id
        }
      }

      bp.plugins:insert {
        name = "request-termination",
        consumer_id = anonymous.id,
        config = {
          status_code = 403,
          message = "So it goes.",
        }
      }

      assert(helpers.start_kong {
        custom_plugins = "session",
        database   = strategy,
        nginx_conf = "spec/fixtures/custom_nginx.template",
      })
    end)

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

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

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

    describe("kong adapter - ", function()
      it("kong adapter stores consumer", function()  
        local res, cookie
        local request = {
          method = "GET",
          path = "/test1/status/200",
          headers = { host = "httpbin.org", },
{'fraction_non_alphanumeric': 0.1180414465664364, 'fraction_numerical': 0.008533116619260463, 'mean_word_length': 1.716887417218543, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4490790', 'n_tokens_mistral': 1508, 'n_tokens_neox': 1445, 'n_words': 315}