Skip to content

Commit

Permalink
More test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnMcPMS committed Oct 3, 2024
1 parent 57f794f commit 2f2d871
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,23 @@ public async Task ApplyMixedElevationUnits()
Directory.CreateDirectory(tempDirectory);

ConfigurationSet configurationSet = this.ConfigurationSet();
configurationSet.SchemaVersion = "0.2";
configurationSet.Metadata.Add(Helpers.Constants.EnableDynamicFactoryTestMode, true);

ConfigurationUnit unit = this.ConfigurationUnit();
unit.Metadata.Add("version", version.ToString());
unit.Metadata.Add("module", moduleName);
unit.Settings.Add("directoryPath", tempDirectory);
unit.Type = resourceName;
unit.Intent = ConfigurationUnitIntent.Apply;

ConfigurationUnit elevatedUnit = this.ConfigurationUnit();
elevatedUnit.Metadata.Add("version", version.ToString());
elevatedUnit.Metadata.Add("module", moduleName);
elevatedUnit.Metadata.Add("securityContext", "elevated");
elevatedUnit.Settings.Add("directoryPath", tempDirectory);
elevatedUnit.Type = resourceName;
elevatedUnit.Intent = ConfigurationUnitIntent.Apply;

configurationSet.Units = new ConfigurationUnit[] { unit, elevatedUnit };

Expand Down Expand Up @@ -110,22 +113,23 @@ public async Task ApplyUnitNotInLimitationSet()
Version version = new Version("0.0.0.1");

ConfigurationSet configurationSet = this.ConfigurationSet();
configurationSet.SchemaVersion = "0.2";
configurationSet.Metadata.Add(Helpers.Constants.EnableDynamicFactoryTestMode, true);
configurationSet.Metadata.Add(Helpers.Constants.ForceHighIntegrityLevelUnitsTestGuid, true);
configurationSet.Metadata.Add(Helpers.Constants.EnableRestrictedIntegrityLevelTestGuid, true);

ConfigurationUnit unit = this.ConfigurationUnit();
unit.Metadata.Add("version", version.ToString());
unit.Metadata.Add("module", moduleName);
unit.Identifier = "restrictedUnit";
unit.Type = resourceName;
unit.Intent = ConfigurationUnitIntent.Apply;

ConfigurationUnit elevatedUnit = this.ConfigurationUnit();
elevatedUnit.Metadata.Add("version", version.ToString());
elevatedUnit.Metadata.Add("module", moduleName);
elevatedUnit.Metadata.Add("securityContext", "elevated");
unit.Identifier = "elevatedUnit";
elevatedUnit.Type = resourceName;
elevatedUnit.Intent = ConfigurationUnitIntent.Apply;

configurationSet.Units = new ConfigurationUnit[] { unit, elevatedUnit };

Expand Down Expand Up @@ -197,9 +201,9 @@ public async Task SecureParameterAcrossIntegrityBoundaryFails()

ConfigurationProcessor processor = this.CreateConfigurationProcessorWithDiagnostics(dynamicFactory);

ApplyConfigurationSetResult result = processor.ApplySet(configurationSet, ApplyConfigurationSetFlags.None);
Assert.NotNull(result.ResultCode);
Assert.Equal(Errors.WINGET_CONFIG_ERROR_PARAMETER_INTEGRITY_BOUNDARY, result.ResultCode.HResult);
// While parameters are not supported, we expect to get a not implemented exception.
// Once they are implemented, swap to the appropriate error mechanism for the parameter integrity boundary.
Assert.Throws<NotImplementedException>(() => processor.ApplySet(configurationSet, ApplyConfigurationSetFlags.None));
}
}
}

0 comments on commit 2f2d871

Please sign in to comment.