Sha256: 518d950830b5fb165624e1cb7a4c8ee575847da1b4f476c76cbc9151d69a107d

Contents?: true

Size: 1.38 KB

Versions: 1

Compression:

Stored size: 1.38 KB

Contents

require_relative 'test_helper'

module GitHubLdapMembershipValidatorsTestCases
  def make_validator(groups)
    groups = @domain.groups(groups)
    @validator.new(@ldap, groups)
  end

  def test_validates_user_in_group
    validator = make_validator(%w(ghe-users))
    assert validator.perform(@entry)
  end

  def test_does_not_validate_user_not_in_group
    validator = make_validator(%w(ghe-admins))
    refute validator.perform(@entry)
  end

  def test_does_not_validate_user_not_in_any_group
    @entry = @domain.user?('groupless-user1')
    validator = make_validator(%w(ghe-users ghe-admins))
    refute validator.perform(@entry)
  end
end

class GitHubLdapMembershipValidatorsClassicTest < GitHub::Ldap::Test
  include GitHubLdapMembershipValidatorsTestCases

  def setup
    @ldap      = GitHub::Ldap.new(options.merge(search_domains: "dc=github,dc=com"))
    @domain    = @ldap.domain("dc=github,dc=com")
    @entry     = @domain.user?('user1')
    @validator = GitHub::Ldap::MembershipValidators::Classic
  end
end

class GitHubLdapMembershipValidatorsRecursiveTest < GitHub::Ldap::Test
  include GitHubLdapMembershipValidatorsTestCases

  def setup
    @ldap      = GitHub::Ldap.new(options.merge(search_domains: "dc=github,dc=com"))
    @domain    = @ldap.domain("dc=github,dc=com")
    @entry     = @domain.user?('user1')
    @validator = GitHub::Ldap::MembershipValidators::Recursive
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
github-ldap-1.4.0 test/membership_validators_test.rb