diff --git a/Octokit.Tests.Integration/Clients/Enterprise/EnterpriseLdapClientTests.cs b/Octokit.Tests.Integration/Clients/Enterprise/EnterpriseLdapClientTests.cs index ff6bad79..da837b17 100644 --- a/Octokit.Tests.Integration/Clients/Enterprise/EnterpriseLdapClientTests.cs +++ b/Octokit.Tests.Integration/Clients/Enterprise/EnterpriseLdapClientTests.cs @@ -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(); } } diff --git a/Octokit.Tests.Integration/Reactive/Enterprise/ObservableEnterpriseLdapClientTests.cs b/Octokit.Tests.Integration/Reactive/Enterprise/ObservableEnterpriseLdapClientTests.cs index 99099ac9..1d7c6749 100644 --- a/Octokit.Tests.Integration/Reactive/Enterprise/ObservableEnterpriseLdapClientTests.cs +++ b/Octokit.Tests.Integration/Reactive/Enterprise/ObservableEnterpriseLdapClientTests.cs @@ -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(); } } } diff --git a/Octokit.Tests/Clients/Enterprise/EnterpriseLdapClientTests.cs b/Octokit.Tests/Clients/Enterprise/EnterpriseLdapClientTests.cs index ee30b8e6..4d0d0e06 100644 --- a/Octokit.Tests/Clients/Enterprise/EnterpriseLdapClientTests.cs +++ b/Octokit.Tests/Clients/Enterprise/EnterpriseLdapClientTests.cs @@ -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(Arg.Is(u => u.ToString() == expectedUri), Arg.Any()); + connection.Received().Patch(Arg.Is(u => u.ToString() == expectedUri), Arg.Any()); } [Fact] @@ -31,10 +31,10 @@ namespace Octokit.Tests.Clients client.UpdateUserMapping("test-user", new NewLdapMapping(_distinguishedNameUser)); - connection.Received().Patch( + connection.Received().Patch( Arg.Any(), Arg.Is(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( + connection.Received().Patch( Arg.Is(u => u.ToString() == expectedUri), Arg.Any()); } @@ -99,10 +99,10 @@ namespace Octokit.Tests.Clients client.UpdateTeamMapping(1, new NewLdapMapping(_distinguishedNameTeam)); - connection.Received().Patch( + connection.Received().Patch( Arg.Any(), Arg.Is(a => - a.LdapDN == _distinguishedNameTeam)); + a.LdapDn == _distinguishedNameTeam)); } [Fact] diff --git a/Octokit.Tests/Reactive/Enterprise/ObservableEnterpriseLdapClientTests.cs b/Octokit.Tests/Reactive/Enterprise/ObservableEnterpriseLdapClientTests.cs index c8779945..c23bfbfc 100644 --- a/Octokit.Tests/Reactive/Enterprise/ObservableEnterpriseLdapClientTests.cs +++ b/Octokit.Tests/Reactive/Enterprise/ObservableEnterpriseLdapClientTests.cs @@ -21,7 +21,7 @@ namespace Octokit.Tests github.Enterprise.Ldap.Received(1).UpdateUserMapping( Arg.Is(a => a == "test-user"), Arg.Is(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(a => a == 1), Arg.Is(a => - a.LdapDN == _distinguishedName)); + a.LdapDn == _distinguishedName)); } }