Beispiel #1
0
        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);
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        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 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);
        }