mirror of
https://github.com/zoriya/octokit.net.git
synced 2025-12-06 07:16:09 +00:00
Rework tests. Note that test user and distinguished names have been replaced with generic values as we cant reveal our own domain details
This commit is contained in:
committed by
Ryan Gribble
parent
e4eb1166b7
commit
8be8c41966
@@ -6,12 +6,15 @@ using Octokit.Tests.Integration;
|
||||
using Octokit.Tests.Integration.Helpers;
|
||||
using Xunit;
|
||||
|
||||
public class EnterpriseLdapClientTests
|
||||
public class EnterpriseLdapClientTests : IDisposable
|
||||
{
|
||||
readonly IGitHubClient _github;
|
||||
readonly EnterpriseTeamContext _context;
|
||||
|
||||
readonly string _testUser = "test-user";
|
||||
readonly string _distinguishedNameUser = "uid=test-user,ou=users,dc=company,dc=com";
|
||||
readonly string _distinguishedNameTeam = "uid=DG-Test-Team,ou=groups,dc=company,dc=com";
|
||||
|
||||
readonly EnterpriseTeamContext _context;
|
||||
readonly string _distinguishedNameTeam = "cn=test-team,ou=groups,dc=company,dc=com";
|
||||
|
||||
public EnterpriseLdapClientTests()
|
||||
{
|
||||
@@ -26,26 +29,28 @@ public class EnterpriseLdapClientTests
|
||||
{
|
||||
var newLDAPMapping = new NewLdapMapping(_distinguishedNameUser);
|
||||
var ldapUser = await
|
||||
_github.Enterprise.Ldap.UpdateUserMapping(EnterpriseHelper.UserName, newLDAPMapping);
|
||||
_github.Enterprise.Ldap.UpdateUserMapping(_testUser, newLDAPMapping);
|
||||
|
||||
Assert.NotNull(ldapUser);
|
||||
Assert.NotNull(ldapUser.LdapDn);
|
||||
Assert.Equal(ldapUser.LdapDn, _distinguishedNameUser);
|
||||
|
||||
// Get user and check mapping was updated
|
||||
var checkUser = await _github.User.Get(EnterpriseHelper.UserName);
|
||||
var checkUser = await _github.User.Get(_testUser);
|
||||
Assert.Equal(checkUser.Login, ldapUser.Login);
|
||||
//Assert.Equal(checkUser.LdapDN, _distinguishedNameUser);
|
||||
Assert.Equal(checkUser.LdapDn, _distinguishedNameUser);
|
||||
}
|
||||
|
||||
[GitHubEnterpriseTest]
|
||||
public async Task CanQueueSyncUserMapping()
|
||||
{
|
||||
var response = await
|
||||
_github.Enterprise.Ldap.QueueSyncUserMapping(EnterpriseHelper.UserName);
|
||||
_github.Enterprise.Ldap.QueueSyncUserMapping(_testUser);
|
||||
|
||||
// Check response message indicates LDAP sync was queued
|
||||
Assert.NotNull(response);
|
||||
Assert.NotNull(response.Status);
|
||||
Assert.True(response.Status.All(m => m.Contains("was added to the indexing queue")));
|
||||
Assert.True(response.Status == "queued");
|
||||
}
|
||||
|
||||
[GitHubEnterpriseTest]
|
||||
@@ -56,11 +61,13 @@ public class EnterpriseLdapClientTests
|
||||
_github.Enterprise.Ldap.UpdateTeamMapping(_context.TeamId, newLDAPMapping);
|
||||
|
||||
Assert.NotNull(ldapTeam);
|
||||
Assert.NotNull(ldapTeam.LdapDn);
|
||||
Assert.Equal(ldapTeam.LdapDn, _distinguishedNameTeam);
|
||||
|
||||
// Get Team and check mapping was updated
|
||||
var checkTeam = await _github.Organization.Team.Get(_context.TeamId);
|
||||
Assert.Equal(checkTeam.Name, ldapTeam.Name);
|
||||
//Assert.Equal(checkTeam.LDAPDN, _fixtureDistinguishedNameTeam);
|
||||
Assert.Equal(checkTeam.LdapDn, _distinguishedNameTeam);
|
||||
}
|
||||
|
||||
[GitHubEnterpriseTest]
|
||||
@@ -72,6 +79,11 @@ public class EnterpriseLdapClientTests
|
||||
// Check response message indicates LDAP sync was queued
|
||||
Assert.NotNull(response);
|
||||
Assert.NotNull(response.Status);
|
||||
Assert.True(response.Status.All(m => m.Contains("was added to the indexing queue")));
|
||||
Assert.True(response.Status == "queued");
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_context.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,13 +8,16 @@ using Xunit;
|
||||
|
||||
namespace Octokit.Tests.Integration
|
||||
{
|
||||
public class ObservableEnterpriseLdapClientTests
|
||||
public class ObservableEnterpriseLdapClientTests : IDisposable
|
||||
{
|
||||
readonly IObservableGitHubClient _github;
|
||||
readonly EnterpriseTeamContext _context;
|
||||
readonly string _distinguishedNameUser = "uid=test-user,ou=users,dc=company,dc=com";
|
||||
readonly string _distinguishedNameTeam = "uid=DG-Test-Team,ou=groups,dc=company,dc=com";
|
||||
|
||||
readonly string _testUser = "test-user";
|
||||
readonly string _distinguishedNameUser = "uid=test-user,ou=users,dc=company,dc=com";
|
||||
|
||||
readonly EnterpriseTeamContext _context;
|
||||
readonly string _distinguishedNameTeam = "cn=test-team,ou=groups,dc=company,dc=com";
|
||||
|
||||
public ObservableEnterpriseLdapClientTests()
|
||||
{
|
||||
var gitHub = EnterpriseHelper.GetAuthenticatedClient();
|
||||
@@ -29,28 +32,30 @@ namespace Octokit.Tests.Integration
|
||||
{
|
||||
var newLDAPMapping = new NewLdapMapping(_distinguishedNameUser);
|
||||
var observable =
|
||||
_github.Enterprise.Ldap.UpdateUserMapping(EnterpriseHelper.UserName, newLDAPMapping);
|
||||
_github.Enterprise.Ldap.UpdateUserMapping(_testUser, newLDAPMapping);
|
||||
var ldapUser = await observable;
|
||||
|
||||
Assert.NotNull(ldapUser);
|
||||
Assert.NotNull(ldapUser.LdapDn);
|
||||
Assert.Equal(ldapUser.LdapDn, _distinguishedNameUser);
|
||||
|
||||
// Get user and check mapping was updated
|
||||
var checkUser = await _github.User.Get(EnterpriseHelper.UserName);
|
||||
var checkUser = await _github.User.Get(_testUser);
|
||||
Assert.Equal(checkUser.Login, ldapUser.Login);
|
||||
//Assert.Equal(checkUser.LdapDN, _distinguishedNameUser);
|
||||
Assert.Equal(checkUser.LdapDn, _distinguishedNameUser);
|
||||
}
|
||||
|
||||
[GitHubEnterpriseTest]
|
||||
public async Task CanQueueSyncUserMapping()
|
||||
{
|
||||
var observable =
|
||||
_github.Enterprise.Ldap.QueueSyncUserMapping(EnterpriseHelper.UserName);
|
||||
_github.Enterprise.Ldap.QueueSyncUserMapping(_testUser);
|
||||
var response = await observable;
|
||||
|
||||
// Check response message indicates LDAP sync was queued
|
||||
Assert.NotNull(response);
|
||||
Assert.NotNull(response.Status);
|
||||
Assert.True(response.Status.All(m => m.Contains("was added to the indexing queue")));
|
||||
Assert.True(response.Status == "queued");
|
||||
}
|
||||
|
||||
[GitHubEnterpriseTest]
|
||||
@@ -62,11 +67,13 @@ namespace Octokit.Tests.Integration
|
||||
var ldapTeam = await observable;
|
||||
|
||||
Assert.NotNull(ldapTeam);
|
||||
Assert.NotNull(ldapTeam.LdapDn);
|
||||
Assert.Equal(ldapTeam.LdapDn, _distinguishedNameTeam);
|
||||
|
||||
// Get Team and check mapping was updated
|
||||
var checkTeam = await _github.Organization.Team.Get(_context.TeamId);
|
||||
Assert.Equal(checkTeam.Name, ldapTeam.Name);
|
||||
//Assert.Equal(checkTeam.LdapDN, _distinguishedNameTeam);
|
||||
Assert.Equal(checkTeam.LdapDn, _distinguishedNameTeam);
|
||||
}
|
||||
|
||||
[GitHubEnterpriseTest]
|
||||
@@ -79,7 +86,12 @@ namespace Octokit.Tests.Integration
|
||||
// Check response message indicates LDAP sync was queued
|
||||
Assert.NotNull(response);
|
||||
Assert.NotNull(response.Status);
|
||||
Assert.True(response.Status.All(m => m.Contains("was added to the indexing queue")));
|
||||
Assert.True(response.Status == "queued");
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_context.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace Octokit.Tests.Clients
|
||||
string expectedUri = "admin/ldap/users/test-user/mapping";
|
||||
client.UpdateUserMapping("test-user", new NewLdapMapping(_distinguishedNameUser));
|
||||
|
||||
connection.Received().Patch<LdapUser>(Arg.Is<Uri>(u => u.ToString() == expectedUri), Arg.Any<object>());
|
||||
connection.Received().Patch<User>(Arg.Is<Uri>(u => u.ToString() == expectedUri), Arg.Any<object>());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -31,10 +31,10 @@ namespace Octokit.Tests.Clients
|
||||
|
||||
client.UpdateUserMapping("test-user", new NewLdapMapping(_distinguishedNameUser));
|
||||
|
||||
connection.Received().Patch<LdapUser>(
|
||||
connection.Received().Patch<User>(
|
||||
Arg.Any<Uri>(),
|
||||
Arg.Is<NewLdapMapping>(a =>
|
||||
a.LdapDN == _distinguishedNameUser));
|
||||
a.LdapDn == _distinguishedNameUser));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -86,7 +86,7 @@ namespace Octokit.Tests.Clients
|
||||
string expectedUri = "admin/ldap/teams/1/mapping";
|
||||
client.UpdateTeamMapping(1, new NewLdapMapping(_distinguishedNameTeam));
|
||||
|
||||
connection.Received().Patch<LdapTeam>(
|
||||
connection.Received().Patch<Team>(
|
||||
Arg.Is<Uri>(u => u.ToString() == expectedUri),
|
||||
Arg.Any<object>());
|
||||
}
|
||||
@@ -99,10 +99,10 @@ namespace Octokit.Tests.Clients
|
||||
|
||||
client.UpdateTeamMapping(1, new NewLdapMapping(_distinguishedNameTeam));
|
||||
|
||||
connection.Received().Patch<LdapTeam>(
|
||||
connection.Received().Patch<Team>(
|
||||
Arg.Any<Uri>(),
|
||||
Arg.Is<NewLdapMapping>(a =>
|
||||
a.LdapDN == _distinguishedNameTeam));
|
||||
a.LdapDn == _distinguishedNameTeam));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace Octokit.Tests
|
||||
github.Enterprise.Ldap.Received(1).UpdateUserMapping(
|
||||
Arg.Is<string>(a => a == "test-user"),
|
||||
Arg.Is<NewLdapMapping>(a =>
|
||||
a.LdapDN == _distinguishedName));
|
||||
a.LdapDn == _distinguishedName));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace Octokit.Tests
|
||||
|
||||
public class TheUpdateTeamMappingMethod
|
||||
{
|
||||
readonly string _distinguishedName = "uid=DG-Test-Team,ou=groups,dc=company,dc=com";
|
||||
readonly string _distinguishedName = "cn=test-team,ou=groups,dc=company,dc=com";
|
||||
|
||||
[Fact]
|
||||
public void CallsIntoClient()
|
||||
@@ -53,7 +53,7 @@ namespace Octokit.Tests
|
||||
github.Enterprise.Ldap.Received(1).UpdateTeamMapping(
|
||||
Arg.Is<int>(a => a == 1),
|
||||
Arg.Is<NewLdapMapping>(a =>
|
||||
a.LdapDN == _distinguishedName));
|
||||
a.LdapDn == _distinguishedName));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user