Skip to content

Commit

Permalink
Due to api serialisation, must use LdapDn rather than LdapDN (the lat…
Browse files Browse the repository at this point in the history
…ter turns into ldap_d_n instead of ldap_dn)

Get rid of LdapTeam and LdapUser, the regular Team and User objects contain ldap_dn field if LDAP sync is enabled
  • Loading branch information
ryangribble committed Feb 8, 2016
1 parent 67d48df commit 50a9384
Show file tree
Hide file tree
Showing 16 changed files with 63 additions and 102 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ public interface IObservableEnterpriseLdapClient
/// </remarks>
/// <param name="userName">The username to update LDAP mapping</param>
/// <param name="newLdapMapping">The <see cref="NewLdapMapping"/></param>
/// <returns>The <see cref="LdapUser"/> object.</returns>
IObservable<LdapUser> UpdateUserMapping(string userName, NewLdapMapping newLdapMapping);
/// <returns>The <see cref="User"/> object.</returns>
IObservable<User> UpdateUserMapping(string userName, NewLdapMapping newLdapMapping);

/// <summary>
/// Queue an LDAP Sync job for a user on a GitHub Enterprise appliance (must be Site Admin user).
Expand All @@ -31,7 +31,7 @@ public interface IObservableEnterpriseLdapClient
/// https://developer.github.com/v3/enterprise/ldap/#sync-ldap-mapping-for-a-user
/// </remarks>
/// <param name="userName">The username to sync LDAP mapping</param>
/// <returns>The <see cref="HttpStatusCode"/> of the queue request.</returns>
/// <returns>The <see cref="LdapSyncResponse"/> of the queue request.</returns>
IObservable<LdapSyncResponse> QueueSyncUserMapping(string userName);

/// <summary>
Expand All @@ -42,8 +42,8 @@ public interface IObservableEnterpriseLdapClient
/// </remarks>
/// <param name="teamId">The teamId to update LDAP mapping</param>
/// <param name="newLdapMapping">The <see cref="NewLdapMapping"/></param>
/// <returns>The <see cref="LdapTeam"/> object.</returns>
IObservable<LdapTeam> UpdateTeamMapping(int teamId, NewLdapMapping newLdapMapping);
/// <returns>The <see cref="Team"/> object.</returns>
IObservable<Team> UpdateTeamMapping(int teamId, NewLdapMapping newLdapMapping);

