public EnterpriseLdapClientTests() { _github = EnterpriseHelper.GetAuthenticatedClient(); NewTeam newTeam = new NewTeam(Helper.MakeNameWithTimestamp("test-team")) { Description = "Test Team" }; _context = _github.CreateTeamContext(EnterpriseHelper.Organization, newTeam).Result; }
/// <summary> /// Returns newly created <see cref="Team" /> for the current org. /// </summary> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> /// <returns>Newly created <see cref="Team"/></returns> public Task<Team> CreateTeam(string org, NewTeam team) { Ensure.ArgumentNotNullOrEmptyString(org, "org"); Ensure.ArgumentNotNull(team, "team"); var endpoint = ApiUrls.OrganizationTeams(org); return ApiConnection.Post<Team>(endpoint, team); }
/// <summary> /// Returns newly created <see cref="Team" /> for the current org. /// </summary> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> /// <returns>Newly created <see cref="Team"/></returns> public Task<Team> CreateTeam(string org, NewTeam team) { Ensure.ArgumentNotNullOrEmptyString(org, "org"); Ensure.ArgumentNotNull(team, "team"); var endpoint = "orgs/{0}/teams".FormatUri(org); return ApiConnection.Post<Team>(endpoint, team); }
public async Task FailsWhenAuthenticatedWithBadCredentials() { var github = Helper.GetBadCredentialsClient(); var newTeam = new NewTeam("Test"); var e = await Assert.ThrowsAsync<AuthorizationException>(() => github.Organization.Team.Create(Helper.Organization, newTeam)); Assert.Equal(HttpStatusCode.Unauthorized, e.StatusCode); }
public async Task FailsWhenNotAuthenticated() { var github = new GitHubClient(new ProductHeaderValue("OctokitTests")); var newTeam = new NewTeam("Test"); var e = await AssertEx.Throws<AuthorizationException>(async () => await github.Organization.Team.Create(Helper.Organization, newTeam)); Assert.Equal(HttpStatusCode.Unauthorized, e.StatusCode); }
public async Task SucceedsWhenAuthenticated() { var github = Helper.GetAuthenticatedClient(); var newTeam = new NewTeam(Guid.NewGuid().ToString()); var team = await github.Organization.Team.Create(Helper.Organization, newTeam); Assert.Equal(newTeam.Name, team.Name); }
public async Task FailsWhenNotAuthenticated() { var github = Helper.GetAnonymousClient(); var newTeam = new NewTeam("Test"); var e = await AssertEx.Throws<AuthorizationException>(async () => await github.Organization.Team.Create(Helper.Organization, newTeam)); Assert.Equal(HttpStatusCode.Unauthorized, e.StatusCode); }
public async Task SucceedsWhenAuthenticated() { var github = new GitHubClient(new ProductHeaderValue("OctokitTests")) { Credentials = Helper.Credentials }; var newTeam = new NewTeam(Guid.NewGuid().ToString()); var team = await github.Organization.Team.Create(Helper.Organization, newTeam); Assert.Equal(newTeam.Name, team.Name); }