Beispiel #1
0
        public async Task ReturnsNoPendingInvitations()
        {
            using (var teamContext = await _gitHub.CreateTeamContext(Helper.Organization, new NewTeam(Helper.MakeNameWithTimestamp("team"))))
            {
                var team = teamContext.Team;

                var pendingInvitations = await _gitHub.Organization.Team.GetAllPendingInvitations(team.Id);

                Assert.NotNull(pendingInvitations);
                Assert.Empty(pendingInvitations);
            }
        }
Beispiel #2
0
            public async Task ReturnsPendingInvitations()
            {
                using (var teamContext = await _gitHub.CreateTeamContext(Helper.Organization, new NewTeam(Helper.MakeNameWithTimestamp("team"))))
                {
                    teamContext.InviteMember("octokitnet-test1");
                    teamContext.InviteMember("octokitnet-test2");

                    var pendingInvitations = await _client.GetAllPendingInvitations(Helper.Organization).ToList();

                    Assert.NotEmpty(pendingInvitations);
                    Assert.Equal(2, pendingInvitations.Count);
                }
            }
Beispiel #3
0
        public async Task GetsAllChildTeams()
        {
            using (var parentTeamContext = await _github.CreateTeamContext(Helper.Organization, new NewTeam(Helper.MakeNameWithTimestamp("parent-team"))))
            {
                var team1 = await _github.Organization.Team.Create(Helper.Organization, new NewTeam(Helper.MakeNameWithTimestamp("child-team")) { Privacy = TeamPrivacy.Closed, ParentTeamId = parentTeamContext.TeamId });

                var team2 = await _github.Organization.Team.Create(Helper.Organization, new NewTeam(Helper.MakeNameWithTimestamp("child-team")) { Privacy = TeamPrivacy.Closed, ParentTeamId = parentTeamContext.TeamId });

                var teams = await _github.Organization.Team.GetAllChildTeams(parentTeamContext.TeamId);

                Assert.Equal(2, teams.Count);
                Assert.Contains(teams, x => x.Id == team1.Id);
                Assert.Contains(teams, x => x.Id == team2.Id);
            }
        }
        internal async static Task <OrganizationRepositoryWithTeamContext> CreateOrganizationRepositoryWithProtectedBranch(this IGitHubClient client)
        {
            // Create organization owned repo
            var orgRepo = new NewRepository(Helper.MakeNameWithTimestamp("protected-org-repo"))
            {
                AutoInit = true
            };
            var contextOrgRepo = await client.CreateRepositoryContext(Helper.Organization, orgRepo);

            // Create team in org
            var contextOrgTeam = await client.CreateTeamContext(Helper.Organization, new NewTeam(Helper.MakeNameWithTimestamp("team")));

            // Grant team push access to repo
            await client.Organization.Team.AddRepository(
                contextOrgTeam.TeamId,
                contextOrgRepo.RepositoryOwner,
                contextOrgRepo.RepositoryName,
                new RepositoryPermissionRequest(Permission.Push));

            // Protect master branch
            var protection = new BranchProtectionSettingsUpdate(
                new BranchProtectionRequiredStatusChecksUpdate(true, new[] { "build", "test" }),
                new BranchProtectionPushRestrictionsUpdate(new BranchProtectionTeamCollection {
                contextOrgTeam.TeamName
            }),
                true);
            await client.Repository.Branch.UpdateBranchProtection(contextOrgRepo.RepositoryOwner, contextOrgRepo.RepositoryName, "master", protection);

            return(new OrganizationRepositoryWithTeamContext
            {
                RepositoryContext = contextOrgRepo,
                TeamContext = contextOrgTeam
            });
        }
    public EnterpriseLdapClientTests()
    {
        _github = EnterpriseHelper.GetAuthenticatedClient();

        NewTeam newTeam = new NewTeam(Helper.MakeNameWithTimestamp("test-team")) { Description = "Test Team" };
        _context = _github.CreateTeamContext(EnterpriseHelper.Organization, newTeam).Result;
    }
        public TheAddProtectedBranchTeamRestrictionsMethod()
        {
            _github = Helper.GetAuthenticatedClient();
            _client = _github.Repository.Branch;

            _contextOrgTeam2 = _github.CreateTeamContext(Helper.Organization, new NewTeam(Helper.MakeNameWithTimestamp("team2"))).Result;
            _orgRepoContext  = _github.CreateOrganizationRepositoryWithProtectedBranch().Result;
        }
