mirror of
https://github.com/zoriya/octokit.net.git
synced 2025-12-19 13:45:12 +00:00
* Initial implementation of ManagementConsole - maintenance mode * Add environment var support for management console password for integration tests * Add reactive client and unit tests * Update some xmlDoc * I think this is a better way to setup the underlying baseUri on IConneciton, to achieve managemet console access rather than requiring a specific GitHubClient that cant call normal API's Instead, the management client methods can check the base Url and if it contains /api/v3/ they can set their relative endpoint Uri to include a leading "/" which will cause the /api/v3/ to be removed. * Update EnterpriseClient.cs Fix xml comments * Update IEnterpriseClient.cs Fix xml comments * Still trying to get the xmDoc perfect, thanks app veyor :) * XmlDoc'ing my way to success * Add specific test attribute for management console tests * check chronic string empty/null * Use helper's password field in test * Tidy up maintenance mode tests by using a context/destructor to manage the initial/end state of maintenance mode * make internal and tidy up URL concatenation * move GHE endpoint fixup inside ApiUrls methods * Rework request object to be the correct structure so SimpleJsonSerializer can be used to serialize it. Remove MaintenanceDate class and just pass in the Date/string for when Still need to use UrlFormEncoding rather than json in the POST body though... * Create abstract base class for FormUrlEncoded parameters (similar to existing RequetParameters) and inherit from it in UpdateMaintenanceRequest * Fix maintenance context logic - destructor should always turn maintenance OFF regardless of initial requested state * Fix xml comment * Fix Xml comment * Those pesky xml comments! * Fine, I give up! * Fix string.Format * fix bad rebase * fix failing convention tests * restore missing whitespace * writing some docs * some edits * edit
88 lines
3.9 KiB
C#
88 lines
3.9 KiB
C#
using System.Threading.Tasks;
|
|
|
|
namespace Octokit.Tests.Integration.Helpers
|
|
{
|
|
internal static class GithubClientExtensions
|
|
{
|
|
internal static async Task<RepositoryContext> CreateRepositoryContext(this IGitHubClient client, string repositoryName)
|
|
{
|
|
var repoName = Helper.MakeNameWithTimestamp(repositoryName);
|
|
var repo = await client.Repository.Create(new NewRepository(repoName) { AutoInit = true });
|
|
|
|
return new RepositoryContext(client.Connection, repo);
|
|
}
|
|
|
|
internal static async Task<RepositoryContext> CreateRepositoryContext(this IGitHubClient client, string organizationLogin, NewRepository newRepository)
|
|
{
|
|
var repo = await client.Repository.Create(organizationLogin, newRepository);
|
|
|
|
return new RepositoryContext(client.Connection, repo);
|
|
}
|
|
|
|
internal static async Task<RepositoryContext> CreateRepositoryContext(this IGitHubClient client, NewRepository newRepository)
|
|
{
|
|
var repo = await client.Repository.Create(newRepository);
|
|
|
|
return new RepositoryContext(client.Connection, repo);
|
|
}
|
|
|
|
internal static async Task<TeamContext> CreateTeamContext(this IGitHubClient client, string organization, NewTeam newTeam)
|
|
{
|
|
newTeam.Privacy = TeamPrivacy.Closed;
|
|
var team = await client.Organization.Team.Create(organization, newTeam);
|
|
|
|
return new TeamContext(client.Connection, team);
|
|
}
|
|
|
|
internal static async Task<EnterpriseUserContext> CreateEnterpriseUserContext(this IGitHubClient client, NewUser newUser)
|
|
{
|
|
var user = await client.User.Administration.Create(newUser);
|
|
|
|
return new EnterpriseUserContext(client.Connection, user);
|
|
}
|
|
|
|
internal static async Task<PublicKeyContext> CreatePublicKeyContext(this IGitHubClient client)
|
|
{
|
|
// Create a key
|
|
string keyTitle = "title";
|
|
string keyData = "ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAQEAq42HufbSy1BUbZTdKyEy8nX44gdchbh1A/cYuVFkRXETrFr6XYLETi4tauXGS3Wp3E4s3oG272O4JW+fIBX0kuOJXnRgYz52H3BDk6aY9B0ny+PYFJrYrpG43px5EVfojj9o7oxugNq4zLCGqWTqZU1maTf5T4Mopjt0ggA7cyNnM5B645cBxXjD2KNfrTIyLI+meYxptzjRiB6fHLGFRA9fxpVqUnbq7EcGbwsTlILRuEPt58hZ9He88M45m0F8rkVZOewt4JSzsLsC+sQs+h/LXI8dbrg6xWpxJVi0trzYuMuY/MwygloWKtaFQYuPkJ7yqMZ3Aew+J3DupF6uxQ==";
|
|
|
|
var key = await client.User.GitSshKey.Create(new NewPublicKey(keyTitle, keyData));
|
|
|
|
return new PublicKeyContext(client.Connection, key);
|
|
}
|
|
|
|
internal static async Task<GpgKeyContext> CreateGpgKeyContext(this IGitHubClient client)
|
|
{
|
|
// Create a key
|
|
string publicKey = @"
|
|
-----BEGIN PGP PUBLIC KEY BLOCK-----
|
|
Version: BCPG C# v1.6.1.0
|
|
|
|
mQENBFdTvCUBCADOaVtPoJTQOgMIVYEpI8uT60LA/kDqw/1OKn7ftKjAtxNVSgjQ
|
|
i/ZqZp8XKjTg2u6l4c/aPjER2BGTg90xCcbmpwq/kkQuHR4DK7dOlEOoTzDDESEF
|
|
v6XXlXGCnxN8AD8YNvSO+Sy4+35ihuKUBAHDxmOl7ZAMH0STo10KuW82/DhfT3cC
|
|
JNqmID7H+CW1H6IhwutPKt8XsVq2FQg2RMx+uX1KqkuBAd7b30KJ93SJqzgq5CC3
|
|
DticaC0/WdZnxmYD01UvMAS6o/REs+SICdsyTxgBx/X8SIXuX2TD9PG/O2785JI5
|
|
/xvBd4jU6bBH/4oWoHr3e/lyNqb1+GSeTFX3ABEBAAG0AIkBHAQQAQIABgUCV1O8
|
|
JQAKCRDohALS4SeiOs/QB/9PMeFNdPkB1xfBm3qvTErqvhTcQspPibucYefG6JHL
|
|
vhm6iCOVBeCuPS4P/T8RTzb0qJaTdZZWcwZ9UjRVqF/RKwdMJTBKBHRegc5hRjLH
|
|
Koxk0zXosk+CapIR6eVhHe4IzpVVxZOvunsFOclIh+qHx9UzJhz9wSO/XBn/6Rzr
|
|
DGzE9fpK1JRKC0I3PuiDCNuZvojXeUsT/zuHYsz00wnA2Em7CmcWWng3nPUSHvBB
|
|
GUJ7YE7NvYXqT09PdhoZnf9p1wOugiuG6CLzWf8stlNV3mZptpP+sCGcz/UVffRO
|
|
VO/+BCBsaoT4g1FFOmJhbBAD3G72yslBnUJmqKP/39pi
|
|
=O7Yi
|
|
-----END PGP PUBLIC KEY BLOCK-----
|
|
";
|
|
|
|
var key = await client.User.GpgKey.Create(new NewGpgKey(publicKey));
|
|
|
|
return new GpgKeyContext(client.Connection, key);
|
|
}
|
|
|
|
internal static MaintenanceModeContext CreateMaintenanceModeContext(this IGitHubClient client, bool enabled)
|
|
{
|
|
return new MaintenanceModeContext(client.Connection, enabled);
|
|
}
|
|
}
|
|
} |