public async Task WhenNoEnrollmentProvided_ThenDeviceCertiticateAuthenticationIsOff( [Credential(Role = PredefinedRole.ComputeViewer)] ResourceTask <ICredential> credential) { var adapter = new ResourceManagerAdapter(await credential); Assert.IsFalse(adapter.IsDeviceCertiticateAuthenticationEnabled); }
public async Task WhenUserNotInRole_ThenIsGrantedPermissionReturnsFalse( [Credential(Role = PredefinedRole.ComputeViewer)] ResourceTask <ICredential> credential) { var adapter = new ResourceManagerAdapter(await credential); var result = await adapter.IsGrantedPermission( TestProject.ProjectId, "compute.disks.create"); Assert.IsFalse(result); }
public async Task WhenUserInRole_ThenIsGrantedPermissionReturnsTrue( [Credential(Role = PredefinedRole.ComputeViewer)] ResourceTask <ICredential> credential) { var adapter = new ResourceManagerAdapter(await credential); var result = await adapter.IsGrantedPermission( TestProject.ProjectId, Permissions.ComputeInstancesGet); Assert.IsTrue(result); }
public async Task WhenUserNotInRole_ThenGetProjectThrowsResourceAccessDeniedException( [Credential(Role = PredefinedRole.IapTunnelUser)] ResourceTask <ICredential> credential) { using (var adapter = new ResourceManagerAdapter(await credential)) { AssertEx.ThrowsAggregateException <ResourceAccessDeniedException>( () => adapter.GetProjectAsync( TestProject.ProjectId, CancellationToken.None).Wait()); } }
public async Task WhenUserInRole_ThenIsGrantedPermissionReturnsTrue( [Credential(Role = PredefinedRole.ComputeViewer)] CredentialRequest credential) { var adapter = new ResourceManagerAdapter(await credential.GetCredentialAsync()); var result = await adapter.IsGrantedPermission( TestProject.ProjectId, "compute.instances.get"); Assert.IsTrue(result); }
public async Task WhenUserInViewerRole_ThenGetProjectReturnsProject( [Credential(Role = PredefinedRole.ComputeViewer)] ResourceTask <ICredential> credential) { using (var adapter = new ResourceManagerAdapter(await credential)) { var project = await adapter.GetProjectAsync( TestProject.ProjectId, CancellationToken.None); Assert.IsNotNull(project); Assert.AreEqual(TestProject.ProjectId, project.ProjectId); } }
public async Task WhenProjectIdExists_ThenQueryProjectsByIdReturnsProject( [Credential(Role = PredefinedRole.ComputeViewer)] ResourceTask <ICredential> credential) { using (var adapter = new ResourceManagerAdapter(await credential)) { var project = await adapter.QueryProjectsById( TestProject.ProjectId, CancellationToken.None); Assert.IsNotNull(project); Assert.AreEqual(1, project.Count()); Assert.AreEqual(TestProject.ProjectId, project.First().ProjectId); } }
public async Task WhenUserNotInRole_ThenIsGrantedPermissionReturnsFalse( [LinuxInstance] InstanceRequest testInstance, [Credential(Role = PredefinedRole.ComputeViewer)] CredentialRequest credential) { await testInstance.AwaitReady(); var instanceRef = await testInstance.GetInstanceAsync(); var adapter = new ResourceManagerAdapter(await credential.GetCredentialAsync()); var result = await adapter.IsGrantedPermission( TestProject.ProjectId, "iam.serviceAccounts.actAs"); Assert.IsFalse(result); }
public async Task WhenProjectIdExists_ThenQueryProjectsByIdReturnsProject( [Credential(Role = PredefinedRole.ComputeViewer)] ResourceTask <ICredential> credential) { using (var adapter = new ResourceManagerAdapter(await credential)) { var result = await adapter.ListProjects( ProjectFilter.ByProjectId(TestProject.ProjectId), null, CancellationToken.None); Assert.IsNotNull(result); Assert.IsFalse(result.IsTruncated); Assert.AreEqual(1, result.Projects.Count()); Assert.AreEqual(TestProject.ProjectId, result.Projects.First().ProjectId); } }
public async Task WhenProjectIdExists_ThenQueryProjectsByPrefixReturnsProject( [Credential(Role = PredefinedRole.ComputeViewer)] ResourceTask <ICredential> credential) { using (var adapter = new ResourceManagerAdapter(await credential)) { // Remove last character from project ID. var prefix = TestProject.ProjectId.Substring(0, TestProject.ProjectId.Length - 1); var project = await adapter.QueryProjectsByPrefix( prefix, CancellationToken.None); Assert.IsNotNull(project); Assert.IsTrue(project.Any()); CollectionAssert.Contains( project.Select(p => p.ProjectId), TestProject.ProjectId); } }
public void WhenEnrollmentProvided_ThenDeviceCertiticateAuthenticationIsOn() { var adapter = new ResourceManagerAdapter(CreateAuthorizationAdapterForSecureConnectUser()); Assert.IsTrue(adapter.IsDeviceCertiticateAuthenticationEnabled); }