Beispiel #7
0
        public TheGetAllMembersMethod()
        {
            _github = Helper.GetAuthenticatedClient();

            var newTeam = new NewTeam(Helper.MakeNameWithTimestamp("team-fixture"));

            newTeam.Maintainers.Add(Helper.UserName);

            _teamContext = _github.CreateTeamContext(Helper.Organization, newTeam).Result;
        }
    public EnterpriseLdapClientTests()
    {
        _github = EnterpriseHelper.GetAuthenticatedClient();

        NewTeam newTeam = new NewTeam(Helper.MakeNameWithTimestamp("test-team"))
        {
            Description = "Test Team"
        };

        _context = _github.CreateTeamContext(EnterpriseHelper.Organization, newTeam).Result;
    }
            public async Task ReturnsUsersMembershipOrganizationMembership()
            {
                using (var teamContext = await _gitHub.CreateTeamContext(Helper.Organization, new NewTeam(Helper.MakeNameWithTimestamp("team"))))
                {
                    teamContext.InviteMember("alfhenrik-test-2");

                    var organizationMemberhip = await _gitHub.Organization.Member.GetOrganizationMembership(Helper.Organization, "alfhenrik-test-2");

                    Assert.Equal(MembershipState.Pending, organizationMemberhip.State);
                    Assert.Equal(MembershipRole.Member, organizationMemberhip.Role);
                }
            }
Beispiel #10
0
        public async Task UpdatesTeam()
        {
            using (var parentTeamContext = await _github.CreateTeamContext(Helper.Organization, new NewTeam(Helper.MakeNameWithTimestamp("parent-team"))))
                using (var teamContext = await _github.CreateTeamContext(Helper.Organization, new NewTeam(Helper.MakeNameWithTimestamp("team-fixture"))))
                {
                    var teamName        = Helper.MakeNameWithTimestamp("updated-team");
                    var teamDescription = Helper.MakeNameWithTimestamp("updated description");
                    var update          = new UpdateTeam(teamName)
                    {
                        Description  = teamDescription,
                        Privacy      = TeamPrivacy.Closed,
                        ParentTeamId = parentTeamContext.TeamId
                    };

                    var team = await _github.Organization.Team.Update(teamContext.TeamId, update);

                    Assert.Equal(teamName, team.Name);
                    Assert.Equal(teamDescription, team.Description);
                    Assert.Equal(TeamPrivacy.Closed, team.Privacy);
                    Assert.Equal(parentTeamContext.TeamId, team.Parent.Id);
                }
        }
Beispiel #11
0
        public async Task CanAddRepository()
        {
            using (var teamContext = await _github.CreateTeamContext(Helper.Organization, new NewTeam(Helper.MakeNameWithTimestamp("team"))))
                using (var repoContext = await _github.CreateRepositoryContext(Helper.Organization, new NewRepository(Helper.MakeNameWithTimestamp("team-repository"))))
                {
                    var team = teamContext.Team;
                    var repo = repoContext.Repository;

                    var addRepo = await _github.Organization.Team.AddRepository(team.Id, team.Organization.Login, repo.Name, new RepositoryPermissionRequest(Permission.Admin));

                    Assert.True(addRepo);

                    var addedRepo = await _github.Organization.Team.GetAllRepositories(team.Id);

                    //Check if permission was correctly applied
                    Assert.True(addedRepo.First(x => x.Id == repo.Id).Permissions.Admin == true);
                }
        }
        public TheUpdateProtectedBranchTeamRestrictionsMethod()
        {
            _github = Helper.GetAuthenticatedClient();
            _client = _github.Repository.Branch;

            _contextOrgTeam2 = _github.CreateTeamContext(Helper.Organization, new NewTeam(Helper.MakeNameWithTimestamp("team2"))).Result;
            _orgRepoContext = _github.CreateOrganizationRepositoryWithProtectedBranch().Result;
        }