public async Task WhenUserNotInRole_ThenListNodesAsyncThrowsResourceAccessDeniedException( [Credential(Role = PredefinedRole.IapTunnelUser)] ResourceTask <ICredential> credential) { var adapter = new ComputeEngineAdapter(await credential); AssertEx.ThrowsAggregateException <ResourceAccessDeniedException>( () => adapter.ListNodesAsync( TestProject.ProjectId, CancellationToken.None).Wait()); AssertEx.ThrowsAggregateException <ResourceAccessDeniedException>( () => adapter.ListNodesAsync( new ZoneLocator(TestProject.ProjectId, "us-central1-a"), "group-1", CancellationToken.None).Wait()); }
public async Task WhenInstanceCreated_ThenProcessInstanceEventsAsyncCanFeedHistorySetBuilder( [LinuxInstance] ResourceTask <InstanceLocator> testInstance, [Credential(Roles = new[] { PredefinedRole.ComputeViewer, PredefinedRole.LogsViewer })] ResourceTask <ICredential> credential) { await testInstance; var instanceRef = await testInstance; var instanceBuilder = new InstanceSetHistoryBuilder( DateTime.UtcNow.AddDays(-7), DateTime.UtcNow); var computeAdapter = new ComputeEngineAdapter(await credential); instanceBuilder.AddExistingInstances( await computeAdapter.ListInstancesAsync(TestProject.ProjectId, CancellationToken.None), await computeAdapter.ListNodesAsync(TestProject.ProjectId, CancellationToken.None), await computeAdapter.ListDisksAsync(TestProject.ProjectId, CancellationToken.None), TestProject.ProjectId); var adapter = new AuditLogAdapter(await credential); await adapter.ProcessInstanceEventsAsync( new[] { TestProject.ProjectId }, null, // all zones. null, // all instances. instanceBuilder.StartDate, instanceBuilder, CancellationToken.None); var set = instanceBuilder.Build(); var testInstanceHistory = set.Instances.FirstOrDefault(i => i.Reference == instanceRef); Assert.IsNotNull(testInstanceHistory, "Instance found in history"); }