/// <summary>
/// Queue an LDAP Sync job for a team on a GitHub Enterprise appliance (must be Site Admin user).
Expand All @@ -52,7 +52,7 @@ public interface IObservableEnterpriseLdapClient
/// https://developer.github.com/v3/enterprise/ldap/#sync-ldap-mapping-for-a-team
/// </remarks>
/// <param name="teamId">The teamId to update LDAP mapping</param>
/// <returns>The <see cref="HttpStatusCode"/> of the queue request.</returns>
/// <returns>The <see cref="LdapSyncResponse"/> of the queue request.</returns>
IObservable<LdapSyncResponse> QueueSyncTeamMapping(int teamId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ public ObservableEnterpriseLdapClient(IGitHubClient client)
/// </remarks>
/// <param name="userName">The username to update LDAP mapping</param>
/// <param name="newLdapMapping">The <see cref="NewLdapMapping"/></param>
/// <returns>The <see cref="LdapUser"/> object.</returns>
public IObservable<LdapUser> UpdateUserMapping(string userName, NewLdapMapping newLdapMapping)
/// <returns>The <see cref="User"/> object.</returns>
public IObservable<User> UpdateUserMapping(string userName, NewLdapMapping newLdapMapping)
{
return _client.UpdateUserMapping(userName, newLdapMapping).ToObservable();
}
Expand All @@ -44,7 +44,7 @@ public IObservable<LdapUser> UpdateUserMapping(string userName, NewLdapMapping n
/// https://developer.github.com/v3/enterprise/ldap/#sync-ldap-mapping-for-a-user
/// </remarks>
/// <param name="userName">The username to sync LDAP mapping</param>
/// <returns>The <see cref="HttpStatusCode"/> of the queue request.</returns>
/// <returns>The <see cref="LdapSyncResponse"/> of the queue request.</returns>
public IObservable<LdapSyncResponse> QueueSyncUserMapping(string userName)
{
return _client.QueueSyncUserMapping(userName).ToObservable();
Expand All @@ -58,8 +58,8 @@ public IObservable<LdapSyncResponse> QueueSyncUserMapping(string userName)
/// </remarks>
/// <param name="teamId">The teamId to update LDAP mapping</param>
/// <param name="newLdapMapping">The <see cref="NewLdapMapping"/></param>
/// <returns>The <see cref="LdapTeam"/> object.</returns>
public IObservable<LdapTeam> UpdateTeamMapping(int teamId, NewLdapMapping newLdapMapping)
/// <returns>The <see cref="Team"/> object.</returns>
public IObservable<Team> UpdateTeamMapping(int teamId, NewLdapMapping newLdapMapping)
{
return _client.UpdateTeamMapping(teamId, newLdapMapping).ToObservable();
}
Expand All @@ -71,7 +71,7 @@ public IObservable<LdapTeam> UpdateTeamMapping(int teamId, NewLdapMapping newLda
/// https://developer.github.com/v3/enterprise/ldap/#sync-ldap-mapping-for-a-team
/// </remarks>
/// <param name="teamId">The teamId to update LDAP mapping</param>
/// <returns>The <see cref="HttpStatusCode"/> of the queue request.</returns>
/// <returns>The <see cref="LdapSyncResponse"/> of the queue request.</returns>
public IObservable<LdapSyncResponse> QueueSyncTeamMapping(int teamId)
{
return _client.QueueSyncTeamMapping(teamId).ToObservable();
Expand Down
18 changes: 9 additions & 9 deletions Octokit/Clients/Enterprise/EnterpriseLdapClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ public EnterpriseLdapClient(IApiConnection apiConnection)
/// </remarks>
/// <param name="userName">The username to update LDAP mapping</param>
/// <param name="newLdapMapping">The <see cref="NewLdapMapping"/></param>
/// <returns>The <see cref="LdapUser"/> object.</returns>
public async Task<LdapUser> UpdateUserMapping(string userName, NewLdapMapping newLdapMapping)
/// <returns>The <see cref="User"/> object.</returns>
public async Task<User> UpdateUserMapping(string userName, NewLdapMapping newLdapMapping)
{
Ensure.ArgumentNotNull(userName, "userName");
Ensure.ArgumentNotNull(newLdapMapping, "newLdapMapping");

var endpoint = ApiUrls.EnterpriseLdapUserMapping(userName);

return await ApiConnection.Patch<LdapUser>(endpoint, newLdapMapping);
return await ApiConnection.Patch<User>(endpoint, newLdapMapping);
}

/// <summary>
Expand All @@ -41,7 +41,7 @@ public async Task<LdapUser> UpdateUserMapping(string userName, NewLdapMapping ne
/// https://developer.github.com/v3/enterprise/ldap/#sync-ldap-mapping-for-a-user
/// </remarks>
/// <param name="userName">The userName to sync LDAP mapping</param>
/// <returns>The <see cref="HttpStatusCode"/> of the queue request.</returns>
/// <returns>The <see cref="LdapSyncResponse"/> of the queue request.</returns>
public async Task<LdapSyncResponse> QueueSyncUserMapping(string userName)
{
Ensure.ArgumentNotNull(userName, "userName");
Expand All @@ -65,25 +65,25 @@ public async Task<LdapSyncResponse> QueueSyncUserMapping(string userName)
/// </remarks>
/// <param name="teamId">The teamId to update LDAP mapping</param>
/// <param name="newLdapMapping">The <see cref="NewLdapMapping"/></param>
/// <returns>The <see cref="LdapTeam"/> object.</returns>
public async Task<LdapTeam> UpdateTeamMapping(int teamId, NewLdapMapping newLdapMapping)
/// <returns>The <see cref="Team"/> object.</returns>
public async Task<Team> UpdateTeamMapping(int teamId, NewLdapMapping newLdapMapping)
{
Ensure.ArgumentNotNull(teamId, "teamId");
Ensure.ArgumentNotNull(newLdapMapping, "newLdapMapping");

var endpoint = ApiUrls.EnterpriseLdapTeamMapping(teamId);

return await ApiConnection.Patch<LdapTeam>(endpoint, newLdapMapping);
return await ApiConnection.Patch<Team>(endpoint, newLdapMapping);
}

/// <summary>
/// Queue an LDAP Sync job for a team on a GitHub Enterprise appliance (must be Site Admin user).
/// </summary>
/// <remarks>
/// https://developer.github.com/v3/enterprise/ldap/#sync-ldap-mapping-for-a-team
/// </remarks>
/// <param name="teamId">The teamId to update LDAP mapping</param>
/// <returns>The <see cref="HttpStatusCode"/> of the queue request.</returns>
/// <returns>The <see cref="LdapSyncResponse"/> of the queue request.</returns>
public async Task<LdapSyncResponse> QueueSyncTeamMapping(int teamId)
{
Ensure.ArgumentNotNull(teamId, "teamId");
Expand Down
12 changes: 6 additions & 6 deletions Octokit/Clients/Enterprise/IEnterpriseLdapClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ public interface IEnterpriseLdapClient
/// </remarks>
/// <param name="userName">The username to update LDAP mapping</param>
/// <param name="newLdapMapping">The <see cref="NewLdapMapping"/></param>
/// <returns>The <see cref="LdapUser"/> object.</returns>
Task<LdapUser> UpdateUserMapping(string userName, NewLdapMapping newLdapMapping);
/// <returns>The <see cref="User"/> object.</returns>
Task<User> UpdateUserMapping(string userName, NewLdapMapping newLdapMapping);

/// <summary>
/// Queue an LDAP Sync job for a user on a GitHub Enterprise appliance (must be Site Admin user).
Expand All @@ -28,7 +28,7 @@ public interface IEnterpriseLdapClient
/// https://developer.github.com/v3/enterprise/ldap/#sync-ldap-mapping-for-a-user
/// </remarks>
/// <param name="userName">The username to sync LDAP mapping</param>
/// <returns>The <see cref="HttpStatusCode"/> of the queue request.</returns>
/// <returns>The <see cref="LdapSyncResponse"/> of the queue request.</returns>
Task<LdapSyncResponse> QueueSyncUserMapping(string userName);

/// <summary>
Expand All @@ -39,8 +39,8 @@ public interface IEnterpriseLdapClient
/// </remarks>
/// <param name="teamId">The teamId to update LDAP mapping</param>
/// <param name="newLdapMapping">The <see cref="NewLdapMapping"/></param>
/// <returns>The <see cref="LdapTeam"/> object.</returns>
Task<LdapTeam> UpdateTeamMapping(int teamId, NewLdapMapping newLdapMapping);
/// <returns>The <see cref="Team"/> object.</returns>
Task<Team> UpdateTeamMapping(int teamId, NewLdapMapping newLdapMapping);

/// <summary>
/// Queue an LDAP Sync job for a team on a GitHub Enterprise appliance (must be Site Admin user).
Expand All @@ -49,7 +49,7 @@ public interface IEnterpriseLdapClient
/// https://developer.github.com/v3/enterprise/ldap/#sync-ldap-mapping-for-a-team
/// </remarks>
/// <param name="teamId">The teamId to update LDAP mapping</param>
/// <returns>The <see cref="HttpStatusCode"/> of the queue request.</returns>
/// <returns>The <see cref="LdapSyncResponse"/> of the queue request.</returns>
Task<LdapSyncResponse> QueueSyncTeamMapping(int teamId);
}
}
13 changes: 9 additions & 4 deletions Octokit/Models/Request/Enterprise/NewLdapMapping.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;

namespace Octokit
Expand All @@ -15,21 +16,25 @@ public class NewLdapMapping
/// Initializes a new instance of the <see cref="NewLdapMapping"/> class.
/// </summary>
/// <param name="ldapDn">The LDAP Distinguished Name</param>
public NewLdapMapping(string ldapDN)
[SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Dn")]
[SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Dn")]
public NewLdapMapping(string ldapDn)
{
LdapDN = ldapDN;
LdapDn = ldapDn;
}

/// <summary>
/// The LDAP Distinguished Name (required)
/// </summary>
public string LdapDN { get; private set; }
[SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Dn")]
[SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Dn")]
public string LdapDn { get; private set; }

internal string DebuggerDisplay
{
get
{
return string.Format(CultureInfo.InvariantCulture, "LdapDn: {0}", LdapDN);
return string.Format(CultureInfo.InvariantCulture, "LdapDn: {0}", LdapDn);
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions Octokit/Models/Response/Enterprise/LdapSyncResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ public class LdapSyncResponse
{
public LdapSyncResponse() { }

public LdapSyncResponse(IReadOnlyList<string> status)
public LdapSyncResponse(string status)
{
Status = status;
}

public IReadOnlyList<string> Status
public string Status
{
get;
private set;
Expand All @@ -26,7 +26,7 @@ internal string DebuggerDisplay
{
get
{
return String.Format(CultureInfo.InvariantCulture, "Status: {0}", string.Join("\r\n", Status));
return String.Format(CultureInfo.InvariantCulture, "Status: {0}", Status);
}
}
}
Expand Down
27 changes: 0 additions & 27 deletions Octokit/Models/Response/Enterprise/LdapTeam.cs

This file was deleted.

27 changes: 0 additions & 27 deletions Octokit/Models/Response/Enterprise/LdapUser.cs

This file was deleted.

13 changes: 12 additions & 1 deletion Octokit/Models/Response/Team.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;

namespace Octokit
Expand All @@ -12,7 +13,9 @@ public class Team
{
public Team() { }

public Team(Uri url, int id, string name, Permission permission, int membersCount, int reposCount, Organization organization)
[SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId="Dn")]
[SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Dn")]
public Team(Uri url, int id, string name, Permission permission, int membersCount, int reposCount, Organization organization, string ldapDn)
{
Url = url;
Id = id;
Expand All @@ -21,6 +24,7 @@ public Team(Uri url, int id, string name, Permission permission, int membersCoun
MembersCount = membersCount;
ReposCount = reposCount;
Organization = organization;
LdapDn = ldapDn;
}

/// <summary>
Expand Down Expand Up @@ -58,6 +62,13 @@ public Team(Uri url, int id, string name, Permission permission, int membersCoun
/// </summary>
public Organization Organization { get; protected set; }

/// <summary>
/// LDAP Binding (GitHub Enterprise only)
/// </summary>
[SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Dn")]
[SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Dn")]
public string LdapDn { get; protected set; }

internal string DebuggerDisplay
{
get { return string.Format(CultureInfo.InvariantCulture, "Name: {0} ", Name); }
Expand Down
13 changes: 12 additions & 1 deletion Octokit/Models/Response/User.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;

namespace Octokit
Expand All @@ -12,17 +13,27 @@ public class User : Account
{
public User() { }

public User(string avatarUrl, string bio, string blog, int collaborators, string company, DateTimeOffset createdAt, int diskUsage, string email, int followers, int following, bool? hireable, string htmlUrl, int totalPrivateRepos, int id, string location, string login, string name, int ownedPrivateRepos, Plan plan, int privateGists, int publicGists, int publicRepos, string url, bool siteAdmin)
[SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Dn")]
[SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Dn")]
public User(string avatarUrl, string bio, string blog, int collaborators, string company, DateTimeOffset createdAt, int diskUsage, string email, int followers, int following, bool? hireable, string htmlUrl, int totalPrivateRepos, int id, string location, string login, string name, int ownedPrivateRepos, Plan plan, int privateGists, int publicGists, int publicRepos, string url, bool siteAdmin, string ldapDn)
: base(avatarUrl, bio, blog, collaborators, company, createdAt, diskUsage, email, followers, following, hireable, htmlUrl, totalPrivateRepos, id, location, login, name, ownedPrivateRepos, plan, privateGists, publicGists, publicRepos, AccountType.User, url)
{
SiteAdmin = siteAdmin;
LdapDn = ldapDn;
}

/// <summary>
/// Whether or not the user is an administrator of the site
/// </summary>
public bool SiteAdmin { get; protected set; }

/// <summary>
/// LDAP Binding (GitHub Enterprise only)
/// </summary>
[SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Dn")]
[SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Dn")]
public string LdapDn { get; protected set; }

internal string DebuggerDisplay
{
get
Expand Down
2 changes: 0 additions & 2 deletions Octokit/Octokit-Mono.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -450,8 +450,6 @@
<Compile Include="Clients\Enterprise\EnterpriseLdapClient.cs" />
<Compile Include="Clients\Enterprise\IEnterpriseLdapClient.cs" />
<Compile Include="Models\Request\Enterprise\NewLdapMapping.cs" />
<Compile Include="Models\Response\Enterprise\LdapTeam.cs" />
<Compile Include="Models\Response\Enterprise\LdapUser.cs" />
<Compile Include="Models\Response\Enterprise\LdapSyncResponse.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
Expand Down
2 changes: 0 additions & 2 deletions Octokit/Octokit-MonoAndroid.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -458,8 +458,6 @@
<Compile Include="Clients\Enterprise\EnterpriseLdapClient.cs" />
<Compile Include="Clients\Enterprise\IEnterpriseLdapClient.cs" />
<Compile Include="Models\Request\Enterprise\NewLdapMapping.cs" />
<Compile Include="Models\Response\Enterprise\LdapTeam.cs" />
<Compile Include="Models\Response\Enterprise\LdapUser.cs" />
<Compile Include="Models\Response\Enterprise\LdapSyncResponse.cs" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" />
Expand Down
Loading

0 comments on commit 50a9384

Please sign in to comment.