<commit_before>local http = require("socket.http")
local test_support = require("test_support")
require 'busted.runner'()

describe("if there is an active non-expired login", function()
  test_support.start_server()
  teardown(test_support.stop_server)
  local _, _, cookies = test_support.login()
  local _, status = http.request({
    url = "http://localhost/default/t",
    redirect = false,
    headers = { cookie = cookies },
  })
  it("no redirect occurs on the next call", function()
    assert.are.equals(200, status)
  end)
  it("the access token is returned by authenticate", function()
    assert.is_not.error_log_contains("authenticate didn't return any access token")
  end)
end)

-- see https://github.com/zmartzone/lua-resty-openidc/issues/121
describe("if there is an active non-expired login and renew is disabled explicitly", function()
  test_support.start_server()
  teardown(test_support.stop_server)<commit_msg>test wasn't testing what it claimed to<commit_after>local http = require("socket.http")
local test_support = require("test_support")
require 'busted.runner'()

describe("if there is an active non-expired login", function()
  test_support.start_server()
  teardown(test_support.stop_server)
  local _, _, cookies = test_support.login()
  local _, status = http.request({
    url = "http://localhost/default/t",
    redirect = false,
    headers = { cookie = cookies },
  })
  it("no redirect occurs on the next call", function()
    assert.are.equals(200, status)
  end)
  it("the access token is returned by authenticate", function()
    assert.is_not.error_log_contains("authenticate didn't return any access token")
  end)
end)

-- see https://github.com/zmartzone/lua-resty-openidc/issues/121
describe("if there is an active non-expired login and renew is disabled explicitly", function()
  test_support.start_server({
    oidc_opts = {
      renew_access_token_on_expiry = false
    }
  })
  teardown(test_support.stop_server)
{'fraction_non_alphanumeric': 0.11869587366276108, 'fraction_numerical': 0.006113092205807438, 'mean_word_length': 4.532394366197183, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '6519873', 'n_tokens_mistral': 615, 'n_tokens_neox': 592, 'n_words': 158}