diff --git a/Octokit.Reactive/Clients/Enterprise/IObservableEnterpriseClient.cs b/Octokit.Reactive/Clients/Enterprise/IObservableEnterpriseClient.cs
index 74186a8f67..018c48e8de 100644
--- a/Octokit.Reactive/Clients/Enterprise/IObservableEnterpriseClient.cs
+++ b/Octokit.Reactive/Clients/Enterprise/IObservableEnterpriseClient.cs
@@ -16,6 +16,14 @@ public interface IObservableEnterpriseClient
///
IObservableEnterpriseAdminStatsClient AdminStats { get; }
+ ///
+ /// A client for GitHub's Enterprise LDAP API
+ ///
+ ///
+ /// See the Enterprise LDAP API documentation for more information.
+ ///
+ IObservableEnterpriseLdapClient Ldap { get; }
+
///
/// A client for GitHub's Enterprise License API
///
diff --git a/Octokit.Reactive/Clients/Enterprise/IObservableEnterpriseLdapClient.cs b/Octokit.Reactive/Clients/Enterprise/IObservableEnterpriseLdapClient.cs
new file mode 100644
index 0000000000..d5f4bd1f68
--- /dev/null
+++ b/Octokit.Reactive/Clients/Enterprise/IObservableEnterpriseLdapClient.cs
@@ -0,0 +1,58 @@
+using System;
+using System.Diagnostics.CodeAnalysis;
+using System.Reactive;
+using System.Reactive.Threading.Tasks;
+
+namespace Octokit.Reactive
+{
+ ///
+ /// A client for GitHub's Enterprise LDAP API
+ ///
+ ///
+ /// See the Enterprise LDAP API documentation for more information.
+ ///
+ public interface IObservableEnterpriseLdapClient
+ {
+ ///
+ /// Update the LDAP mapping for a user on a GitHub Enterprise appliance (must be Site Admin user).
+ ///
+ ///
+ /// https://developer.github.com/v3/enterprise/ldap/#update-ldap-mapping-for-a-user
+ ///
+ /// The username to update LDAP mapping
+ /// The
+ /// The object.
+ IObservable UpdateUserMapping(string userName, NewLdapMapping newLdapMapping);
+
+ ///
+ /// Queue an LDAP Sync job for a user on a GitHub Enterprise appliance (must be Site Admin user).
+ ///
+ ///
+ /// https://developer.github.com/v3/enterprise/ldap/#sync-ldap-mapping-for-a-user
+ ///
+ /// The username to sync LDAP mapping
+ /// The of the queue request.
+ IObservable QueueSyncUserMapping(string userName);
+
+ ///
+ /// Update the LDAP mapping for a team on a GitHub Enterprise appliance (must be Site Admin user).
+ ///
+ ///
+ /// https://developer.github.com/v3/enterprise/ldap/#update-ldap-mapping-for-a-team
+ ///
+ /// The teamId to update LDAP mapping
+ /// The
+ /// The object.
+ IObservable UpdateTeamMapping(int teamId, NewLdapMapping newLdapMapping);
+
+ ///
+ /// Queue an LDAP Sync job for a team on a GitHub Enterprise appliance (must be Site Admin user).
+ ///
+ ///
+ /// https://developer.github.com/v3/enterprise/ldap/#sync-ldap-mapping-for-a-team
+ ///
+ /// The teamId to update LDAP mapping
+ /// The of the queue request.
+ IObservable QueueSyncTeamMapping(int teamId);
+ }
+}
diff --git a/Octokit.Reactive/Clients/Enterprise/ObservableEnterpriseClient.cs b/Octokit.Reactive/Clients/Enterprise/ObservableEnterpriseClient.cs
index 0aa4c9201f..a463212a72 100644
--- a/Octokit.Reactive/Clients/Enterprise/ObservableEnterpriseClient.cs
+++ b/Octokit.Reactive/Clients/Enterprise/ObservableEnterpriseClient.cs
@@ -13,6 +13,7 @@ public ObservableEnterpriseClient(IGitHubClient client)
Ensure.ArgumentNotNull(client, "client");
AdminStats = new ObservableEnterpriseAdminStatsClient(client);
+ Ldap = new ObservableEnterpriseLdapClient(client);
License = new ObservableEnterpriseLicenseClient(client);
Organization = new ObservableEnterpriseOrganizationClient(client);
SearchIndexing = new ObservableEnterpriseSearchIndexingClient(client);
@@ -26,6 +27,14 @@ public ObservableEnterpriseClient(IGitHubClient client)
///
public IObservableEnterpriseAdminStatsClient AdminStats { get; private set; }
+ ///
+ /// A client for GitHub's Enterprise LDAP API
+ ///
+ ///
+ /// See the Enterprise LDAP API documentation for more information.
+ ///
+ public IObservableEnterpriseLdapClient Ldap { get; private set; }
+
///
/// A client for GitHub's Enterprise License API
///
diff --git a/Octokit.Reactive/Clients/Enterprise/ObservableEnterpriseLdapClient.cs b/Octokit.Reactive/Clients/Enterprise/ObservableEnterpriseLdapClient.cs
new file mode 100644
index 0000000000..f096e496ab
--- /dev/null
+++ b/Octokit.Reactive/Clients/Enterprise/ObservableEnterpriseLdapClient.cs
@@ -0,0 +1,80 @@
+using System;
+using System.Reactive;
+using System.Reactive.Threading.Tasks;
+using Octokit;
+
+
+namespace Octokit.Reactive
+{
+ ///
+ /// A client for GitHub's Enterprise LDAP API
+ ///
+ ///
+ /// See the Enterprise LDAP API documentation for more information.
+ ///
+ public class ObservableEnterpriseLdapClient : IObservableEnterpriseLdapClient
+ {
+ readonly IEnterpriseLdapClient _client;
+
+ public ObservableEnterpriseLdapClient(IGitHubClient client)
+ {
+ Ensure.ArgumentNotNull(client, "client");
+
+ _client = client.Enterprise.Ldap;
+ }
+
+ ///
+ /// Update the LDAP mapping for a user on a GitHub Enterprise appliance (must be Site Admin user).
+ ///
+ ///
+ /// https://developer.github.com/v3/enterprise/ldap/#update-ldap-mapping-for-a-user
+ ///
+ /// The username to update LDAP mapping
+ /// The
+ /// The object.
+ public IObservable UpdateUserMapping(string userName, NewLdapMapping newLdapMapping)
+ {
+ return _client.UpdateUserMapping(userName, newLdapMapping).ToObservable();
+ }
+
+ ///
+ /// Queue an LDAP Sync job for a user on a GitHub Enterprise appliance (must be Site Admin user).
+ ///
+ ///
+ /// https://developer.github.com/v3/enterprise/ldap/#sync-ldap-mapping-for-a-user
+ ///
+ /// The username to sync LDAP mapping
+ /// The of the queue request.
+ public IObservable QueueSyncUserMapping(string userName)
+ {
+ return _client.QueueSyncUserMapping(userName).ToObservable();
+ }
+
+ ///
+ /// Update the LDAP mapping for a team on a GitHub Enterprise appliance (must be Site Admin user).
+ ///
+ ///
+ /// https://developer.github.com/v3/enterprise/ldap/#update-ldap-mapping-for-a-team
+ ///
+ /// The teamId to update LDAP mapping
+ /// The
+ /// The object.
+ public IObservable UpdateTeamMapping(int teamId, NewLdapMapping newLdapMapping)
+ {
+ return _client.UpdateTeamMapping(teamId, newLdapMapping).ToObservable();
+ }
+
+ ///
+ /// Queue an LDAP Sync job for a team on a GitHub Enterprise appliance (must be Site Admin user).
+ ///
+ ///
+ /// https://developer.github.com/v3/enterprise/ldap/#sync-ldap-mapping-for-a-team
+ ///
+ /// The teamId to update LDAP mapping
+ /// The of the queue request.
+ public IObservable QueueSyncTeamMapping(int teamId)
+ {
+ return _client.QueueSyncTeamMapping(teamId).ToObservable();
+ }
+ }
+}
diff --git a/Octokit.Reactive/Octokit.Reactive-Mono.csproj b/Octokit.Reactive/Octokit.Reactive-Mono.csproj
index 10d634574d..41db98100a 100644
--- a/Octokit.Reactive/Octokit.Reactive-Mono.csproj
+++ b/Octokit.Reactive/Octokit.Reactive-Mono.csproj
@@ -171,6 +171,8 @@
+
+
diff --git a/Octokit.Reactive/Octokit.Reactive-MonoAndroid.csproj b/Octokit.Reactive/Octokit.Reactive-MonoAndroid.csproj
index d0f878da13..2a01d4da5a 100644
--- a/Octokit.Reactive/Octokit.Reactive-MonoAndroid.csproj
+++ b/Octokit.Reactive/Octokit.Reactive-MonoAndroid.csproj
@@ -179,6 +179,8 @@
+
+
diff --git a/Octokit.Reactive/Octokit.Reactive-Monotouch.csproj b/Octokit.Reactive/Octokit.Reactive-Monotouch.csproj
index ce3efdbed0..c3855b708a 100644
--- a/Octokit.Reactive/Octokit.Reactive-Monotouch.csproj
+++ b/Octokit.Reactive/Octokit.Reactive-Monotouch.csproj
@@ -175,6 +175,8 @@
+
+
diff --git a/Octokit.Reactive/Octokit.Reactive.csproj b/Octokit.Reactive/Octokit.Reactive.csproj
index 607a71eb74..4c69b57fee 100644
--- a/Octokit.Reactive/Octokit.Reactive.csproj
+++ b/Octokit.Reactive/Octokit.Reactive.csproj
@@ -75,6 +75,7 @@
Properties\SolutionInfo.cs
+
@@ -82,6 +83,7 @@
+
diff --git a/Octokit.Tests.Integration/Clients/Enterprise/EnterpriseLdapClientTests.cs b/Octokit.Tests.Integration/Clients/Enterprise/EnterpriseLdapClientTests.cs
new file mode 100644
index 0000000000..edbca49664
--- /dev/null
+++ b/Octokit.Tests.Integration/Clients/Enterprise/EnterpriseLdapClientTests.cs
@@ -0,0 +1,89 @@
+using System;
+using System.Linq;
+using System.Threading.Tasks;
+using Octokit;
+using Octokit.Tests.Integration;
+using Octokit.Tests.Integration.Helpers;
+using Xunit;
+
+public class EnterpriseLdapClientTests : IDisposable
+{
+ readonly IGitHubClient _github;
+
+ 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 EnterpriseLdapClientTests()
+ {
+ _github = EnterpriseHelper.GetAuthenticatedClient();
+
+ NewTeam newTeam = new NewTeam(Helper.MakeNameWithTimestamp("test-team")) { Description = "Test Team" };
+ _context = _github.CreateEnterpriseTeamContext(EnterpriseHelper.Organization, newTeam).Result;
+ }
+
+ [GitHubEnterpriseTest]
+ public async Task CanUpdateUserMapping()
+ {
+ var newLDAPMapping = new NewLdapMapping(_distinguishedNameUser);
+ var ldapUser = await
+ _github.Enterprise.Ldap.UpdateUserMapping(_testUser, newLDAPMapping);
+
+ Assert.NotNull(ldapUser);
+ Assert.NotNull(ldapUser.LdapDistinguishedName);
+ Assert.Equal(ldapUser.LdapDistinguishedName, _distinguishedNameUser);
+
+ // Get user and check mapping was updated
+ var checkUser = await _github.User.Get(_testUser);
+ Assert.Equal(checkUser.Login, ldapUser.Login);
+ Assert.Equal(checkUser.LdapDistinguishedName, _distinguishedNameUser);
+ }
+
+ [GitHubEnterpriseTest]
+ public async Task CanQueueSyncUserMapping()
+ {
+ var response = await
+ _github.Enterprise.Ldap.QueueSyncUserMapping(_testUser);
+
+ // Check response message indicates LDAP sync was queued
+ Assert.NotNull(response);
+ Assert.NotNull(response.Status);
+ Assert.True(response.Status == "queued");
+ }
+
+ [GitHubEnterpriseTest]
+ public async Task CanUpdateTeamMapping()
+ {
+ var newLDAPMapping = new NewLdapMapping(_distinguishedNameTeam);
+ var ldapTeam = await
+ _github.Enterprise.Ldap.UpdateTeamMapping(_context.TeamId, newLDAPMapping);
+
+ Assert.NotNull(ldapTeam);
+ Assert.NotNull(ldapTeam.LdapDistinguishedName);
+ Assert.Equal(ldapTeam.LdapDistinguishedName, _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.LdapDistinguishedName, _distinguishedNameTeam);
+ }
+
+ [GitHubEnterpriseTest]
+ public async Task CanQueueSyncTeamMapping()
+ {
+ var response = await
+ _github.Enterprise.Ldap.QueueSyncTeamMapping(_context.TeamId);
+
+ // Check response message indicates LDAP sync was queued
+ Assert.NotNull(response);
+ Assert.NotNull(response.Status);
+ Assert.True(response.Status == "queued");
+ }
+
+ public void Dispose()
+ {
+ _context.Dispose();
+ }
+}
diff --git a/Octokit.Tests.Integration/EnterpriseHelper.cs b/Octokit.Tests.Integration/EnterpriseHelper.cs
index 9a1ab54e06..63323012cc 100644
--- a/Octokit.Tests.Integration/EnterpriseHelper.cs
+++ b/Octokit.Tests.Integration/EnterpriseHelper.cs
@@ -124,6 +124,22 @@ public static void DeleteRepo(string owner, string name)
catch { }
}
+ public static void DeleteTeam(Team team)
+ {
+ if (team != null)
+ DeleteTeam(team.Id);
+ }
+
+ public static void DeleteTeam(int teamId)
+ {
+ var api = GetAuthenticatedClient();
+ try
+ {
+ api.Organization.Team.Delete(teamId).Wait(TimeSpan.FromSeconds(15));
+ }
+ catch { }
+ }
+
public static IGitHubClient GetAuthenticatedClient()
{
return new GitHubClient(new ProductHeaderValue("OctokitEnterpriseTests"), GitHubEnterpriseUrl)
diff --git a/Octokit.Tests.Integration/Helpers/EnterpriseTeamContext.cs b/Octokit.Tests.Integration/Helpers/EnterpriseTeamContext.cs
new file mode 100644
index 0000000000..3b910a2af3
--- /dev/null
+++ b/Octokit.Tests.Integration/Helpers/EnterpriseTeamContext.cs
@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Octokit.Tests.Integration.Helpers
+{
+ internal sealed class EnterpriseTeamContext : IDisposable
+ {
+ internal EnterpriseTeamContext(Team team)
+ {
+ Team = team;
+ TeamId = team.Id;
+ TeamName = team.Name;
+ }
+
+ internal int TeamId { get; private set; }
+ internal string TeamName { get; private set; }
+
+ internal Team Team { get; private set; }
+
+ public void Dispose()
+ {
+ EnterpriseHelper.DeleteTeam(Team);
+ }
+ }
+}
diff --git a/Octokit.Tests.Integration/Helpers/GithubClientExtensions.cs b/Octokit.Tests.Integration/Helpers/GithubClientExtensions.cs
index 58c53d0512..badd2b5623 100644
--- a/Octokit.Tests.Integration/Helpers/GithubClientExtensions.cs
+++ b/Octokit.Tests.Integration/Helpers/GithubClientExtensions.cs
@@ -29,5 +29,12 @@ internal async static Task CreateRepositoryContext(this IGitH
return new RepositoryContext(repo);
}
+
+ internal async static Task CreateEnterpriseTeamContext(this IGitHubClient client, string organization, NewTeam newTeam)
+ {
+ var team = await client.Organization.Team.Create(organization, newTeam);
+
+ return new EnterpriseTeamContext(team);
+ }
}
}
\ No newline at end of file
diff --git a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj
index 329cae99d6..d12eff12fd 100644
--- a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj
+++ b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj
@@ -77,6 +77,7 @@
+
@@ -118,6 +119,7 @@
+
@@ -128,6 +130,7 @@
+
diff --git a/Octokit.Tests.Integration/Reactive/Enterprise/ObservableEnterpriseLdapClientTests.cs b/Octokit.Tests.Integration/Reactive/Enterprise/ObservableEnterpriseLdapClientTests.cs
new file mode 100644
index 0000000000..0880616259
--- /dev/null
+++ b/Octokit.Tests.Integration/Reactive/Enterprise/ObservableEnterpriseLdapClientTests.cs
@@ -0,0 +1,97 @@
+using System;
+using System.Linq;
+using System.Reactive.Linq;
+using System.Threading.Tasks;
+using Octokit.Reactive;
+using Octokit.Tests.Integration.Helpers;
+using Xunit;
+
+namespace Octokit.Tests.Integration
+{
+ public class ObservableEnterpriseLdapClientTests : IDisposable
+ {
+ readonly IObservableGitHubClient _github;
+
+ 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();
+ _github = new ObservableGitHubClient(gitHub);
+
+ NewTeam newTeam = new NewTeam(Helper.MakeNameWithTimestamp("test-team")) { Description = "Test Team" };
+ _context = gitHub.CreateEnterpriseTeamContext(EnterpriseHelper.Organization, newTeam).Result;
+ }
+
+ [GitHubEnterpriseTest]
+ public async Task CanUpdateUserMapping()
+ {
+ var newLDAPMapping = new NewLdapMapping(_distinguishedNameUser);
+ var observable =
+ _github.Enterprise.Ldap.UpdateUserMapping(_testUser, newLDAPMapping);
+ var ldapUser = await observable;
+
+ Assert.NotNull(ldapUser);
+ Assert.NotNull(ldapUser.LdapDistinguishedName);
+ Assert.Equal(ldapUser.LdapDistinguishedName, _distinguishedNameUser);
+
+ // Get user and check mapping was updated
+ var checkUser = await _github.User.Get(_testUser);
+ Assert.Equal(checkUser.Login, ldapUser.Login);
+ Assert.Equal(checkUser.LdapDistinguishedName, _distinguishedNameUser);
+ }
+
+ [GitHubEnterpriseTest]
+ public async Task CanQueueSyncUserMapping()
+ {
+ var observable =
+ _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 == "queued");
+ }
+
+ [GitHubEnterpriseTest]
+ public async Task CanUpdateTeamMapping()
+ {
+ var newLDAPMapping = new NewLdapMapping(_distinguishedNameTeam);
+ var observable =
+ _github.Enterprise.Ldap.UpdateTeamMapping(_context.TeamId, newLDAPMapping);
+ var ldapTeam = await observable;
+
+ Assert.NotNull(ldapTeam);
+ Assert.NotNull(ldapTeam.LdapDistinguishedName);
+ Assert.Equal(ldapTeam.LdapDistinguishedName, _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.LdapDistinguishedName, _distinguishedNameTeam);
+ }
+
+ [GitHubEnterpriseTest]
+ public async Task CanQueueSyncTeamMapping()
+ {
+ var observable =
+ _github.Enterprise.Ldap.QueueSyncTeamMapping(_context.TeamId);
+ var response = await observable;
+
+ // Check response message indicates LDAP sync was queued
+ Assert.NotNull(response);
+ Assert.NotNull(response.Status);
+ 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
new file mode 100644
index 0000000000..d5ea1c4d4e
--- /dev/null
+++ b/Octokit.Tests/Clients/Enterprise/EnterpriseLdapClientTests.cs
@@ -0,0 +1,134 @@
+using System;
+using System.Threading.Tasks;
+using NSubstitute;
+using Xunit;
+
+namespace Octokit.Tests.Clients
+{
+ public class EnterpriseLdapClientTests
+ {
+ public class TheUpdateUserMappingMethod
+ {
+ readonly string _distinguishedNameUser = "uid=test-user,ou=users,dc=company,dc=com";
+
+ [Fact]
+ public void RequestsCorrectUrl()
+ {
+ var connection = Substitute.For();
+ var client = new EnterpriseLdapClient(connection);
+
+ 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
\ No newline at end of file
diff --git a/Octokit/Octokit-Monotouch.csproj b/Octokit/Octokit-Monotouch.csproj
index 5add86a95b..98e4beee9c 100644
--- a/Octokit/Octokit-Monotouch.csproj
+++ b/Octokit/Octokit-Monotouch.csproj
@@ -452,6 +452,10 @@
+
+
+
+
diff --git a/Octokit/Octokit-Portable.csproj b/Octokit/Octokit-Portable.csproj
index 8a39aea9db..eedca31146 100644
--- a/Octokit/Octokit-Portable.csproj
+++ b/Octokit/Octokit-Portable.csproj
@@ -445,6 +445,10 @@
+
+
+
+
diff --git a/Octokit/Octokit-netcore45.csproj b/Octokit/Octokit-netcore45.csproj
index 5dc2d66447..8478f6f53e 100644
--- a/Octokit/Octokit-netcore45.csproj
+++ b/Octokit/Octokit-netcore45.csproj
@@ -452,6 +452,10 @@
+
+
+
+
diff --git a/Octokit/Octokit.csproj b/Octokit/Octokit.csproj
index d6ef33fac0..45a357276b 100644
--- a/Octokit/Octokit.csproj
+++ b/Octokit/Octokit.csproj
@@ -59,10 +59,12 @@
+
+
@@ -111,6 +113,7 @@
+
@@ -151,6 +154,7 @@
+
@@ -484,4 +488,4 @@
-->
-
\ No newline at end of file
+