Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for configure mixed elevation #4487

Merged
merged 14 commits into from
Jun 14, 2024
Prev Previous commit
Next Next commit
add tests and hooks
  • Loading branch information
ryfu-msft committed May 15, 2024
commit 6567d093e155d2a7d8a8d3e1e2ef81b0a9949011
42 changes: 42 additions & 0 deletions src/AppInstallerCLITests/TestHooks.h
Original file line number Diff line number Diff line change
Expand Up @@ -245,4 +245,46 @@ namespace TestHook
private:
AppInstaller::Authentication::AuthenticationResult m_authResult;
};

struct SetDisplayCatalogHttpPipelineStage_Override
{
SetDisplayCatalogHttpPipelineStage_Override(std::shared_ptr<web::http::http_pipeline_stage> value)
{
AppInstaller::MSStore::TestHooks::SetDisplayCatalogHttpPipelineStage_Override(value);
}

~SetDisplayCatalogHttpPipelineStage_Override()
{
AppInstaller::MSStore::TestHooks::SetDisplayCatalogHttpPipelineStage_Override(nullptr);
}
};

struct SetSfsClientAppContents_Override
{
SetSfsClientAppContents_Override(std::function<std::vector<SFS::AppContent>(std::string_view)> value) : m_appContentsFunction(std::move(value))
{
AppInstaller::MSStore::TestHooks::SetSfsClientAppContents_Override(&m_appContentsFunction);
}

~SetSfsClientAppContents_Override()
{
AppInstaller::MSStore::TestHooks::SetSfsClientAppContents_Override(nullptr);
}

private:
std::function<std::vector<SFS::AppContent>(std::string_view)> m_appContentsFunction;
};

struct SetLicensingHttpPipelineStage_Override
{
SetLicensingHttpPipelineStage_Override(std::shared_ptr<web::http::http_pipeline_stage> value)
{
AppInstaller::MSStore::TestHooks::SetLicensingHttpPipelineStage_Override(value);
}

~SetLicensingHttpPipelineStage_Override()
{
AppInstaller::MSStore::TestHooks::SetLicensingHttpPipelineStage_Override(nullptr);
}
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,15 @@
elevationRequiredUnit.Metadata.Add("securityContext", "elevated");
elevationRequiredUnit.Metadata.Add("version", version.ToString());
elevationRequiredUnit.Metadata.Add("module", moduleName);
elevationRequiredUnit.Metadata.Add("secretCode", "123456789");

elevationRequiredUnit.Settings.Add("secretCode", "123456789");
elevationRequiredUnit.Type = resourceName;
elevationRequiredUnit.Intent = ConfigurationUnitIntent.Apply;

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

Expand Down Expand Up @@ -100,24 +101,17 @@

ConfigurationSet configurationSet = this.ConfigurationSet();
configurationSet.Metadata.Add(Helpers.Constants.DisableRunAsTestGuid, true);
configurationSet.Metadata.Add(Helpers.Constants.DisableHighIntegriySerializationTestGuid, true);

Check failure on line 104 in src/Microsoft.Management.Configuration.UnitTests/Tests/ConfigurationMixedElevationTests.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`Integriy` is not a recognized word. (unrecognized-spelling)

ConfigurationUnit elevationRequiredUnit1 = this.ConfigurationUnit();
elevationRequiredUnit1.Metadata.Add("securityContext", "elevated");
elevationRequiredUnit1.Metadata.Add("version", version.ToString());
elevationRequiredUnit1.Metadata.Add("module", moduleName);
elevationRequiredUnit1.Metadata.Add("secretCode", "123456789");

elevationRequiredUnit1.Settings.Add("secretCode", "123456789");
elevationRequiredUnit1.Type = resourceName;
elevationRequiredUnit1.Intent = ConfigurationUnitIntent.Apply;

//ConfigurationUnit elevationRequiredUnit2 = this.ConfigurationUnit();
//elevationRequiredUnit2.Metadata.Add("securityContext", "elevated");
//elevationRequiredUnit2.Metadata.Add("version", version.ToString());
//elevationRequiredUnit2.Metadata.Add("module", moduleName);
//elevationRequiredUnit2.Metadata.Add("secretCode", "123456789");
//elevationRequiredUnit2.Type = resourceName;
//elevationRequiredUnit2.Intent = ConfigurationUnitIntent.Apply;

configurationSet.Units = new ConfigurationUnit[] { elevationRequiredUnit1 };

IConfigurationSetProcessorFactory dynamicFactory = await this.fixture.ConfigurationStatics.CreateConfigurationSetProcessorFactoryAsync(Helpers.Constants.DynamicRuntimeHandlerIdentifier);
Expand All @@ -126,8 +120,9 @@

ApplyConfigurationSetResult result = processor.ApplySet(configurationSet, ApplyConfigurationSetFlags.None);
Assert.NotNull(result);
Assert.Null(result.ResultCode);
Assert.Equal(2, result.UnitResults.Count);
Assert.NotNull(result.ResultCode);
Assert.Equal(Errors.WINGET_CONFIG_ERROR_SET_APPLY_FAILED, result.ResultCode.HResult);
Assert.Equal(1, result.UnitResults.Count);
}
}
}
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.