import { describe, it, expect } from 'vitest';
import { LdapTeamDirectory } from './ldapTeamClient';

// Hits real CSC infrastructure (anonymous LDAP read access is sanctioned
// CSC-wide, confirmed earlier in this project) -- not mocked, so this
// proves the query actually works against ldap1.csclub.uwaterloo.ca.
describe('LdapTeamDirectory (live)', () => {
  it('returns [] for a made-up username against a real group', async () => {
    const directory = new LdapTeamDirectory({
      url: 'ldap://ldap1.csclub.uwaterloo.ca',
      baseDn: 'dc=csclub,dc=uwaterloo,dc=ca',
    });
    const teams = await directory.getTeamsForUser('this-username-should-not-exist-xyz', ['termcom']);
    expect(teams).toEqual([]);
  }, 10000);

  it('returns [] for any candidate team that does not exist in LDAP', async () => {
    const directory = new LdapTeamDirectory({
      url: 'ldap://ldap1.csclub.uwaterloo.ca',
      baseDn: 'dc=csclub,dc=uwaterloo,dc=ca',
    });
    const teams = await directory.getTeamsForUser('j47ho', ['this-group-should-not-exist-xyz']);
    expect(teams).toEqual([]);
  }, 10000);
});
