Exemplo n.º 1
0
        public async Task<BranchPermission> SetPermissions(string projectKey, string repositorySlug, BranchPermission permissions) 
        {
            string requestUrl = UrlBuilder.FormatRestApiUrl(BRANCH_PERMISSIONS, null, projectKey, repositorySlug);

            BranchPermission response = await _httpWorker.PostAsync(requestUrl, permissions);

            return response;
        }
Exemplo n.º 2
0
        public async Task Can_SetBranchPermissions_Than_DeleteBranchPermissions_Using_Pattern()
        {
            BranchPermission setBranchPerm = new BranchPermission
            {
                Type = BranchPermissionType.READ_ONLY,
                Matcher = new BranchPermissionMatcher
                {
                    Id = "**",
                    DisplayId = "**",
                    Active = true,
                    Type = new BranchPermissionMatcherType
                    {
                        Id = BranchPermissionMatcherTypeName.PATTERN,
                        Name = "Pattern"
                    }
                },
                Users = new List<User>(),
                Groups = new string[] { EXISTING_GROUP }
            };

            var response = await stashClient.Branches.SetPermissions(EXISTING_PROJECT, EXISTING_REPOSITORY, setBranchPerm);

            Assert.IsNotNull(response);
            Assert.IsInstanceOfType(response, typeof(BranchPermission));
            Assert.AreEqual(setBranchPerm.Type, response.Type);
            Assert.AreEqual(setBranchPerm.Matcher.Id, response.Matcher.Id);
            Assert.AreEqual(setBranchPerm.Matcher.Type.Id, response.Matcher.Type.Id);
            Assert.IsTrue(response.Id > 0);

            await stashClient.Branches.DeletePermissions(EXISTING_PROJECT, EXISTING_REPOSITORY, response.Id);
        }
Exemplo n.º 3
0
        public async Task Can_SetBranchPermissions_Than_DeleteBranchPermissions_Using_Pattern()
        {
            var setBranchPerm = new BranchPermission
            {
                Type = BranchPermissionType.PATTERN,
                Value = "**",
                Groups = new string[] { EXISTING_GROUP },
                Users = new string[] { }
            };

            var response = await stashClient.Branches.SetPermissions(EXISTING_PROJECT, EXISTING_REPOSITORY, setBranchPerm);

            Assert.IsNotNull(response);
            Assert.IsInstanceOfType(response, typeof(BranchPermission));
            Assert.AreEqual(setBranchPerm.Type, response.Type);
            Assert.AreEqual(setBranchPerm.Value, response.Value);
            Assert.IsTrue(response.Id > 0);

            await stashClient.Branches.DeletePermissions(EXISTING_PROJECT, EXISTING_REPOSITORY, response.Id);
        }