public async Task ReconcileIntegrationTestForMasterBranchPermission() { var repositoryId = "6435e3f0-15b7-4302-814d-4ab586e61f8b"; var client = new VstsRestClient(_config.Organization, _config.Token); var projectId = (await client.GetAsync(Project.Properties(_config.Project))).Id; await ManagePermissions .ForMasterBranch(client, projectId, repositoryId) .Permissions(Permissions.BypassPoliciesPullRequest) .SetToAsync(PermissionId.Allow); var rule = new NobodyCanBypassPolicies(client); (await rule.EvaluateAsync(projectId, repositoryId)) .ShouldBe(false); await rule.ReconcileAsync(projectId, repositoryId); await Policy .Handle <Exception>() .WaitAndRetryAsync(Constants.NumRetries, t => TimeSpan.FromSeconds(t)) .ExecuteAsync(async() => { (await rule.EvaluateAsync(projectId, repositoryId)).ShouldBe(true); }); }
public async Task ReconcileIntegrationTest() { var repositoryId = "3167b64e-c72b-4c55-84eb-986ac62d0dec"; var client = new VstsRestClient(_config.Organization, _config.Token); var projectId = (await client.GetAsync(Project.Properties(_config.Project))).Id; await ManagePermissions .ForRepository(client, projectId, repositoryId) .Permissions(Permissions.BypassPoliciesPullRequest) .SetToAsync(PermissionId.Allow); var rule = new NobodyCanBypassPolicies(client); (await rule.EvaluateAsync(projectId, repositoryId)) .ShouldBe(false); await rule.ReconcileAsync(projectId, repositoryId); await Policy .Handle <Exception>() .WaitAndRetryAsync(Constants.NumRetries, t => TimeSpan.FromSeconds(t)) .ExecuteAsync(async() => { (await rule.EvaluateAsync(projectId, repositoryId)).ShouldBe(true); }); }
public async Task Reconcile() { // Arrange CustomizePermission(PermissionId.Allow, Permissions.BypassPoliciesPullRequest); var client = _fixture.Create <IVstsRestClient>(); // Act var rule = new NobodyCanBypassPolicies(client); await rule.ReconcileAsync(_fixture.Create <string>(), _fixture.Create <string>()); // Assert await client .Received(_fixture.RepeatCount *_fixture.RepeatCount * 2) // identities * permissions * 2 for repository and master branch .PostAsync(Arg.Any <IVstsRequest <Requests.Permissions.UpdateWrapper, object> >(), Arg.Any <Requests.Permissions.UpdateWrapper>()); }
public async Task EvaluateTrue( [CombinatorialValues(PermissionId.Deny, PermissionId.DenyInherited, PermissionId.NotSet)] int permissionId, [CombinatorialValues( Permissions.ManagePermissions, Permissions.BypassPoliciesCodePush, Permissions.BypassPoliciesPullRequest)] int permissionBit) { // Arrange CustomizePermission(permissionId, permissionBit); // Act var rule = new NobodyCanBypassPolicies(_fixture.Create <IVstsRestClient>()); var result = await rule.EvaluateAsync(_fixture.Create <string>(), _fixture.Create <string>()); // Assert result.ShouldBe(true); }
public async Task Exclude(string group) { // Arrange CustomizePermission(PermissionId.Allow, Permissions.BypassPoliciesPullRequest); CustomizeApplicationGroup(group); var client = _fixture.Create <IVstsRestClient>(); // Act var rule = new NobodyCanBypassPolicies(client); var result = await rule.EvaluateAsync(_fixture.Create <string>(), _fixture.Create <string>()); // Assert await client .Received(2) .GetAsync(Arg.Any <IVstsRequest <Response.ApplicationGroups> >()); // for both repository and master branch result.ShouldBe(true); }