<commit_before>const request = require('supertest');
const express = require('express');
const session = require('express-session');
const auth = require('../index');
const { Issuer } = require('openid-client');

Issuer.discover = () => new Issuer({
  issuer: process.env.SDF_OIDC_PROVIDER,
  authorization_endpoint: `${process.env.SDF_OIDC_PROVIDER}/authorize`,
});

let server;
let app;

async function getApp() {
  server = express();
  server.use(session({
    resave: true,
    saveUninitialized: true,
    secret: 'super secret',
  }));

  return auth(server);
}

describe('auth', () => {
  beforeAll(async () => {
    app = await getApp();
  });

  it.skip('redirects to auth provider when hitting /login', async () => {
    process.env.SDF_OIDC_PROVIDER = 'http://example.org/openid';
    process.env.SDF_OIDC_CLIENT_ID = '123456';
    const response = await request(app).get('/auth');
    expect(response.statusCode).toEqual(302);
    expect(response.header).toEqual(
      expect.objectContaining({
        location: expect.stringContaining(process.env.SDF_OIDC_PROVIDER),
      }),
    );
  });

  it('redirects to base page after logging out', async () => {
    const response = await request(app).get('/logout');
    expect(response.statusCode).toEqual(302);
    expect(response.header).toEqual(
      expect.objectContaining({
        location: '/',
      }),
    );
  });
});

describe('openid enabled', () => {
  beforeEach(async () => {
    process.env.SDF_OIDC_PROVIDER = 'http://example.org/openid';
    process.env.SDF_OIDC_CLIENT_ID = '123456';
  });

  afterEach(() => {
    process.env.SDF_OIDC_PROVIDER = '';
    process.env.SDF_OIDC_CLIENT_ID = '';
  });

  it('redirects to OpenID provider when OIDC enabled', async () => {
    app = await getApp();
    const response = await request(app).get('/login');
    expect(response.statusCode).toEqual(302);
    expect(response.header).toEqual(
      expect.objectContaining({
        location: expect.stringContaining(process.env.SDF_OIDC_PROVIDER),
      }),
    );
  });
});<commit_msg>Remove test of oidc-client login redirect logic<commit_after>const request = require('supertest');
const express = require('express');
const session = require('express-session');
const auth = require('../index');
const { Issuer } = require('openid-client');

Issuer.discover = () => new Issuer({
  issuer: process.env.SDF_OIDC_PROVIDER,
  authorization_endpoint: `${process.env.SDF_OIDC_PROVIDER}/authorize`,
});

let server;
let app;

async function getApp() {
  server = express();
  server.use(session({
    resave: true,
    saveUninitialized: true,
    secret: 'super secret',
  }));

  return auth(server);
}

describe('auth', () => {
  beforeAll(async () => {
    app = await getApp();
  });

  it('redirects to base page after logging out', async () => {
    const response = await request(app).get('/logout');
    expect(response.statusCode).toEqual(302);
    expect(response.header).toEqual(
      expect.objectContaining({
        location: '/',
      }),
    );
  });
});
{'fraction_non_alphanumeric': 0.16869450838539954, 'fraction_numerical': 0.007892140743176587, 'mean_word_length': 3.7755102040816326, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 16, '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': '100426', 'n_tokens_mistral': 998, 'n_tokens_neox': 976, 'n_words': 181}