public async Task WhenGuestAttributesDisabledByPolicy_ThenOsPropertiesAreNull( [WindowsInstance] ResourceTask <InstanceLocator> testInstance, [Credential(Role = PredefinedRole.ComputeViewer)] ResourceTask <ICredential> credential) { var locator = await testInstance; var gceAdapter = new ComputeEngineAdapter(await credential); var inventoryService = new Mock <IInventoryService>(); inventoryService.Setup(s => s.GetInstanceInventoryAsync( It.IsAny <InstanceLocator>(), It.IsAny <CancellationToken>())) .Throws(new GoogleApiException("mock", "mock") { Error = new Apis.Requests.RequestError() { Code = 412 } }); var model = await InstancePropertiesInspectorModel.LoadAsync( await testInstance, gceAdapter, inventoryService.Object, CancellationToken.None); Assert.AreEqual(locator.Name, model.InstanceName); Assert.AreEqual("RUNNING", model.Status); Assert.IsFalse(model.IsOsInventoryInformationPopulated); Assert.IsNull(model.Architecture); Assert.IsNull(model.KernelVersion); Assert.IsNull(model.OperatingSystemFullName); Assert.IsNull(model.OperatingSystemVersion); }
public async Task WhenLoadAsyncCompletes_ThenPropertiesArePopulated( [WindowsInstance] ResourceTask <InstanceLocator> testInstance, [Credential(Role = PredefinedRole.ComputeViewer)] ResourceTask <ICredential> credential) { var locator = await testInstance; var gceAdapter = new ComputeEngineAdapter(await credential); var model = await InstancePropertiesInspectorModel.LoadAsync( await testInstance, gceAdapter, new InventoryService(gceAdapter), CancellationToken.None); Assert.AreEqual(locator.Name, model.InstanceName); Assert.IsNull(model.Hostname); Assert.AreEqual("RUNNING", model.Status); Assert.IsNotNull(model.InternalIp); Assert.IsNotNull(model.ExternalIp); Assert.IsNotNull(model.Licenses); Assert.AreEqual(model.IsOsInventoryInformationPopulated ? FeatureFlag.Enabled : FeatureFlag.Disabled, model.OsInventory); Assert.AreEqual(FeatureFlag.Disabled, model.Diagnostics); Assert.AreEqual(FeatureFlag.Enabled, model.GuestAttributes); Assert.IsNull(model.InternalDnsMode); Assert.IsFalse(model.IsSoleTenant); Assert.AreEqual(WindowsInstanceAttribute.DefaultMachineType, model.MachineType); Assert.IsNull(model.Tags); }