├── .gitignore
├── .vscode
├── launch.json
├── settings.json
└── tasks.json
├── LICENSE
├── NOTES.md
├── README.md
├── TODO.md
├── TugDSC.common.props
├── TugDSC.sharedasm.props
├── TugDSC.sln
├── Zyborg-tug.sln
├── appveyor.yml
├── doc
├── art
│ └── logo
│ │ ├── README.md
│ │ ├── TUGBOAT VECTOR-02.eps
│ │ ├── TUGBOAT VECTOR-02.svg
│ │ ├── tug-logo-solid.png
│ │ ├── tug-logo-trans-150.png
│ │ ├── tug-logo-trans-150b.png
│ │ ├── tug-logo-trans-300.png
│ │ ├── tug-logo-trans-300b.png
│ │ ├── tug-logo-trans-600.png
│ │ ├── tug-logo-trans-600b.png
│ │ ├── tug-logo-trans-75.png
│ │ ├── tug-logo-trans-75b.png
│ │ ├── tug-logo-trans.png
│ │ ├── tug-logo.vsdx
│ │ └── wordart.pptx
├── draw.io
│ ├── PowerShellOrg tug - Provider Model.png
│ ├── PowerShellOrg tug - Provider Model.xml
│ ├── Tug.Server-mvc-design.png
│ └── Tug.Server-mvc-design.xml
├── dsc-ecosystem.md
└── impl
│ └── ProviderModel.md
├── migrate-report.json
├── references
├── MS-DSCPM-FullJsonSchema.json
├── cmdlets.md
├── observations.md
├── regkey-authorization.md
└── wireshark_traces
│ ├── Issue 58 Registration with Tug Server.pcapng
│ ├── Issue 58 Tug Server Log.txt
│ ├── SendReport-request-sample-1.txt
│ ├── sample-registration-configurationrepository.json
│ ├── sample-registration-reportserver.json
│ ├── sample-registration-resourcerepository.json
│ ├── v2 Initial node registration, config pull, module pull, and reporting.pcapng
│ ├── v2 LCM fails when given multiple configuration names on one pull server.pcapng
│ ├── v2 node was given new config to pull - it was pulled applied and reported - no module download.pcapng
│ └── v2 node with partials.pcapng
├── sample-module
└── README.md
├── src
├── Tug.Base
│ ├── Ext
│ │ ├── IProvider.cs
│ │ ├── IProviderManager.cs
│ │ ├── IProviderProduct.cs
│ │ ├── ProviderInfo.cs
│ │ ├── ProviderParameterInfo.cs
│ │ └── Util
│ │ │ ├── MefExtensions.cs
│ │ │ ├── ProviderExtensions.cs
│ │ │ ├── ProviderManagerBase.cs
│ │ │ └── ServiceProviderExportDescriptorProvider.cs
│ ├── Messages
│ │ ├── DscRequest.cs
│ │ ├── DscResponse.cs
│ │ ├── GetConfiguration.cs
│ │ ├── GetDscAction.cs
│ │ ├── GetModule.cs
│ │ ├── GetReports.cs
│ │ ├── ModelBinding
│ │ │ └── ModelBinding.cs
│ │ ├── RegisterDscAgent.cs
│ │ └── SendReport.cs
│ ├── Model
│ │ ├── ActionDetailsItem.cs
│ │ ├── AgentInformation.cs
│ │ ├── CertificateInformation.cs
│ │ ├── ClientStatusItem.cs
│ │ ├── GetDscActionRequestBody.cs
│ │ ├── GetDscActionResponseBody.cs
│ │ ├── GetReportsResponseBody.cs
│ │ ├── ModelCommon.cs
│ │ ├── RegisterDscAgentRequestBody.cs
│ │ ├── RegistrationInformation.cs
│ │ └── SendReportBody.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── Tug.Base.csproj
│ └── Util
│ │ ├── ExceptionExtensions.cs
│ │ ├── ExtDataBase.cs
│ │ ├── ExtDataExtensions.cs
│ │ ├── ExtDataIndexerBase.cs
│ │ ├── IExtData.cs
│ │ ├── ReadOnlyConfiguration.cs
│ │ └── ReadOnlyConfigurationSection.cs
├── Tug.Client
│ ├── AppLog.cs
│ ├── Configuration
│ │ ├── CommandLine.cs
│ │ ├── DscPullConfig.cs
│ │ ├── OfType.cs
│ │ └── UseType.cs
│ ├── DscPullClient.cs
│ ├── FileResponse.cs
│ ├── Program.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── Tug.Client.csproj
│ ├── Util
│ │ └── BasicWebProxy.cs
│ └── appsettings.json
├── Tug.Ext-WORK
│ ├── Ext.1
│ │ ├── ExtInfo.cs
│ │ ├── ExtManagerBase.1.cs
│ │ ├── IExtManager.1.cs
│ │ └── IExtProvider.1.cs
│ ├── Ext
│ │ ├── ExtensionAttribute.cs
│ │ ├── IExtManager.cs
│ │ ├── IExtension.cs
│ │ ├── Provider
│ │ │ ├── ExtParameterInfo.cs
│ │ │ ├── IProviderExtension.cs
│ │ │ └── IProviderProduct.cs
│ │ └── Util
│ │ │ ├── ExtManagerBase.cs
│ │ │ └── MefExtensions.cs
│ ├── Program.cs
│ └── Tug.Ext-WORK.csproj
├── Tug.Server.Base
│ ├── ActionStatus.cs
│ ├── Configuration
│ │ ├── AppSettings.cs
│ │ ├── AuthzSettings.cs
│ │ ├── ChecksumSettings.cs
│ │ ├── ExtSettings.cs
│ │ ├── HandlerSettings.cs
│ │ └── LogSettings.cs
│ ├── DscHandlerConfig.cs
│ ├── FileContent.cs
│ ├── Filters
│ │ ├── DscRegKeyAuthzFilter.cs
│ │ ├── DscRegKeyAuthzFilterAlt.cs
│ │ ├── InspectAuthzFilter.cs
│ │ ├── StrictInputFilter.cs
│ │ └── VeryStrictInputFilter.cs
│ ├── IChecksumAlgorithm.cs
│ ├── IChecksumAlgorithmProvider.cs
│ ├── IDscHandler.cs
│ ├── IDscHandlerProvider.cs
│ ├── Mvc
│ │ └── ModelResult.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── Tug.Server.Base.csproj
│ └── Util
│ │ ├── ChecksumHelper.cs
│ │ └── DscHandlerHelper.cs
├── Tug.Server.FaaS.AwsLambda
│ ├── Configuration
│ │ ├── AppSettings.cs
│ │ ├── HostSettings.cs
│ │ └── PullServiceSettings.cs
│ ├── Controllers
│ │ └── DscController.cs
│ ├── FunctionMain.cs
│ ├── FunctionStartup.cs
│ ├── LambdaAuthzStorageHandler.cs
│ ├── README-LAMBDA.md
│ ├── README.md
│ ├── Tug.Server.FaaS.AwsLambda.csproj
│ ├── sample-appsettings.json
│ ├── sample-aws-lambda-tools-defaults.json
│ ├── sample-deploy-serverless.cmd
│ └── serverless.template
├── Tug.Server.FaaS.AzureFunctions
│ └── README.md
├── Tug.Server.Providers.Ps5DscHandler
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── Ps5CustomHost.cs
│ ├── Ps5CustomHostRawUI.cs
│ ├── Ps5CustomHostUI.cs
│ ├── Ps5DscHandler.cs
│ ├── Ps5DscHandlerProvider.cs
│ ├── PsLogger.cs
│ ├── README.md
│ └── Tug.Server.Providers.Ps5DscHandler.csproj
├── Tug.Server
│ ├── AppLog.cs
│ ├── Controllers
│ │ ├── DscController.cs
│ │ └── DscReportingController.cs
│ ├── Program.cs
│ ├── Properties
│ │ ├── AssemblyInfo.cs
│ │ └── launchSettings.json
│ ├── Providers
│ │ ├── BasicDscHandler.cs
│ │ ├── BasicDscHandlerProvider.cs
│ │ ├── Sha256ChecksumAlgorithm.cs
│ │ └── Sha256ChecksumAlgorithmProvider.cs
│ ├── Startup.cs
│ ├── Tug.Server.csproj
│ └── appsettings.json
├── TugDSC.Abstractions
│ ├── Configuration
│ │ ├── Binder
│ │ │ ├── ConfigurationExtendedBinder.cs
│ │ │ ├── README.md
│ │ │ ├── Resources.Designer.cs
│ │ │ └── Resources.resx
│ │ ├── ReadOnlyConfiguration.cs
│ │ └── ReadOnlyConfigurationSection.cs
│ ├── Ext
│ │ ├── IProvider.cs
│ │ ├── IProviderManager.cs
│ │ ├── IProviderProduct.cs
│ │ ├── ProviderInfo.cs
│ │ ├── ProviderParameterInfo.cs
│ │ └── Util
│ │ │ ├── MefExtensions.cs
│ │ │ ├── ProviderExtensions.cs
│ │ │ ├── ProviderManagerBase.cs
│ │ │ └── ServiceProviderExportDescriptorProvider.cs
│ ├── Messages
│ │ ├── DscRequest.cs
│ │ ├── DscResponse.cs
│ │ ├── GetConfiguration.cs
│ │ ├── GetDscAction.cs
│ │ ├── GetModule.cs
│ │ ├── GetReports.cs
│ │ ├── ModelBinding
│ │ │ └── ModelBinding.cs
│ │ ├── RegisterDscAgent.cs
│ │ └── SendReport.cs
│ ├── Model
│ │ ├── ActionDetailsItem.cs
│ │ ├── AgentInformation.cs
│ │ ├── CertificateInformation.cs
│ │ ├── ClientStatusItem.cs
│ │ ├── GetDscActionRequestBody.cs
│ │ ├── GetDscActionResponseBody.cs
│ │ ├── GetReportsResponseBody.cs
│ │ ├── ModelCommon.cs
│ │ ├── RegisterDscAgentRequestBody.cs
│ │ ├── RegistrationInformation.cs
│ │ └── SendReportBody.cs
│ ├── README.md
│ ├── TugDSC.Abstractions.csproj
│ └── Util
│ │ ├── ExceptionExtensions.cs
│ │ ├── ExtDataBase.cs
│ │ ├── ExtDataExtensions.cs
│ │ ├── ExtDataIndexerBase.cs
│ │ └── IExtData.cs
├── TugDSC.Client.CLIApp
│ ├── AppLog.cs
│ ├── Configuration
│ │ ├── CommandLine.cs
│ │ └── DscPullConfig.cs
│ ├── DscPullClient.cs
│ ├── FileResponse.cs
│ ├── Program.cs
│ ├── TugDSC.Client.CLIApp.csproj
│ ├── Util
│ │ └── BasicWebProxy.cs
│ └── appsettings.json
├── TugDSC.Server.Abstractions
│ ├── ActionStatus.cs
│ ├── Configuration
│ │ ├── AppSettings.cs
│ │ ├── AuthzSettings.cs
│ │ ├── ChecksumSettings.cs
│ │ ├── ExtSettings.cs
│ │ ├── HandlerSettings.cs
│ │ └── LogSettings.cs
│ ├── DscHandlerConfig.cs
│ ├── FileContent.cs
│ ├── Filters
│ │ ├── DscRegKeyAuthzFilter.cs
│ │ ├── DscRegKeyAuthzFilterAlt.cs
│ │ ├── InspectAuthzFilter.cs
│ │ ├── StrictInputFilter.cs
│ │ └── VeryStrictInputFilter.cs
│ ├── IChecksumAlgorithm.cs
│ ├── IChecksumAlgorithmProvider.cs
│ ├── IDscHandler.cs
│ ├── IDscHandlerProvider.cs
│ ├── Mvc
│ │ └── ModelResult.cs
│ ├── README.md
│ ├── TugDSC.Server.Abstractions.csproj
│ └── Util
│ │ ├── ChecksumHelper.cs
│ │ └── DscHandlerHelper.cs
├── TugDSC.Server.WebAppHost
│ ├── AppLog.cs
│ ├── Controllers
│ │ ├── DscController.cs
│ │ └── DscReportingController.cs
│ ├── Program.cs
│ ├── Properties
│ │ └── launchSettings.json
│ ├── Providers
│ │ ├── BasicDscHandler.cs
│ │ ├── BasicDscHandlerProvider.cs
│ │ ├── Sha256ChecksumAlgorithm.cs
│ │ └── Sha256ChecksumAlgorithmProvider.cs
│ ├── README.md
│ ├── Startup.cs
│ ├── StartupLogger.cs
│ ├── TugDSC.Server.WebAppHost.csproj
│ ├── appsettings.Development.json
│ ├── appsettings.json
│ └── pwsh
│ │ └── TugDSC.Server.psm1
├── bundles
│ ├── Tug.Server-ps5
│ │ ├── Tug.Server-ps5.csproj
│ │ ├── build-posh-module.cmd
│ │ └── posh-res
│ │ │ ├── Tug.Server-ps5.psd1
│ │ │ ├── Tug.Server-ps5.psm1
│ │ │ └── samples
│ │ │ ├── README.md
│ │ │ ├── RegistrationKeys.txt
│ │ │ ├── appsettings.json
│ │ │ ├── hosting.json.sample
│ │ │ ├── nlog.config
│ │ │ └── tug-server.cmd
│ └── TugDSC.Server.Basic
│ │ ├── Bundles.targets
│ │ ├── README.md
│ │ ├── build.ps1
│ │ └── src
│ │ ├── TugDSC.Server.Basic
│ │ ├── TugDSC.Server.Basic.Install.psm1
│ │ ├── TugDSC.Server.Basic.Publish.psm1
│ │ └── TugDSC.Server.Basic.psd1
│ │ └── assets
│ │ ├── RegistrationKeys.txt
│ │ ├── appsettings.json.sample
│ │ └── hosting.json.sample
├── shared
│ ├── SharedAssemblyInfo.cs
│ ├── SharedAssemblyVersionInfo.cs
│ └── SharedGlobalSuppressions.cs
└── testing
│ └── TugDSC.Testing.MSTest
│ ├── TugAssert.cs
│ └── TugDSC.Testing.MSTest.csproj
├── test
├── Tug.Ext-tests-aux
│ ├── FuncThingy.cs
│ ├── FuncThingyProvider.cs
│ ├── README.md
│ └── Tug.Ext-tests-aux.csproj
├── Tug.Ext-tests
│ ├── README.md
│ ├── TestExt
│ │ ├── DynamicThingyProviderManager.cs
│ │ ├── IThingy.cs
│ │ ├── IThingyProvider.cs
│ │ ├── Impl
│ │ │ ├── BasicThingy.cs
│ │ │ └── BasicThingyProvider.cs
│ │ └── SimpleThingyProviderManager.cs
│ ├── Tests.cs
│ ├── Tug.Ext-tests.csproj
│ └── project.xunit.json
├── Tug.UnitTesting
│ ├── Tug.UnitTesting.csproj
│ └── TugAssert.cs
├── client
│ ├── Tug.Client-tests
│ │ ├── ClassicPullServerProtocolCompatibilityReportTests.cs
│ │ ├── ClassicPullServerProtocolCompatibilityTests.cs
│ │ ├── ProtocolCompatibilityTestsBase.cs
│ │ ├── Tug.Client-tests.csproj
│ │ ├── test-default.cmd
│ │ ├── test-lambda-with-fiddler.cmd
│ │ ├── test-localhost5000.cmd
│ │ ├── test-server1_5000-with-fiddler.cmd
│ │ ├── test-server2-with-fiddler.cmd
│ │ └── test-with-fiddler.cmd
│ ├── TugDSC.Client.CLIApp-tests
│ │ ├── ClassicPullServerProtocolCompatibilityReportTests.cs
│ │ ├── ClassicPullServerProtocolCompatibilityTests.cs
│ │ ├── ProtocolCompatibilityTestsBase.cs
│ │ ├── README.md
│ │ ├── TugDSC.Client.CLIApp-tests.csproj
│ │ └── run-test.ps1
│ ├── run-client.ps1
│ └── run-profiles
│ │ └── netcore
│ │ ├── appsettings.json
│ │ └── nlog.config
└── server
│ ├── Tug.Server-itests
│ ├── BasicPullHandlerRoot
│ │ ├── Configuration
│ │ │ └── SHARED
│ │ │ │ ├── FYI
│ │ │ │ ├── StaticTestConfig.dsc.ps1
│ │ │ │ └── StaticTestConfig.mof.checksum
│ │ │ │ └── StaticTestConfig.mof
│ │ ├── Modules
│ │ │ └── xPSDesiredStateConfiguration
│ │ │ │ ├── 5.1.0.0.zip
│ │ │ │ └── FYI
│ │ │ │ └── 5.1.0.0.zip.checksum
│ │ └── RegKeys
│ │ │ └── RegistrationKeys.txt
│ ├── IntegTestDscHandler.cs
│ ├── IntegTestDscHandlerProvider.cs
│ ├── ServerProtocolTests.cs
│ ├── Tug.Server-itests.csproj
│ ├── appsettings.json
│ ├── nlog.config
│ ├── project.json.ORIG
│ └── test-framework-net462.cmd
│ ├── Tug.Server.FaaS.AwsLambda-tests
│ ├── FunctionMainTest.cs
│ ├── SampleRequests
│ │ ├── Get-Base.json
│ │ ├── Get-Default.json
│ │ └── Put-RegisterDscAgent.json
│ ├── Tug.Server.FaaS.AwsLambda-tests.csproj
│ └── appsettings.json
│ ├── TugDSC.Server-tests
│ ├── BasicPullHandlerRoot
│ │ ├── Configuration
│ │ │ └── SHARED
│ │ │ │ ├── FYI
│ │ │ │ ├── StaticTestConfig.dsc.ps1
│ │ │ │ └── StaticTestConfig.mof.checksum
│ │ │ │ └── StaticTestConfig.mof
│ │ ├── Modules
│ │ │ └── xPSDesiredStateConfiguration
│ │ │ │ ├── 5.1.0.0.zip
│ │ │ │ └── FYI
│ │ │ │ └── 5.1.0.0.zip.checksum
│ │ └── RegKeys
│ │ │ └── RegistrationKeys.txt
│ ├── IntegTestDscHandler.cs
│ ├── IntegTestDscHandlerProvider.cs
│ ├── ServerProtocolTests.cs
│ ├── TugDSC.Server-tests.csproj
│ └── appsettings.json
│ ├── ext
│ ├── README.md
│ ├── Sample.TestExt.DynamicThingy
│ │ ├── DynamicThingy.cs
│ │ ├── DynamicThingyProvider.cs
│ │ └── Sample.TestExt.DynamicThingy.csproj
│ ├── Sample.TestExt.Thingy
│ │ ├── DynamicThingyProviderManager.cs
│ │ ├── IThingy.cs
│ │ ├── IThingyProvider.cs
│ │ ├── Impl
│ │ │ ├── BasicThingy.cs
│ │ │ └── BasicThingyProvider.cs
│ │ ├── Sample.TestExt.Thingy.csproj
│ │ └── SimpleThingyProviderManager.cs
│ └── TugDSC.Ext-tests
│ │ ├── ExtTests.cs
│ │ └── TugDSC.Ext-tests.csproj
│ ├── misc
│ └── TugDSC.Configuration-tests
│ │ ├── BinderTests.cs
│ │ ├── TugDSC.Configuration-tests.csproj
│ │ └── test1.json
│ ├── run-profiles
│ ├── net461-ps6
│ │ ├── BasicTugCmdlets.ps1
│ │ ├── DummyTugCmdlets.ps1
│ │ ├── appsettings.json
│ │ └── nlog.config
│ ├── net461
│ │ ├── appsettings.json
│ │ └── nlog.config
│ └── netcore
│ │ ├── appsettings.json
│ │ └── nlog.config
│ └── run-server.ps1
├── tools
└── ci
│ ├── DSC
│ ├── .gitignore
│ ├── DscCommon.ps1
│ ├── DscPullServer.dsc.ps1
│ ├── LCMConfig.dsc.ps1
│ ├── StaticTestConfig-copy.ps1
│ ├── StaticTestConfig.dsc.ps1
│ ├── StaticTestConfig.mof
│ ├── StaticTestConfig.mof.checksum
│ ├── TestConfig1.dsc.ps1
│ ├── xPSDesiredStateConfiguration-copy.ps1
│ ├── xPSDesiredStateConfiguration_5.1.0.0.zip
│ └── xPSDesiredStateConfiguration_5.1.0.0.zip.checksum
│ ├── README.md
│ ├── appveyor-template.rdp
│ └── av-connect.ps1
└── tug-core1-ps5.sln
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | // Place your settings in this file to overwrite default and user settings.
2 | {
3 | "cSpell.words": [
4 | "ASMNAME",
5 | "HMACSHA",
6 | "Integ",
7 | "Requ",
8 | "Shhh",
9 | "asms",
10 | "assms",
11 | "authz",
12 | "csum",
13 | "dotnetfw",
14 | "dyna",
15 | "ext",
16 | "finalizer",
17 | "jsons",
18 | "nlog",
19 | "rtasm",
20 | "uncomment"
21 | ]
22 | }
--------------------------------------------------------------------------------
/.vscode/tasks.json:
--------------------------------------------------------------------------------
1 | {
2 | // See https://go.microsoft.com/fwlink/?LinkId=733558
3 | // for the documentation about the tasks.json format
4 | "version": "0.1.0",
5 | "command": "dotnet",
6 | "isShellCommand": true,
7 | "args": [],
8 | "tasks": [
9 | {
10 | "taskName": "build",
11 | "args": [
12 | "${workspaceRoot}/src/tug/project.json"
13 | ],
14 | "isBuildCommand": true,
15 | "problemMatcher": "$msCompile"
16 | }
17 | ]
18 | }
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | PowerShell.org Tug DSC Pull Server
4 |
5 | Copyright (c) 2019 The DevOps Collective, Inc.
6 |
7 | Permission is hereby granted, free of charge, to any person obtaining a copy
8 | of this software and associated documentation files (the "Software"), to deal
9 | in the Software without restriction, including without limitation the rights
10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | copies of the Software, and to permit persons to whom the Software is
12 | furnished to do so, subject to the following conditions:
13 |
14 | The above copyright notice and this permission notice shall be included in all
15 | copies or substantial portions of the Software.
16 |
17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 | SOFTWARE.
24 |
--------------------------------------------------------------------------------
/TugDSC.common.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | true
6 |
7 |
8 |
14 |
15 |
16 | $(MSBuildThisFileDirectory)/src/shared
17 | netstandard2.0
18 | netcoreapp2.0
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 | $(DefineConstants);DOTNET_CORE
27 |
28 |
29 |
30 | $(DefineConstants);DOTNET_CORE
31 |
32 |
33 |
34 | $(DefineConstants);DOTNET_FRAMEWORK
35 |
36 |
37 |
38 |
39 | en-US
40 | github.com/PowerShellOrg/tug/graphs/contributors
41 |
47 | CS0169;CS0649
48 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/doc/art/logo/README.md:
--------------------------------------------------------------------------------
1 | # Logo Artwork
2 |
3 | The original icon of a tugboat comes from [Vecteezy](https://www.vecteezy.com/vector-art/131644-tugboat-vector).
4 |
5 | The composite EPS file was converted to SVG using [CloudConvert](https://cloudconvert.com/eps-to-svg).
6 |
7 | One of the tugboats as extracted and edited as per the Vecteezy ToCs using Visio.
8 |
9 | We use Paint.NET to do final clean up and saving with a transparent background.
10 |
11 | --
12 |
13 | Used PowerPoint WordArt to create a *skewed* or curved name for the ship, christened the D.S. Configuration.
14 |
15 | Added the PS logo to the [funnel](https://en.wikipedia.org/wiki/Funnel_(ship)).
16 |
17 | Brightened-up the color scheme.
18 |
19 | Copied from Visio and pasted to Paint.NET. Scaled down and saved to each of the four stock widths:
20 | * 600px
21 | * 300px
22 | * 150px
23 | * 75px
24 |
25 | ## Attribution
26 |
27 | Vectors by [Vecteezy.com](http://www.Vecteezy.com/)
28 |
29 | ## Embed Example
30 |
31 | width | v1 | v2
32 | ------|----|----
33 | ` 75` |  | 
34 | `150` |  | 
35 | `300` |  | 
36 | `600` |  | 
37 |
--------------------------------------------------------------------------------
/doc/art/logo/TUGBOAT VECTOR-02.eps:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PowerShellOrg/tug/aab51f407b92475ae64cc14a0dea33d459fe9885/doc/art/logo/TUGBOAT VECTOR-02.eps
--------------------------------------------------------------------------------
/doc/art/logo/tug-logo-solid.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PowerShellOrg/tug/aab51f407b92475ae64cc14a0dea33d459fe9885/doc/art/logo/tug-logo-solid.png
--------------------------------------------------------------------------------
/doc/art/logo/tug-logo-trans-150.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PowerShellOrg/tug/aab51f407b92475ae64cc14a0dea33d459fe9885/doc/art/logo/tug-logo-trans-150.png
--------------------------------------------------------------------------------
/doc/art/logo/tug-logo-trans-150b.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PowerShellOrg/tug/aab51f407b92475ae64cc14a0dea33d459fe9885/doc/art/logo/tug-logo-trans-150b.png
--------------------------------------------------------------------------------
/doc/art/logo/tug-logo-trans-300.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PowerShellOrg/tug/aab51f407b92475ae64cc14a0dea33d459fe9885/doc/art/logo/tug-logo-trans-300.png
--------------------------------------------------------------------------------
/doc/art/logo/tug-logo-trans-300b.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PowerShellOrg/tug/aab51f407b92475ae64cc14a0dea33d459fe9885/doc/art/logo/tug-logo-trans-300b.png
--------------------------------------------------------------------------------
/doc/art/logo/tug-logo-trans-600.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PowerShellOrg/tug/aab51f407b92475ae64cc14a0dea33d459fe9885/doc/art/logo/tug-logo-trans-600.png
--------------------------------------------------------------------------------
/doc/art/logo/tug-logo-trans-600b.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PowerShellOrg/tug/aab51f407b92475ae64cc14a0dea33d459fe9885/doc/art/logo/tug-logo-trans-600b.png
--------------------------------------------------------------------------------
/doc/art/logo/tug-logo-trans-75.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PowerShellOrg/tug/aab51f407b92475ae64cc14a0dea33d459fe9885/doc/art/logo/tug-logo-trans-75.png
--------------------------------------------------------------------------------
/doc/art/logo/tug-logo-trans-75b.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PowerShellOrg/tug/aab51f407b92475ae64cc14a0dea33d459fe9885/doc/art/logo/tug-logo-trans-75b.png
--------------------------------------------------------------------------------
/doc/art/logo/tug-logo-trans.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PowerShellOrg/tug/aab51f407b92475ae64cc14a0dea33d459fe9885/doc/art/logo/tug-logo-trans.png
--------------------------------------------------------------------------------
/doc/art/logo/tug-logo.vsdx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PowerShellOrg/tug/aab51f407b92475ae64cc14a0dea33d459fe9885/doc/art/logo/tug-logo.vsdx
--------------------------------------------------------------------------------
/doc/art/logo/wordart.pptx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PowerShellOrg/tug/aab51f407b92475ae64cc14a0dea33d459fe9885/doc/art/logo/wordart.pptx
--------------------------------------------------------------------------------
/doc/draw.io/PowerShellOrg tug - Provider Model.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PowerShellOrg/tug/aab51f407b92475ae64cc14a0dea33d459fe9885/doc/draw.io/PowerShellOrg tug - Provider Model.png
--------------------------------------------------------------------------------
/doc/draw.io/PowerShellOrg tug - Provider Model.xml:
--------------------------------------------------------------------------------
1 | 7Vlbb9sgFP41lraHVTZ2qPvYZG330imSJ+0Zm+OLik2ESZzu1w9i7PiSqNmUW6XkIeF8YA585wsHsOXO8vWLIIv0lVNgFrLp2nK/Wwj53r361sB7DWCMayARGa0hZwsE2R8woG3QZUah7DWUnDOZLfpgxIsCItnDiBC86jeLOet7XZAERkAQETZGf2dUpmZaCG/xH5AlaePZwQ91TUiit0TwZWH8WciNN5+6OidNX2aiZUoorzqQ+2S5M8G5rEv5egZMU9vQVj/3vKe2HbeAQh7yAPKoHfoPbhi6PsUO+mZ6WBG2NFzIZWLGKt8bfqo0kxAsSKTtSknAcqepzJmyHFXcEADaha2sdo7aSBgpS1OOeJ5FpsxICGzasjfjjAtVVfBCuZjGGWMNVFOKokjjvJBGPQ42dqedvfkonLAsKRQWKVpAmIbPJM+YFuhsMw5kB6Qo1c9roActBX+DTl8Uh3iifYwpbjgDIWHdgQzlL8BzkOJdNWlqm/A3fw9jVlutId9gaUdnnsGIkXfS9rwNsSqYKB8YcTSK+GMwv/v59EuBMy7g2oJPCfjxMPjotMHHkQ9hrGcgCM2g5+ceCAb7NMJo7Y4yHO9cynBHyjCyeBYkh4qLN1X+4t1NLDT9epNJRyZHkILfV4K7SwnoXErw9inhtkAcP/IuuqbQ432hDyQpKBFUFZ07fBPB+bJEu1+4iixxPxLInFcggrR+bjW5OmlMwKfeeaXho9DFR9o9DjJDa19kefA/iP71LQyfPPrD7HDZ8Dt7zov2QvCVOsMLC2GmBjCl2UoVE7nhT6H2PJg0dcprp/raBLPzsHliwbSHzR2ZJI7pw6mWEu+iWhqfRA/WEr5p6dJaGi1MlxXTeN86EgMU9FFfFmp+dXR1TLtq+JDrQ6OohLTQjUjtbT/bQHv3kmOuO1xOdlDZYAIYkdmqf5u5i1/jYc4zNZLtBtMbbDD9QYhKvhQRmKe614uDjpzBTlVx0u9IEpGAHHW0CXc77f9UwHhjejkFUFKmm3XF+Yxy8I8kB/eSchjvVIfZxc7Newx1sNVd6SU3VqmivKWR86WR0RWofeDlOPr3NKLM7auWWmTb11nu018=
--------------------------------------------------------------------------------
/doc/draw.io/Tug.Server-mvc-design.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PowerShellOrg/tug/aab51f407b92475ae64cc14a0dea33d459fe9885/doc/draw.io/Tug.Server-mvc-design.png
--------------------------------------------------------------------------------
/doc/draw.io/Tug.Server-mvc-design.xml:
--------------------------------------------------------------------------------
1 | 7ZtRc6soFIB/TR6bQVDUx8Yme3dmu5PZdHbvPhJF49RIh9Amvb9+QTFRsbdprjbpbPrQyhGQc87n4QB2hIL17jdOnlb3LKLZCIJoN0J3IwhdgOVvJXgtBY5ll4KEp1Epsg6CRfqDaiHQ0uc0optGRcFYJtKnpjBkeU5D0ZARztm2WS1mWfOpTyShhmARksyU/pNGYlVKPYgP8m80TVbVky3sl3eWJHxMOHvO9fNGEMXFT3l7Taq+tKKbFYnYtiZC0xEKOGOivFrvApop01ZmK9vN3ri7HzenuTimASwbvJDsWav+8JyMF5S/UK5HKF4rq2xXqaCLJxKq8lY6foQmK7HOZMmSl4XaNNKlvWZAFpKMbDb6OmTrNNTXGVnSbLK3WcAyxuWtnOXyEZM4zbJKpAzpx67qfhKzXMzIOs0UXUHRHQQLkm/kn/uFrqChsqAu1zoCxY+UkyxNcikLpbWkvmgitRapxOBW3xBM6RiRzWqvlyrMiZD180ICQaGt4OyR1p6BMPKRGqw2sOyY7t50krV3vXyjKFtTwV9llaqBo2l5rXDT5e2BTYi1bFXn0tNCot+HZN/3gQl5obHoRgQZiIz/nD4oiwuSR4RHp3MCBuEkItSLw0E5MdyNQ48uY6UBJ1FKG91408lkFvSEAm6igNwOFOwOFOweSLDfIAFnQr0Y6Yu8TNTljJM13TL+WN2TPdduX4H5OTAuJZiCYYCxO2KHBQcCxjkWmIBxemXl3KxA74ysYIOV28VczzQlHhcGgkO9yP5cEDy4RBh3g+C7EXDdgWYZ9ImzjGuAcCOLUk0IbgwIZFO5JlDuOTcOJ8UFq5+40E5b12kUKQtNVoynP2T/pDLDRhoozZMHldcWShaj0fZEhwqVncrShAnB1rpGH4GmPSlBk68uvGAPeHnvxhlw/3dwjTY/jzYYBwEYKEWB/idGG8vMUe4WwXwhRXPOBAtZ1pGvfJMrn0y9JpeZsxiujPASO7hjSR3HMAy7XRzHkV+4f7iI1kcoaa+NnY6cBQ0Fj5m0SHiUdSh/SUN6JecLkQO7st2hyKmGWyMnYHmcJl+QgOG83MHWbBZM/VlPE4/3fuzo2lbrIw3p2Hn9gyVJERmuBJyNAO8TCTA3Vqc7oSyWrMUVgvNB0DURdEHQyzxgZhCG65vnKu+AMKjryzvViZh1FhiOOIzpgQnbbjLh+uaSBPkmE9b+FPJXoPDfh4Lm0a066Dy4rQZBw0a9uYLuUvFdVRoD4Ojyv4qoMYCuLs8pT6W+ylMFadLc/PV7vVC2sACsBO0mpao0Mk5oW76T5mDPPKxq6XWcIDyhVZTG3T6uOdHpeK8rGacZEelLcxhdftVPmLM0FweEEGzNLbgVL8rh61awdkbb6shGbrOjduApdTY6KjDbq33cWR+4aPLA2PfdGnk3Ej3vo+j5PYOHLw882JzPwMng+c2O0HDgmeuhu00ol0RyxsmyX/kWYfB86PhJ8csule3WDp0FzOnQ7wC6HfFO+vzAXChJMv6iT4yL2j5K4zDxQM0X22T5H7DkuGdkyVxyXbPtC8y2YQcTw6XbyPyu5cKSHs9qpNsWxIOn2/V0pnptjsqEzpX12BiPPeg6HoYAeyoQ1olCwBpLoeNYLrQtVC3nPpoROdWmTQWq1xpnjxmReTB1YVT6TSp9Bw2ciX9BJp2xbdeodJpQInd8ANbZw/VxKlv9usNRae5X/S7TseJU65qlX1ZmBfFxmZXTR2ZlfrXT4ML8RJSEgqlnXDP0i+fIOo6j9u7ASZ8YmxtQJkZLXoEy3Yl7kpPkGnoua4NAZvTHhR7nw8jI4uHfY8oZ7PAvSGj6Hw==
--------------------------------------------------------------------------------
/doc/dsc-ecosystem.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | # DSC is composed of...
4 |
5 | * Pre-reqs:
6 | * PowerShell
7 | * WMI/OMI
8 |
9 | * DSC Framework
10 | * Define Resources
11 | * In C# + Folder Structure
12 | * In PS Classes
13 | * Define Node Config Declaratively via DSL
14 | * Configuration Engine
15 | * LCM
16 | * [ZeroDSC](https://github.com/alx9r/ZeroDSC)
17 | * Remote Repository
18 | * SMB
19 | * Pull Server + Pull Client (LCM)
20 | * v1 PS4
21 | * v2 PS5 - xDscWebService
22 | * OSS Pull Server + Pull Client (LCM)
23 | * v2 Tug
24 |
--------------------------------------------------------------------------------
/references/wireshark_traces/Issue 58 Registration with Tug Server.pcapng:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PowerShellOrg/tug/aab51f407b92475ae64cc14a0dea33d459fe9885/references/wireshark_traces/Issue 58 Registration with Tug Server.pcapng
--------------------------------------------------------------------------------
/references/wireshark_traces/sample-registration-configurationrepository.json:
--------------------------------------------------------------------------------
1 | // PUT /Nodes(AgentId='1AD901EB-C7C6-11E6-A94A-12E41D782BFC') HTTP/1.1
2 | // Accept: application/json
3 | // x-ms-date: 2017-02-25T12:46:54.2426419Z
4 | // Authorization: Shared cdV2mBJI1XonvLHrZbUui/Bv7iYEYATjcXVUzqCPN10=
5 | // ProtocolVersion: 2.0
6 | // Content-Type: application/json; charset=utf-8
7 | // Host: 10.50.1.5:5000
8 | // Content-Length: 681
9 | // Expect: 100-continue
10 | // Connection: Keep-Alive
11 |
12 | {
13 | "AgentInformation": {
14 | "LCMVersion": "2.0",
15 | "NodeName": "EC2AMAZ-VT1I874",
16 | "IPAddress": "10.50.1.9;127.0.0.1;fe80::288e:6e98:1555:55e9%6;::2000:0:0:0;::1;::2000:0:0:0"
17 | },
18 | "ConfigurationNames": [
19 | "TestConfig1"
20 | ],
21 | "RegistrationInformation": {
22 | "CertificateInformation": {
23 | "FriendlyName": "DSC-OaaS Client Authentication",
24 | "Issuer": "CN=http://10.50.1.5:5000",
25 | "NotAfter": "2018-02-24T10:42:01.0000000-05:00",
26 | "NotBefore": "2017-02-24T15:32:02.0000000-05:00",
27 | "Subject": "CN=http://10.50.1.5:5000",
28 | "PublicKey": "U3lzdGVtLlNlY3VyaXR5LkNyeXB0b2dyYXBoeS5YNTA5Q2VydGlmaWNhdGVzLlB1YmxpY0tleQ==",
29 | "Thumbprint": "FFB21C9308069E3C4E3267FA3E8DE38E7A5FBE07",
30 | "Version": 3
31 | },
32 | "RegistrationMessageType": "ConfigurationRepository"
33 | }
34 | }
--------------------------------------------------------------------------------
/references/wireshark_traces/sample-registration-reportserver.json:
--------------------------------------------------------------------------------
1 | // PUT /Nodes(AgentId='1AD901EB-C7C6-11E6-A94A-12E41D782BFC') HTTP/1.1
2 | // Accept: application/json
3 | // x-ms-date: 2017-02-25T12:46:54.6086324Z
4 | // Authorization: Shared SuAbnzLkKPIU6wgLmDsGzpRYtr6Isvezr1JyV/YticA=
5 | // ProtocolVersion: 2.0
6 | // Content-Type: application/json; charset=utf-8
7 | // Host: 10.50.1.5:5000
8 | // Content-Length: 633
9 | // Expect: 100-continue
10 |
11 | {
12 | "AgentInformation": {
13 | "LCMVersion": "2.0",
14 | "NodeName": "EC2AMAZ-VT1I874",
15 | "IPAddress": "10.50.1.9;127.0.0.1;fe80::288e:6e98:1555:55e9%6;::2000:0:0:0;::1;::2000:0:0:0"
16 | },
17 | "RegistrationInformation": {
18 | "CertificateInformation": {
19 | "FriendlyName": "DSC-OaaS Client Authentication",
20 | "Issuer": "CN=http://10.50.1.5:5000",
21 | "NotAfter": "2018-02-24T10:42:01.0000000-05:00",
22 | "NotBefore": "2017-02-24T15:32:02.0000000-05:00",
23 | "Subject": "CN=http://10.50.1.5:5000",
24 | "PublicKey": "U3lzdGVtLlNlY3VyaXR5LkNyeXB0b2dyYXBoeS5YNTA5Q2VydGlmaWNhdGVzLlB1YmxpY0tleQ==",
25 | "Thumbprint": "FFB21C9308069E3C4E3267FA3E8DE38E7A5FBE07",
26 | "Version": 3
27 | },
28 | "RegistrationMessageType": "ReportServer"
29 | }
30 | }
--------------------------------------------------------------------------------
/references/wireshark_traces/sample-registration-resourcerepository.json:
--------------------------------------------------------------------------------
1 | // PUT /Nodes(AgentId='1AD901EB-C7C6-11E6-A94A-12E41D782BFC') HTTP/1.1
2 | // Accept: application/json
3 | // x-ms-date: 2017-02-25T12:46:54.4196460Z
4 | // Authorization: Shared 5MPzNanupLYK15FRl1I+zxxh40+yyOmro5PW9GtPLwQ=
5 | // ProtocolVersion: 2.0
6 | // Content-Type: application/json; charset=utf-8
7 | // Host: 10.50.1.5:5000
8 | // Content-Length: 639
9 | // Expect: 100-continue
10 |
11 | {
12 | "AgentInformation": {
13 | "LCMVersion": "2.0",
14 | "NodeName": "EC2AMAZ-VT1I874",
15 | "IPAddress": "10.50.1.9;127.0.0.1;fe80::288e:6e98:1555:55e9%6;::2000:0:0:0;::1;::2000:0:0:0"
16 | },
17 | "RegistrationInformation": {
18 | "CertificateInformation": {
19 | "FriendlyName": "DSC-OaaS Client Authentication",
20 | "Issuer": "CN=http://10.50.1.5:5000",
21 | "NotAfter": "2018-02-24T10:42:01.0000000-05:00",
22 | "NotBefore": "2017-02-24T15:32:02.0000000-05:00",
23 | "Subject": "CN=http://10.50.1.5:5000",
24 | "PublicKey": "U3lzdGVtLlNlY3VyaXR5LkNyeXB0b2dyYXBoeS5YNTA5Q2VydGlmaWNhdGVzLlB1YmxpY0tleQ==",
25 | "Thumbprint": "FFB21C9308069E3C4E3267FA3E8DE38E7A5FBE07",
26 | "Version": 3
27 | },
28 | "RegistrationMessageType": "ResourceRepository"
29 | }
30 | }
--------------------------------------------------------------------------------
/references/wireshark_traces/v2 Initial node registration, config pull, module pull, and reporting.pcapng:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PowerShellOrg/tug/aab51f407b92475ae64cc14a0dea33d459fe9885/references/wireshark_traces/v2 Initial node registration, config pull, module pull, and reporting.pcapng
--------------------------------------------------------------------------------
/references/wireshark_traces/v2 LCM fails when given multiple configuration names on one pull server.pcapng:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PowerShellOrg/tug/aab51f407b92475ae64cc14a0dea33d459fe9885/references/wireshark_traces/v2 LCM fails when given multiple configuration names on one pull server.pcapng
--------------------------------------------------------------------------------
/references/wireshark_traces/v2 node was given new config to pull - it was pulled applied and reported - no module download.pcapng:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PowerShellOrg/tug/aab51f407b92475ae64cc14a0dea33d459fe9885/references/wireshark_traces/v2 node was given new config to pull - it was pulled applied and reported - no module download.pcapng
--------------------------------------------------------------------------------
/references/wireshark_traces/v2 node with partials.pcapng:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PowerShellOrg/tug/aab51f407b92475ae64cc14a0dea33d459fe9885/references/wireshark_traces/v2 node with partials.pcapng
--------------------------------------------------------------------------------
/sample-module/README.md:
--------------------------------------------------------------------------------
1 | This sample module is designed to illustrate how Tug relies on PowerShell commands to perform its functionality. The sample module provides functionality roughly equivalent to Microsoft's native pull server feature as shipped with Windows Server; however, the sample module does not use a database and instead uses text files to persist data. This results in the sample module having very minimal scalability, and it is likely not suitable for production environments. The module must be placed into a legal module path as defined in the PSModulePath environment variable.
--------------------------------------------------------------------------------
/src/Tug.Base/Ext/IProvider.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | using System.Collections.Generic;
6 |
7 | namespace Tug.Ext
8 | {
9 | public interface IProvider
10 | where TProd : IProviderProduct
11 | {
12 | ProviderInfo Describe();
13 |
14 | IEnumerable DescribeParameters();
15 |
16 | void SetParameters(IDictionary productParams);
17 |
18 | TProd Produce();
19 | }
20 | }
--------------------------------------------------------------------------------
/src/Tug.Base/Ext/IProviderManager.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | using System.Collections.Generic;
6 |
7 | namespace Tug.Ext
8 | {
9 | public interface IProviderManager
10 | where TProv : IProvider
11 | where TProd : IProviderProduct
12 | {
13 | IEnumerable FoundProvidersNames
14 | { get; }
15 |
16 | TProv GetProvider(string name);
17 | }
18 | }
--------------------------------------------------------------------------------
/src/Tug.Base/Ext/IProviderProduct.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | using System;
6 |
7 | namespace Tug.Ext
8 | {
9 | // Alternative Names:
10 | // public interface IProviderYield
11 | // public interface IProviderResult
12 | // public interface IProviderOutput
13 | public interface IProviderProduct : IDisposable
14 | {
15 | bool IsDisposed
16 | { get; }
17 | }
18 | }
--------------------------------------------------------------------------------
/src/Tug.Base/Ext/ProviderInfo.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | namespace Tug.Ext
6 | {
7 | public class ProviderInfo
8 | {
9 | public ProviderInfo(string name,
10 | string label = null, string description = null)
11 | {
12 | Name = name;
13 | Label = label;
14 | Description = description;
15 | }
16 |
17 | public string Name
18 | { get; private set; }
19 |
20 | public string Label
21 | { get; private set; }
22 |
23 | public string Description
24 | { get; private set; }
25 | }
26 | }
--------------------------------------------------------------------------------
/src/Tug.Base/Ext/ProviderParameterInfo.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | namespace Tug.Ext
6 | {
7 | public class ProviderParameterInfo
8 | {
9 | public ProviderParameterInfo(string name,
10 | bool isRequired = false,
11 | string label = null,
12 | string description = null)
13 | {
14 | Name = name;
15 |
16 | IsRequired = false;
17 | Label = label;
18 | Description = description;
19 | }
20 |
21 | public string Name
22 | { get; private set; }
23 |
24 | public bool IsRequired
25 | { get; private set; }
26 |
27 | public string Label
28 | { get; private set; }
29 |
30 | public string Description
31 | { get; private set; }
32 | }
33 | }
--------------------------------------------------------------------------------
/src/Tug.Base/Messages/DscResponse.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | using Tug.Messages.ModelBinding;
6 |
7 | namespace Tug.Messages
8 | {
9 | public class DscResponse
10 | {
11 | public const string PROTOCOL_VERSION_HEADER = "ProtocolVersion";
12 | public const string PROTOCOL_VERSION_VALUE = "2.0";
13 |
14 |
15 | [ToHeader(Name = PROTOCOL_VERSION_HEADER)]
16 | public string ProtocolVersionHeader
17 | { get; set; } = PROTOCOL_VERSION_VALUE;
18 | }
19 | }
--------------------------------------------------------------------------------
/src/Tug.Base/Messages/GetConfiguration.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | using System.IO;
6 | using System.Net.Http;
7 | using Microsoft.AspNetCore.Mvc;
8 | using Tug.Messages.ModelBinding;
9 |
10 | namespace Tug.Messages
11 | {
12 | public class GetConfigurationRequest : DscAgentRequest
13 | {
14 | public static readonly HttpMethod VERB = HttpMethod.Get;
15 |
16 | public const string ROUTE = "Nodes(AgentId='{AgentId}')/Configurations(ConfigurationName='{ConfigurationName}')/ConfigurationContent";
17 | public const string ROUTE_NAME = nameof(GetConfigurationRequest);
18 |
19 | [FromRoute]
20 | public string ConfigurationName
21 | { get; set; }
22 |
23 | ///
24 | /// TODO: Resolve how this relates to the same parameter name in the URI.
25 | /// https://msdn.microsoft.com/en-us/library/mt181633.aspx
26 | ///
27 | [FromHeader(Name = "ConfigurationName")]
28 | public string ConfigurationNameHeader
29 | { get; set; }
30 | }
31 |
32 | public class GetConfigurationResponse : DscResponse
33 | {
34 | [ToHeader(Name = "Checksum")]
35 | public string ChecksumHeader
36 | { get; set; }
37 |
38 | [ToHeader(Name = "ChecksumAlgorithm")]
39 | public string ChecksumAlgorithmHeader
40 | { get; set; }
41 |
42 | [ToResult]
43 | public Stream Configuration
44 | { get; set; }
45 | }
46 | }
--------------------------------------------------------------------------------
/src/Tug.Base/Messages/GetDscAction.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | using System.ComponentModel.DataAnnotations;
6 | using System.Net.Http;
7 | using Microsoft.AspNetCore.Mvc;
8 | using Tug.Messages.ModelBinding;
9 | using Tug.Model;
10 |
11 | namespace Tug.Messages
12 | {
13 | public class GetDscActionRequest : DscAgentRequest
14 | {
15 | public static readonly HttpMethod VERB = HttpMethod.Post;
16 |
17 | public const string ROUTE = "Nodes(AgentId='{AgentId}')/GetDscAction";
18 | public const string ROUTE_NAME = nameof(GetDscActionRequest);
19 |
20 | [FromBody]
21 | [Required]
22 | public GetDscActionRequestBody Body
23 | { get; set; }
24 |
25 | public override object GetBody() => Body;
26 | }
27 |
28 | public class GetDscActionResponse : DscResponse
29 | {
30 | [ToResult]
31 | public GetDscActionResponseBody Body
32 | { get; set; }
33 | }
34 | }
--------------------------------------------------------------------------------
/src/Tug.Base/Messages/GetModule.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | using System;
6 | using System.ComponentModel.DataAnnotations;
7 | using System.IO;
8 | using System.Net.Http;
9 | using Microsoft.AspNetCore.Mvc;
10 | using Tug.Messages.ModelBinding;
11 |
12 | namespace Tug.Messages
13 | {
14 | public class GetModuleRequest : DscRequest
15 | {
16 | public static readonly HttpMethod VERB = HttpMethod.Get;
17 |
18 | public const string ROUTE = "Modules(ModuleName='{ModuleName}',ModuleVersion='{ModuleVersion}')/ModuleContent";
19 | public const string ROUTE_NAME = nameof(GetModuleRequest);
20 |
21 | // Apparently this *has* to be a string when binding it from a
22 | // header field otherwise, it just gets skipped over for some
23 | // reason -- not sure if this is a bug in MVC model binding???
24 | [FromHeader(Name = "AgentId")]
25 | [Required]
26 | public string AgentId
27 | { get; set; }
28 |
29 | [FromRoute]
30 | [Required]
31 | public string ModuleName
32 | { get; set; }
33 |
34 | [FromRoute]
35 | [Required]
36 | public string ModuleVersion
37 | { get; set; }
38 |
39 | public override Guid? GetAgentId()
40 | {
41 | Guid agentId;
42 | if (Guid.TryParse(AgentId, out agentId))
43 | return agentId;
44 | else
45 | return null;
46 | }
47 | }
48 |
49 | public class GetModuleResponse : DscResponse
50 | {
51 | [ToHeaderAttribute(Name = "Checksum")]
52 | public string ChecksumHeader
53 | { get; set; }
54 |
55 | [ToHeader(Name = "ChecksumAlgorithm")]
56 | public string ChecksumAlgorithmHeader
57 | { get; set; }
58 |
59 | [ToResult]
60 | public Stream Module
61 | { get; set; }
62 | }
63 | }
--------------------------------------------------------------------------------
/src/Tug.Base/Messages/GetReports.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | using System;
6 | using System.Net.Http;
7 | using Microsoft.AspNetCore.Mvc;
8 | using Tug.Messages.ModelBinding;
9 | using Tug.Model;
10 |
11 | namespace Tug.Messages
12 | {
13 | public class GetReportsRequest : DscAgentRequest
14 | {
15 | public static readonly HttpMethod VERB = HttpMethod.Get;
16 |
17 | public const string ROUTE_SINGLE = "Nodes(AgentId='{AgentId}')/Reports(JobId='{JobId}')";
18 | public const string ROUTE_SINGLE_NAME = nameof(GetReportsRequest) + "Single";
19 |
20 | public const string ROUTE_ALL = "Nodes(AgentId='{AgentId}')/Reports()";
21 | public const string ROUTE_ALL_NAME = nameof(GetReportsRequest) + "All";
22 |
23 | public const string ROUTE_ALL_ALT = "Nodes(AgentId='{AgentId}')/Reports";
24 | public const string ROUTE_ALL_ALT_NAME = nameof(GetReportsRequest) + "AllAlt";
25 |
26 |
27 | [FromRoute]
28 | public Guid? JobId
29 | { get; set; }
30 | }
31 |
32 | public class GetReportsSingleResponse : DscResponse
33 | {
34 | [ToResult]
35 | public SendReportBody Body
36 | { get; set; }
37 | }
38 |
39 | public class GetReportsAllResponse : DscResponse
40 | {
41 | [ToResult]
42 | public GetReportsAllResponseBody Body
43 | { get; set; }
44 | }
45 | }
--------------------------------------------------------------------------------
/src/Tug.Base/Messages/RegisterDscAgent.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | using System.ComponentModel.DataAnnotations;
6 | using System.Net.Http;
7 | using Microsoft.AspNetCore.Mvc;
8 | using Tug.Messages.ModelBinding;
9 | using Tug.Model;
10 |
11 | namespace Tug.Messages
12 | {
13 | public class RegisterDscAgentRequest : DscAgentRequest
14 | {
15 | public static readonly HttpMethod VERB = HttpMethod.Put;
16 |
17 | public const string ROUTE = "Nodes(AgentId='{AgentId}')";
18 | public const string ROUTE_NAME = nameof(RegisterDscAgentRequest);
19 |
20 | [FromBody]
21 | [Required]
22 | public RegisterDscAgentRequestBody Body
23 | { get; set; }
24 |
25 | public override object GetBody() => Body;
26 | }
27 |
28 | public class RegisterDscAgentResponse : DscResponse
29 | {
30 | ///
31 | /// We only need a single instance since there are
32 | /// no mutable elements in the object graph.
33 | ///
34 | public static readonly RegisterDscAgentResponse INSTANCE =
35 | new RegisterDscAgentResponse();
36 |
37 | [ToResult]
38 | public NoContentResult Body
39 | { get; } = new NoContentResult();
40 | }
41 | }
--------------------------------------------------------------------------------
/src/Tug.Base/Messages/SendReport.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | using System.ComponentModel.DataAnnotations;
6 | using System.Net.Http;
7 | using Microsoft.AspNetCore.Mvc;
8 | using Tug.Model;
9 |
10 | namespace Tug.Messages
11 | {
12 | public class SendReportRequest : DscAgentRequest
13 | {
14 | public static readonly HttpMethod VERB = HttpMethod.Post;
15 |
16 | public const string ROUTE = "Nodes(AgentId='{AgentId}')/SendReport";
17 | public const string ROUTE_NAME = nameof(SendReportRequest);
18 |
19 | [FromBody]
20 | [Required(AllowEmptyStrings = true)]
21 | public SendReportBody Body
22 | { get; set; }
23 |
24 | public override bool HasStrictBody() => false;
25 |
26 | public override object GetBody() => Body;
27 | }
28 | }
--------------------------------------------------------------------------------
/src/Tug.Base/Model/ActionDetailsItem.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | using System.ComponentModel.DataAnnotations;
6 |
7 | namespace Tug.Model
8 | {
9 | public class ActionDetailsItem : Util.ExtDataIndexerBase
10 | {
11 | [Required(AllowEmptyStrings = true)]
12 | public string ConfigurationName
13 | { get; set; } = string.Empty;
14 |
15 | [Required]
16 | [EnumDataTypeAttribute(typeof(DscActionStatus))]
17 | public DscActionStatus Status
18 | { get; set; }
19 | }
20 | }
--------------------------------------------------------------------------------
/src/Tug.Base/Model/AgentInformation.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | using System.ComponentModel.DataAnnotations;
6 |
7 | namespace Tug.Model
8 | {
9 | public class AgentInformation : Util.ExtDataIndexerBase
10 | {
11 | // NOTE: DO NOT CHANGE THE ORDER OF THESE PROPERTIES!!!
12 | // Apparently the order of these properties is important
13 | // to successfully fulfill the RegKey authz requirements
14 |
15 | [Required]
16 | public string LCMVersion
17 | { get; set; }
18 |
19 | [Required]
20 | public string NodeName
21 | { get; set; }
22 |
23 | [Required(AllowEmptyStrings = true)]
24 | public string IPAddress
25 | { get; set; }
26 | }
27 | }
--------------------------------------------------------------------------------
/src/Tug.Base/Model/CertificateInformation.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | using System.ComponentModel.DataAnnotations;
6 |
7 | namespace Tug.Model
8 | {
9 | public class CertificateInformation : Util.ExtDataIndexerBase
10 | {
11 | public CertificateInformation()
12 | { }
13 |
14 | public CertificateInformation(CertificateInformation copyFrom)
15 | {
16 | this.FriendlyName = copyFrom.FriendlyName;
17 | this.Issuer = copyFrom.Issuer;
18 | this.NotAfter = copyFrom.NotAfter;
19 | this.NotBefore = copyFrom.NotBefore;
20 | this.Subject = copyFrom.Subject;
21 | this.PublicKey = copyFrom.PublicKey;
22 | this.Thumbprint = copyFrom.Thumbprint;
23 | }
24 |
25 | // NOTE: DO NOT CHANGE THE ORDER OF THESE PROPERTIES!!!
26 | // Apparently the order of these properties is important
27 | // to successfully fulfill the RegKey authz requirements
28 |
29 | [Required]
30 | public string FriendlyName
31 | { get; set; }
32 |
33 | [Required]
34 | public string Issuer
35 | { get; set; }
36 |
37 | [Required]
38 | public string NotAfter
39 | { get; set; }
40 |
41 | [Required]
42 | public string NotBefore
43 | { get; set; }
44 |
45 | [Required]
46 | public string Subject
47 | { get; set; }
48 |
49 | [Required]
50 | public string PublicKey
51 | { get; set; }
52 |
53 | [Required]
54 | public string Thumbprint
55 | { get; set; }
56 |
57 | // This *MUST* be an int or RegisterDscAction will fail with a
58 | // 401 Unauthorized error and eroneously report an invalid
59 | // Registration Key -- as HOURS of debugging has proven!
60 | [Required]
61 | public int Version
62 | { get; set; }
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/src/Tug.Base/Model/ClientStatusItem.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | using System.ComponentModel.DataAnnotations;
6 | using Newtonsoft.Json;
7 |
8 | namespace Tug.Model
9 | {
10 | public class ClientStatusItem : Util.ExtDataIndexerBase
11 | {
12 | // NOTE: DO NOT CHANGE THE ORDER OF THESE PROPERTIES!!!
13 | // Apparently the order of these properties is important
14 | // to successfully satisfy the strict input validation
15 |
16 | // Based on testing and observation, this property
17 | // is completely omitted when it has no value
18 | [JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
19 | public string ConfigurationName
20 | { get; set; }
21 |
22 | [Required(AllowEmptyStrings = true)]
23 | public string Checksum
24 | { get; set; }
25 |
26 | [Required]
27 | [CustomValidation(typeof(ClientStatusItem),
28 | nameof(ValidateChecksumAlgorithm))]
29 | public string ChecksumAlgorithm
30 | { get; set; }
31 |
32 | public static ValidationResult ValidateChecksumAlgorithm(string value)
33 | {
34 | return "SHA-256" == value
35 | ? ValidationResult.Success
36 | : new ValidationResult("unsupported or unknown checksum algorithm");
37 | }
38 | }
39 | }
--------------------------------------------------------------------------------
/src/Tug.Base/Model/GetDscActionRequestBody.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | using System.ComponentModel.DataAnnotations;
6 |
7 | namespace Tug.Model
8 | {
9 | public class GetDscActionRequestBody : Util.ExtDataIndexerBase
10 | {
11 | [Required]
12 | [MinLengthAttribute(1)]
13 | public ClientStatusItem[] ClientStatus
14 | { get; set; }
15 | }
16 | }
--------------------------------------------------------------------------------
/src/Tug.Base/Model/GetDscActionResponseBody.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | using System.ComponentModel.DataAnnotations;
6 |
7 | namespace Tug.Model
8 | {
9 | public class GetDscActionResponseBody : Util.ExtDataIndexerBase
10 | {
11 | [Required]
12 | [EnumDataTypeAttribute(typeof(DscActionStatus))]
13 | public DscActionStatus NodeStatus
14 | { get; set; }
15 |
16 | public ActionDetailsItem[] Details
17 | { get; set; }
18 | }
19 | }
--------------------------------------------------------------------------------
/src/Tug.Base/Model/GetReportsResponseBody.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | using System.Collections.Generic;
6 | using Newtonsoft.Json;
7 |
8 | namespace Tug.Model
9 | {
10 | public class GetReportsAllResponseBody : Util.ExtDataIndexerBase
11 | {
12 | [JsonProperty(PropertyName = "value")]
13 | public IEnumerable Value
14 | { get; set; }
15 | }
16 | }
--------------------------------------------------------------------------------
/src/Tug.Base/Model/RegisterDscAgentRequestBody.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | using System.ComponentModel.DataAnnotations;
6 | using Newtonsoft.Json;
7 |
8 | namespace Tug.Model
9 | {
10 | ///
11 | /// https://msdn.microsoft.com/en-us/library/dn365245.aspx
12 | ///
13 | public class RegisterDscAgentRequestBody : Util.ExtDataIndexerBase
14 | {
15 | // NOTE: DO NOT CHANGE THE ORDER OF THESE PROPERTIES!!!
16 | // Apparently the order of these properties is important
17 | // to successfully fulfill the RegKey authz requirements
18 |
19 | [Required]
20 | public AgentInformation AgentInformation
21 | { get; set; }
22 |
23 | // Based on testing and observation, this property
24 | // is completely omitted when it has no value
25 | [JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
26 | public string[] ConfigurationNames
27 | { get; set; }
28 |
29 | [Required]
30 | public RegistrationInformation RegistrationInformation
31 | { get; set; }
32 | }
33 | }
--------------------------------------------------------------------------------
/src/Tug.Base/Model/RegistrationInformation.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | using System.ComponentModel.DataAnnotations;
6 |
7 | namespace Tug.Model
8 | {
9 | public class RegistrationInformation : Util.ExtDataIndexerBase
10 | {
11 | // NOTE: DO NOT CHANGE THE ORDER OF THESE PROPERTIES!!!
12 | // Apparently the order of these properties is important
13 | // to successfully fulfill the RegKey authz requirements
14 |
15 | [Required]
16 | public CertificateInformation CertificateInformation
17 | { get; set; }
18 |
19 | [Required]
20 | public string RegistrationMessageType
21 | { get; set; }
22 | }
23 | }
--------------------------------------------------------------------------------
/src/Tug.Base/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 |
3 | // General Information about an assembly is controlled through the following
4 | // set of attributes. Change these attribute values to modify the information
5 | // associated with an assembly.
6 | [assembly: AssemblyTitle("Tug Server Base")]
7 | [assembly: AssemblyDescription("Tug Common Abstractions & Components")]
8 | [assembly: AssemblyConfiguration("")]
9 | [assembly: AssemblyCulture("")]
10 |
11 | /////////////////////////////////////////////////////////////////
12 | // Additional "shared" assembly-level attributes are defined in
13 | // SharedAssemblyInfo.cs and SharedAssemblyVersionInfo.cs files
14 | /////////////////////////////////////////////////////////////////
15 |
--------------------------------------------------------------------------------
/src/Tug.Base/Util/ExceptionExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Tug.Util
4 | {
5 | public static class ExceptionExtensions
6 | {
7 | public static T WithData(this T exception, object key, object value)
8 | where T : Exception
9 | {
10 | exception.Data.Add(key, value);
11 | return exception;
12 | }
13 | }
14 | }
--------------------------------------------------------------------------------
/src/Tug.Base/Util/ExtDataBase.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | using System.Collections.Generic;
6 | using Newtonsoft.Json;
7 | using Newtonsoft.Json.Linq;
8 |
9 | namespace Tug.Util
10 | {
11 | public class ExtDataBase : IExtData
12 | {
13 | [JsonExtensionData]
14 | protected IDictionary _extData = new Dictionary();
15 |
16 | IDictionary IExtData.GetExtData()
17 | {
18 | return _extData;
19 | }
20 | }
21 | }
--------------------------------------------------------------------------------
/src/Tug.Base/Util/ExtDataExtensions.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | using System.Collections.Generic;
6 | using Newtonsoft.Json.Linq;
7 |
8 | namespace Tug.Util
9 | {
10 | public static class ExtDataExtensions
11 | {
12 | public static int GetExtDataCount(this IExtData extData)
13 | {
14 | return extData.GetExtData().Count;
15 | }
16 |
17 | public static IEnumerable GetExtDataKeys(this IExtData extData)
18 | {
19 | return extData.GetExtData().Keys;
20 | }
21 |
22 | public static bool ContainsExtData(this IExtData extData, string key)
23 | {
24 | return extData.GetExtData().ContainsKey(key);
25 | }
26 |
27 | public static object GetExtData(this IExtData extData, string key, object ifNotFound = null)
28 | {
29 | return extData.GetExtData().ContainsKey(key)
30 | ? extData.GetExtData()[key]
31 | : ifNotFound;
32 | }
33 |
34 | public static void SetExtData(this IExtData extData, string key, object value)
35 | {
36 | extData.GetExtData()[key] = JToken.FromObject(value);
37 | }
38 |
39 | public static void RemoveExtData(this IExtData extData, string key)
40 | {
41 | extData.GetExtData().Remove(key);
42 | }
43 | }
44 | }
--------------------------------------------------------------------------------
/src/Tug.Base/Util/ExtDataIndexerBase.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | namespace Tug.Util
6 | {
7 | public class ExtDataIndexerBase : ExtDataBase
8 | {
9 | public object this[string key]
10 | {
11 | get { return ((IExtData)this).GetExtData(key); }
12 | set { ((IExtData)this).SetExtData(key, value); }
13 | }
14 | }
15 | }
--------------------------------------------------------------------------------
/src/Tug.Base/Util/IExtData.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | using System.Collections.Generic;
6 | using Newtonsoft.Json.Linq;
7 |
8 | namespace Tug.Util
9 | {
10 | public interface IExtData
11 | {
12 | IDictionary GetExtData();
13 | }
14 | }
--------------------------------------------------------------------------------
/src/Tug.Client/AppLog.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | using System;
6 | using Microsoft.Extensions.Logging;
7 |
8 | namespace Tug.Client
9 | {
10 | ///
11 | /// Implements a static access pattern for ILoggerFactory.
12 | ///
13 | ///
14 | /// This pattern is based on this static ApplicationLogging class approach.
17 | /// This allows us to introduce logging to static classes (such as Extension
18 | /// Method classes) that cannot participate in dependency-injected services.
19 | ///
20 | public static class AppLog
21 | {
22 | private static LoggerFactory _preLoggerFactory;
23 |
24 | static AppLog()
25 | {
26 | // We set this up to log any events that take place before the
27 | // ultimate logging configuration is finalized and realized
28 | _preLoggerFactory = new LoggerFactory();
29 | // Here we configure the hard-coded settings of the pre-logger with
30 | // anything we want before the runtime logging config is resolved
31 | _preLoggerFactory.AddConsole();
32 |
33 | // This will be the final runtime logger factory
34 | Factory = new LoggerFactory();
35 | }
36 |
37 | public static ILogger CreatePreLogger()
38 | {
39 | return _preLoggerFactory.CreateLogger();
40 | }
41 |
42 | public static ILoggerFactory Factory
43 | { get; }
44 |
45 | public static ILogger Create(Type t)
46 | {
47 | return Factory.CreateLogger(t);
48 | }
49 |
50 | public static ILogger Create()
51 | {
52 | return Factory.CreateLogger();
53 | }
54 | }
55 | }
--------------------------------------------------------------------------------
/src/Tug.Client/FileResponse.cs:
--------------------------------------------------------------------------------
1 | namespace Tug.Client
2 | {
3 | // TODO: maybe we should make this a disposable and the
4 | // Content should be a stream (that would be cleaned up)
5 | // and we could provide convenience methods to get bytes,
6 | // etc. -- SOMETHING TO CONSIDER...
7 |
8 | public class FileResponse
9 | {
10 | public string ChecksumAlgorithm
11 | { get; set; }
12 |
13 | public string Checksum
14 | { get; set; }
15 |
16 | public byte[] Content
17 | { get; set; }
18 | }
19 | }
--------------------------------------------------------------------------------
/src/Tug.Client/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 |
3 | // General Information about an assembly is controlled through the following
4 | // set of attributes. Change these attribute values to modify the information
5 | // associated with an assembly.
6 | [assembly: AssemblyTitle("Tug Client")]
7 | [assembly: AssemblyDescription("DSC Pull Mode client compatible with Class DSC Pull Server")]
8 | [assembly: AssemblyConfiguration("")]
9 | [assembly: AssemblyCulture("")]
10 |
11 | /////////////////////////////////////////////////////////////////
12 | // Additional "shared" assembly-level attributes are defined in
13 | // SharedAssemblyInfo.cs and SharedAssemblyVersionInfo.cs files
14 | /////////////////////////////////////////////////////////////////
15 |
--------------------------------------------------------------------------------
/src/Tug.Ext-WORK/Ext.1/ExtInfo.cs:
--------------------------------------------------------------------------------
1 | namespace Tug.Ext
2 | {
3 | public class ExtInfo
4 | {
5 | public ExtInfo(string name,
6 | string label = null, string description = null)
7 | {
8 | Name = name;
9 | Label = label;
10 | Description = description;
11 | }
12 |
13 | public string Name
14 | { get; set; }
15 |
16 | public string Label
17 | { get; set; }
18 |
19 | public string Description
20 | { get; set; }
21 | }
22 | }
--------------------------------------------------------------------------------
/src/Tug.Ext-WORK/Ext.1/IExtManager.1.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace Tug.Ext
4 | {
5 | public interface IExtManagerX
6 | where TE : IExtension
7 | where TEP: IExtProviderX
8 | {
9 | IEnumerable FoundProviders
10 | { get; }
11 |
12 | TEP GetProvider(string name);
13 | }
14 | }
--------------------------------------------------------------------------------
/src/Tug.Ext-WORK/Ext.1/IExtProvider.1.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace Tug.Ext
4 | {
5 | public interface IExtProviderX
6 | where TE: IExtension
7 | {
8 | ExtInfo Describe();
9 |
10 | IEnumerable DescribeParameters();
11 |
12 | TE Provide(IDictionary initParams);
13 | }
14 | }
--------------------------------------------------------------------------------
/src/Tug.Ext-WORK/Ext/ExtensionAttribute.cs:
--------------------------------------------------------------------------------
1 | namespace Tug.Ext
2 | {
3 | ///
4 | /// Derivative attributes are used to decorate
5 | /// extension
6 | /// implementations and provide meta data, such as unique name or description.
7 | ///
8 | [System.AttributeUsage(System.AttributeTargets.Class,
9 | Inherited = false, AllowMultiple = false)]
10 | public abstract class ExtensionAttribute : System.Attribute
11 | {
12 | ///
13 | /// Returns the name of the target class implementing an associated extension.
14 | ///
15 | protected abstract string Name
16 | { get; }
17 | }
18 | }
--------------------------------------------------------------------------------
/src/Tug.Ext-WORK/Ext/IExtManager.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace Tug.Ext
4 | {
5 | public interface IExtManager
6 | where TExt : IExtension
7 | where TAtt : ExtensionAttribute
8 | {
9 | IEnumerable FoundExtensionNames
10 | { get; }
11 |
12 | TExt GetExtension(string name);
13 | }
14 | }
--------------------------------------------------------------------------------
/src/Tug.Ext-WORK/Ext/IExtension.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Tug.Ext
4 | {
5 | ///
6 | /// Tagging interface to represnet an extension component.
7 | ///
8 | public interface IExtension
9 | { }
10 | }
--------------------------------------------------------------------------------
/src/Tug.Ext-WORK/Ext/Provider/ExtParameterInfo.cs:
--------------------------------------------------------------------------------
1 | namespace Tug.Ext
2 | {
3 | public class ExtParameterInfo
4 | {
5 | public ExtParameterInfo(string name,
6 | bool isRequired = false,
7 | string label = null,
8 | string description = null)
9 | {
10 | Name = name;
11 |
12 | IsRequired = false;
13 | Label = label;
14 | Description = description;
15 | }
16 |
17 | public string Name
18 | { get; private set; }
19 |
20 | public bool IsRequired
21 | { get; private set; }
22 |
23 | public string Label
24 | { get; private set; }
25 |
26 | public string Description
27 | { get; private set; }
28 | }
29 | }
--------------------------------------------------------------------------------
/src/Tug.Ext-WORK/Ext/Provider/IProviderExtension.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace Tug.Ext.Provider
5 | {
6 | public interface IProviderExtension : IExtension
7 | where TProd : IProviderProduct
8 | {
9 | IEnumerable DescribeParameters();
10 |
11 | void SetParameters(IDictionary productParams);
12 |
13 | TProd Produce();
14 | }
15 | }
--------------------------------------------------------------------------------
/src/Tug.Ext-WORK/Ext/Provider/IProviderProduct.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Tug.Ext.Provider
4 | {
5 | // Alternative Names:
6 | // public interface IProviderYield
7 | // public interface IProviderResult
8 | // public interface IProviderOutput
9 | public interface IProviderProduct : IDisposable
10 | {
11 | bool IsDisposed
12 | { get; }
13 | }
14 | }
--------------------------------------------------------------------------------
/src/Tug.Ext-WORK/Tug.Ext-WORK.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Copyright (c) The DevOps Collective, Inc. All rights reserved. Licensed under the MIT license.
5 | Tug Client
6 | en-US
7 | 0.5.1
8 | netcoreapp1.1;net462
9 | portable
10 | true
11 | Tug.Ext
12 | Exe
13 | Tug.Ext-WORK
14 | $(PackageTargetFallback);dnxcore50;portable-net45+win8
15 | 1.0.4
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/src/Tug.Server.Base/ActionStatus.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | using System.Collections.Generic;
6 | using Tug.Model;
7 |
8 | namespace Tug.Server
9 | {
10 | public class ActionStatus
11 | {
12 | public DscActionStatus NodeStatus
13 | { get; set; }
14 |
15 | public IEnumerable ConfigurationStatuses
16 | { get; set; }
17 | }
18 | }
--------------------------------------------------------------------------------
/src/Tug.Server.Base/Configuration/AppSettings.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | namespace Tug.Server.Configuration
6 | {
7 | public class AppSettings
8 | {
9 | public ChecksumSettings Checksum
10 | { get; set; }
11 |
12 | public AuthzSettings Authz
13 | { get; set; }
14 |
15 | public HandlerSettings Handler
16 | { get; set; }
17 | }
18 | }
--------------------------------------------------------------------------------
/src/Tug.Server.Base/Configuration/AuthzSettings.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | using System.Collections.Generic;
6 |
7 | namespace Tug.Server.Configuration
8 | {
9 | public class AuthzSettings
10 | {
11 | // TODO: Need to think about the extensibility model for
12 | // authorization, if we want to use the Provider mechanism
13 |
14 | // public ExtSettings Ext
15 | // { get; set; }
16 |
17 | // [Required]
18 | // public string Provider
19 | // { get; set; }
20 |
21 | // This has to be concrete class, not interface to
22 | // be able to construct during deserialization
23 | public Dictionary Params
24 | { get; set; }
25 | }
26 | }
--------------------------------------------------------------------------------
/src/Tug.Server.Base/Configuration/ChecksumSettings.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | namespace Tug.Server.Configuration
6 | {
7 | public class ChecksumSettings
8 | {
9 | public ExtSettings Ext
10 | { get; set; }
11 |
12 | public string Default
13 | { get; set; } = "SHA-256";
14 | }
15 | }
--------------------------------------------------------------------------------
/src/Tug.Server.Base/Configuration/ExtSettings.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | namespace Tug.Server.Configuration
6 | {
7 | public class ExtSettings
8 | {
9 | public bool ReplaceExtAssemblies
10 | { get; set; }
11 |
12 | public string[] SearchAssemblies
13 | { get; set; }
14 |
15 | public bool ReplaceExtPaths
16 | { get; set; }
17 |
18 | public string[] SearchPaths
19 | { get; set; }
20 | }
21 | }
--------------------------------------------------------------------------------
/src/Tug.Server.Base/Configuration/HandlerSettings.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | using System.Collections.Generic;
6 | using System.ComponentModel.DataAnnotations;
7 |
8 | namespace Tug.Server.Configuration
9 | {
10 | public class HandlerSettings
11 | {
12 | public ExtSettings Ext
13 | { get; set; }
14 |
15 | [Required]
16 | public string Provider
17 | { get; set; } = "basic";
18 |
19 | // This has to be concrete class, not interface to
20 | // be able to construct during deserialization
21 | public Dictionary Params
22 | { get; set; }
23 | }
24 | }
--------------------------------------------------------------------------------
/src/Tug.Server.Base/Configuration/LogSettings.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | using System;
6 |
7 | namespace Tug.Server.Configuration
8 | {
9 | public class LogSettings
10 | {
11 | public LogType LogType
12 | { get; set; }
13 |
14 | public bool DebugLog
15 | { get; set; }
16 | }
17 |
18 | [Flags]
19 | public enum LogType
20 | {
21 | None = 0x0,
22 |
23 | Console = 0x1,
24 |
25 | NLog = 0x2,
26 |
27 | All = Console | NLog,
28 | }
29 | }
--------------------------------------------------------------------------------
/src/Tug.Server.Base/DscHandlerConfig.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | using System.Collections.Generic;
6 |
7 | namespace Tug.Server
8 | {
9 | public class DscHandlerConfig
10 | {
11 | public IDictionary InitParams
12 | { get; set; }
13 | }
14 | }
--------------------------------------------------------------------------------
/src/Tug.Server.Base/FileContent.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | using System.IO;
6 |
7 | namespace Tug.Server
8 | {
9 | public class FileContent
10 | {
11 | public string ChecksumAlgorithm
12 | { get; set; }
13 |
14 | public string Checksum
15 | { get; set; }
16 |
17 | public Stream Content
18 | { get; set; }
19 | }
20 | }
--------------------------------------------------------------------------------
/src/Tug.Server.Base/IChecksumAlgorithm.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | using System.IO;
6 | using Tug.Ext;
7 |
8 | namespace Tug
9 | {
10 | public interface IChecksumAlgorithm : IProviderProduct
11 | {
12 | string AlgorithmName
13 | { get; }
14 |
15 | string ComputeChecksum(byte[] bytes);
16 |
17 | string ComputeChecksum(Stream stream);
18 | }
19 | }
--------------------------------------------------------------------------------
/src/Tug.Server.Base/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 |
3 | // General Information about an assembly is controlled through the following
4 | // set of attributes. Change these attribute values to modify the information
5 | // associated with an assembly.
6 | [assembly: AssemblyTitle("Tug Server Base")]
7 | [assembly: AssemblyDescription("Tug Server Abstractions")]
8 | [assembly: AssemblyConfiguration("")]
9 | [assembly: AssemblyCulture("")]
10 |
11 | /////////////////////////////////////////////////////////////////
12 | // Additional "shared" assembly-level attributes are defined in
13 | // SharedAssemblyInfo.cs and SharedAssemblyVersionInfo.cs files
14 | /////////////////////////////////////////////////////////////////
15 |
--------------------------------------------------------------------------------
/src/Tug.Server.FaaS.AwsLambda/Configuration/AppSettings.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | namespace Tug.Server.FaaS.AwsLambda.Configuration
6 | {
7 | ///
8 | /// Defines configuration settings that drive the operational
9 | /// runtime behavior of the system.
10 | ///
11 | ///
12 | /// App Settings subclass from Host Settings and so they will
13 | /// include a superset of configuration sources that also include
14 | /// all the original bootstrap settings used to resolve the
15 | /// runtime configuration in case those are needed for reference.
16 | ///
17 | public class AppSettings : HostSettings
18 | {
19 | ///
20 | /// Default prefix used to identify environment variables
21 | /// that can override server runtime app configuration.
22 | ///
23 | public new const string ConfigEnvPrefix = "TUG_CFG_";
24 |
25 | public PullServiceSettings PullService
26 | { get; set; }
27 | }
28 | }
--------------------------------------------------------------------------------
/src/Tug.Server.FaaS.AwsLambda/Configuration/HostSettings.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | namespace Tug.Server.FaaS.AwsLambda.Configuration
6 | {
7 | ///
8 | /// Defines a minimal set of bootstrap settings that are loaded initially
9 | /// and define subsequent loading and resolution of runtime app settings.
10 | ///
11 | ///
12 | /// In the Lambda environment the primary means of specifying configuration
13 | /// settings is through the use of environment variables but there are various limitations to this
16 | /// approach including maximum size of config data and naming conventions,
17 | /// and the mapping from a possibly complex and nested config structure to
18 | /// a set of flat key-value pairs, can be error-prone and cumbersome.
19 | ///
20 | /// Instead we define an initial set of host settings that are used to
21 | /// bootstrap the environment and define where and how to pull the actual
22 | /// runtime application settings.
23 | ///
24 | public class HostSettings
25 | {
26 | ///
27 | /// Default prefix used to identify environment variables
28 | /// that can override server startup bootstrap configuration.
29 | ///
30 | public const string ConfigEnvPrefix = "TUG_HOST_";
31 |
32 | public const string AppSettingsLocalJsonFile = "/tmp/appsettings.json";
33 |
34 | public string AppSettingsS3Bucket
35 | { get; set; }
36 |
37 | public string AppSettingsS3Key
38 | { get; set; }
39 | }
40 | }
--------------------------------------------------------------------------------
/src/Tug.Server.FaaS.AwsLambda/Configuration/PullServiceSettings.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | namespace Tug.Server.FaaS.AwsLambda.Configuration
6 | {
7 | public class PullServiceSettings
8 | {
9 | public const string DisabledSettingValue = "#OFF";
10 |
11 | public const int DefaultAuthzRegKeysRefreshMins = 15;
12 |
13 | public string S3Bucket
14 | { get; set; } //= "dsc-faas-work";
15 | public string S3KeyAuthzRegKeys
16 | { get; set; } //= "dsc-service/authz-reg-keys
17 | public string S3KeyPrefixAuthzRegistrations
18 | { get; set; } //= "dsc-service/authz
19 | public string S3KeyPrefixRegistrations
20 | { get; set; } //= "dsc-service/registrations";
21 | public string S3KeyPrefixConfigurations
22 | { get; set; } //= "dsc-service/configurations";
23 | public string S3KeyPrefixModules
24 | { get; set; } //= "dsc-service/modules";
25 |
26 | public int AuthzRegKeysRefreshMins
27 | { get; set; } = DefaultAuthzRegKeysRefreshMins;
28 | }
29 | }
--------------------------------------------------------------------------------
/src/Tug.Server.FaaS.AwsLambda/sample-appsettings.json:
--------------------------------------------------------------------------------
1 | {
2 | // Configure AWS Lambda Logger
3 | "Lambda.Logging": {
4 | "IncludeLogLevel": true,
5 | "IncludeCategory": true,
6 | "IncludeNewline": true,
7 | "LogLevel": {
8 | "Default": "Debug",
9 | "Microsoft": "Information"
10 | }
11 | },
12 |
13 | // Configure the Tug DSC Service
14 | "pullService": {
15 | // Where to store various DSC assets
16 | "S3BucketName": "dsc-faas-work",
17 | "S3KeyPrefixAuthzRegistrations": "dsc-service/authz",
18 | "S3KeyPrefixRegistrations": "dsc-service/registrations",
19 | "S3KeyPrefixConfigurations": "dsc-service/configurations",
20 | "S3KeyPrefixModules": "dsc-service/modules",
21 |
22 | // Where to find Authz Reg Keys and how frequently to
23 | // refresh from the S3 source (-1 to disable refresh)
24 | "S3KeyAuthzRegKeys": "dsc-service/authz-reg-keys",
25 | "AuthzRegKeysRefreshMins": 15
26 | }
27 | }
--------------------------------------------------------------------------------
/src/Tug.Server.FaaS.AwsLambda/sample-aws-lambda-tools-defaults.json:
--------------------------------------------------------------------------------
1 | {
2 | "Information": [
3 | "This file provides default values for the deployment wizard inside Visual Studio and the AWS Lambda commands added to the .NET Core CLI.",
4 | "To learn more about the Lambda commands with the .NET Core CLI execute the following command at the command line in the project root directory.",
5 | "dotnet lambda help",
6 | "All the command line options for the Lambda command can be specified in this file."
7 | ],
8 |
9 | // Specify the name of an AWS Credentials Profile that
10 | // will give you privileges to deploy Lambda function
11 | "profile": "tug-deploy@tug-aws",
12 |
13 | // Specify the AWS region where Lambda function will be deployed
14 | "region": "us-east-1",
15 |
16 | // Give the CloudFormation (CFN) stack a name
17 | "stack-name": "tug-dsc-1",
18 |
19 | // Name of local Lambda CFN template
20 | "template": "serverless.template",
21 |
22 | // Template parameters will be provided at the CLI
23 | "template-parameters": "",
24 |
25 | "configuration": "Release",
26 | "framework": "netcoreapp1.0"
27 | }
--------------------------------------------------------------------------------
/src/Tug.Server.FaaS.AzureFunctions/README.md:
--------------------------------------------------------------------------------
1 | # FaaS Tug - Azure Functions
2 |
3 | This package defines an implementation of TUG DSC Pull Server using a Function-as-a-Service (FaaS)
4 | model that runs atop [Azure Functions](https://azure.microsoft.com/en-us/services/functions/).
5 |
6 | ***NOTE: This is a placeholder for a future implementation***
7 |
--------------------------------------------------------------------------------
/src/Tug.Server.Providers.Ps5DscHandler/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("Tug-Ps5DscHandler")]
9 | [assembly: AssemblyDescription("PowerShell v5 DSC Pull Handler for Tug Server")]
10 | [assembly: AssemblyConfiguration("")]
11 |
12 | /////////////////////////////////////////////////////////////////
13 | // Additional "shared" assembly-level attributes are defined in
14 | // SharedAssemblyInfo.cs and SharedAssemblyVersionInfo.cs files
15 | /////////////////////////////////////////////////////////////////
16 |
--------------------------------------------------------------------------------
/src/Tug.Server.Providers.Ps5DscHandler/Tug.Server.Providers.Ps5DscHandler.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | en-US
5 | github.com/PowerShellOrg/tug/graphs/contributors
6 | net452
7 | $(NoWarn);CS0169;CS0649
8 | portable
9 | Tug.Server.Providers.Ps5DscHandler
10 | Tug.Server.Providers.Ps5DscHandler
11 | false
12 | false
13 | false
14 | false
15 | false
16 | false
17 | false
18 | false
19 | false
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/src/Tug.Server/AppLog.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | using System;
6 | using Microsoft.Extensions.Logging;
7 |
8 | namespace Tug.Server
9 | {
10 | ///
11 | /// Implements a static access pattern for ILoggerFactory.
12 | ///
13 | ///
14 | /// This pattern is based on this static ApplicationLogging class approach.
17 | /// This allows us to introduce logging to static classes (such as Extension
18 | /// Method classes) that cannot participate in dependency-injected services.
19 | ///
20 | public static class AppLog
21 | {
22 | private static LoggerFactory _preLoggerFactory;
23 |
24 | static AppLog()
25 | {
26 | // We set this up to log any events that take place before the
27 | // ultimate logging configuration is finalized and realized
28 | _preLoggerFactory = new LoggerFactory();
29 | // Here we configure the hard-coded settings of the pre-logger with
30 | // anything we want before the runtime logging config is resolved
31 | _preLoggerFactory.AddConsole();
32 |
33 | // This will be the final runtime logger factory
34 | Factory = new LoggerFactory();
35 | }
36 |
37 | public static ILogger CreatePreLogger()
38 | {
39 | return _preLoggerFactory.CreateLogger();
40 | }
41 |
42 | public static ILoggerFactory Factory
43 | { get; }
44 |
45 | public static ILogger Create(Type t)
46 | {
47 | return Factory.CreateLogger(t);
48 | }
49 |
50 | public static ILogger Create()
51 | {
52 | return Factory.CreateLogger();
53 | }
54 | }
55 | }
--------------------------------------------------------------------------------
/src/Tug.Server/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | using System.Reflection;
6 | using Microsoft.Extensions.Configuration.UserSecrets;
7 |
8 | // General Information about an assembly is controlled through the following
9 | // set of attributes. Change these attribute values to modify the information
10 | // associated with an assembly.
11 | [assembly: AssemblyTitle("Tug Server")]
12 | [assembly: AssemblyDescription("Tug Server Implementation")]
13 | [assembly: AssemblyConfiguration("")]
14 | [assembly: AssemblyCulture("")]
15 |
16 | /////////////////////////////////////////////////////////////////
17 | // Additional "shared" assembly-level attributes are defined in
18 | // SharedAssemblyInfo.cs and SharedAssemblyVersionInfo.cs files
19 | /////////////////////////////////////////////////////////////////
20 |
21 | // Defines the ID for User Secrets
22 | [assembly: UserSecretsId("Tug.Server")]
23 |
--------------------------------------------------------------------------------
/src/Tug.Server/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "profiles": {
3 | "tug": {
4 | "commandName": "Project",
5 | "launchBrowser": true,
6 | "launchUrl": "http://localhost:5000",
7 | "environmentVariables": {
8 | "ASPNETCORE_ENVIRONMENT": "Development"
9 | }
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/src/Tug.Server/Providers/Sha256ChecksumAlgorithmProvider.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | using System;
6 | using System.Collections.Generic;
7 | using System.IO;
8 | using System.Security.Cryptography;
9 | using Tug.Ext;
10 |
11 | namespace Tug.Providers
12 | {
13 | public class Sha256ChecksumAlgorithmProvider : IChecksumAlgorithmProvider
14 | {
15 | public const string PROVIDER_NAME = "SHA-256";
16 |
17 | private static readonly ProviderInfo INFO = new ProviderInfo(PROVIDER_NAME);
18 |
19 | private static readonly ProviderParameterInfo[] PARAMS = new ProviderParameterInfo[0];
20 |
21 | private IDictionary _productParams;
22 |
23 | public ProviderInfo Describe() => INFO;
24 |
25 | public IEnumerable DescribeParameters() => PARAMS;
26 |
27 | public void SetParameters(IDictionary productParams = null)
28 | {
29 | _productParams = productParams;
30 | }
31 |
32 | public IChecksumAlgorithm Produce()
33 | {
34 | return new Sha256ChecksumAlgorithm();
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/Tug.Server/appsettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "logSettings": {
3 | "LogType": "nlog",
4 | "DebugLog": "true"
5 | },
6 | "appSettings": {
7 |
8 | }
9 | }
--------------------------------------------------------------------------------
/src/TugDSC.Abstractions/Configuration/Binder/README.md:
--------------------------------------------------------------------------------
1 | # README for `TugDSC.Configuration.Binder`
2 |
3 | The Configration Binder in TugDSC is an adaptation of the standard
4 | [Microsoft Configuration Binder](https://www.nuget.org/packages/Microsoft.Extensions.Configuration.Binder/)
5 | with some enhancements.
6 |
7 | Unfortunately, there is no mechanism to extend the default Binder so this was created by copying
8 | the bits from the official [code repo](https://github.com/aspnet/Configuration/tree/dev/src/Config.Binder)
9 | and making code changes.
10 |
11 | ## License and Copyright Notice
12 |
13 | The code in this sub-namespace is licensed and copyrighted under the original codes terms:
14 |
15 | Apache License, Version 2.0 and Copyright (c) .NET Foundation.
16 |
--------------------------------------------------------------------------------
/src/TugDSC.Abstractions/Ext/IProvider.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | using System.Collections.Generic;
6 |
7 | namespace TugDSC.Ext
8 | {
9 | public interface IProvider
10 | where TProd : IProviderProduct
11 | {
12 | ProviderInfo Describe();
13 |
14 | IEnumerable DescribeParameters();
15 |
16 | void SetParameters(IDictionary productParams);
17 |
18 | TProd Produce();
19 | }
20 | }
--------------------------------------------------------------------------------
/src/TugDSC.Abstractions/Ext/IProviderManager.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | using System.Collections.Generic;
6 |
7 | namespace TugDSC.Ext
8 | {
9 | public interface IProviderManager
10 | where TProv : IProvider
11 | where TProd : IProviderProduct
12 | {
13 | IEnumerable FoundProvidersNames
14 | { get; }
15 |
16 | TProv GetProvider(string name);
17 | }
18 | }
--------------------------------------------------------------------------------
/src/TugDSC.Abstractions/Ext/IProviderProduct.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | using System;
6 |
7 | namespace TugDSC.Ext
8 | {
9 | // Alternative Names:
10 | // public interface IProviderYield
11 | // public interface IProviderResult
12 | // public interface IProviderOutput
13 | public interface IProviderProduct : IDisposable
14 | {
15 | bool IsDisposed
16 | { get; }
17 | }
18 | }
--------------------------------------------------------------------------------
/src/TugDSC.Abstractions/Ext/ProviderInfo.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | namespace TugDSC.Ext
6 | {
7 | public class ProviderInfo
8 | {
9 | public ProviderInfo(string name,
10 | string label = null, string description = null)
11 | {
12 | Name = name;
13 | Label = label;
14 | Description = description;
15 | }
16 |
17 | public string Name
18 | { get; private set; }
19 |
20 | public string Label
21 | { get; private set; }
22 |
23 | public string Description
24 | { get; private set; }
25 | }
26 | }
--------------------------------------------------------------------------------
/src/TugDSC.Abstractions/Ext/ProviderParameterInfo.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | namespace TugDSC.Ext
6 | {
7 | public class ProviderParameterInfo
8 | {
9 | public ProviderParameterInfo(string name,
10 | bool isRequired = false,
11 | string label = null,
12 | string description = null)
13 | {
14 | Name = name;
15 |
16 | IsRequired = false;
17 | Label = label;
18 | Description = description;
19 | }
20 |
21 | public string Name
22 | { get; private set; }
23 |
24 | public bool IsRequired
25 | { get; private set; }
26 |
27 | public string Label
28 | { get; private set; }
29 |
30 | public string Description
31 | { get; private set; }
32 | }
33 | }
--------------------------------------------------------------------------------
/src/TugDSC.Abstractions/Messages/DscResponse.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | using TugDSC.Messages.ModelBinding;
6 |
7 | namespace TugDSC.Messages
8 | {
9 | public class DscResponse
10 | {
11 | public const string PROTOCOL_VERSION_HEADER = "ProtocolVersion";
12 | public const string PROTOCOL_VERSION_VALUE = "2.0";
13 |
14 |
15 | [ToHeader(Name = PROTOCOL_VERSION_HEADER)]
16 | public string ProtocolVersionHeader
17 | { get; set; } = PROTOCOL_VERSION_VALUE;
18 | }
19 | }
--------------------------------------------------------------------------------
/src/TugDSC.Abstractions/Messages/GetConfiguration.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | using System.IO;
6 | using System.Net.Http;
7 | using Microsoft.AspNetCore.Mvc;
8 | using TugDSC.Messages.ModelBinding;
9 |
10 | namespace TugDSC.Messages
11 | {
12 | public class GetConfigurationRequest : DscAgentRequest
13 | {
14 | public static readonly HttpMethod VERB = HttpMethod.Get;
15 |
16 | public const string ROUTE = "Nodes(AgentId='{AgentId}')/Configurations(ConfigurationName='{ConfigurationName}')/ConfigurationContent";
17 | public const string ROUTE_NAME = nameof(GetConfigurationRequest);
18 |
19 | [FromRoute]
20 | public string ConfigurationName
21 | { get; set; }
22 |
23 | ///
24 | /// TODO: Resolve how this relates to the same parameter name in the URI.
25 | /// https://msdn.microsoft.com/en-us/library/mt181633.aspx
26 | ///
27 | [FromHeader(Name = "ConfigurationName")]
28 | public string ConfigurationNameHeader
29 | { get; set; }
30 | }
31 |
32 | public class GetConfigurationResponse : DscResponse
33 | {
34 | [ToHeader(Name = "Checksum")]
35 | public string ChecksumHeader
36 | { get; set; }
37 |
38 | [ToHeader(Name = "ChecksumAlgorithm")]
39 | public string ChecksumAlgorithmHeader
40 | { get; set; }
41 |
42 | [ToResult]
43 | public Stream Configuration
44 | { get; set; }
45 | }
46 | }
--------------------------------------------------------------------------------
/src/TugDSC.Abstractions/Messages/GetDscAction.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | using System.ComponentModel.DataAnnotations;
6 | using System.Net.Http;
7 | using Microsoft.AspNetCore.Mvc;
8 | using TugDSC.Messages.ModelBinding;
9 | using TugDSC.Model;
10 |
11 | namespace TugDSC.Messages
12 | {
13 | public class GetDscActionRequest : DscAgentRequest
14 | {
15 | public static readonly HttpMethod VERB = HttpMethod.Post;
16 |
17 | public const string ROUTE = "Nodes(AgentId='{AgentId}')/GetDscAction";
18 | public const string ROUTE_NAME = nameof(GetDscActionRequest);
19 |
20 | [FromBody]
21 | [Required]
22 | public GetDscActionRequestBody Body
23 | { get; set; }
24 |
25 | public override object GetBody() => Body;
26 | }
27 |
28 | public class GetDscActionResponse : DscResponse
29 | {
30 | [ToResult]
31 | public GetDscActionResponseBody Body
32 | { get; set; }
33 | }
34 | }
--------------------------------------------------------------------------------
/src/TugDSC.Abstractions/Messages/GetModule.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | using System;
6 | using System.ComponentModel.DataAnnotations;
7 | using System.IO;
8 | using System.Net.Http;
9 | using Microsoft.AspNetCore.Mvc;
10 | using TugDSC.Messages.ModelBinding;
11 |
12 | namespace TugDSC.Messages
13 | {
14 | public class GetModuleRequest : DscRequest
15 | {
16 | public static readonly HttpMethod VERB = HttpMethod.Get;
17 |
18 | public const string ROUTE = "Modules(ModuleName='{ModuleName}',ModuleVersion='{ModuleVersion}')/ModuleContent";
19 | public const string ROUTE_NAME = nameof(GetModuleRequest);
20 |
21 | // Apparently this *has* to be a string when binding it from a
22 | // header field otherwise, it just gets skipped over for some
23 | // reason -- not sure if this is a bug in MVC model binding???
24 | [FromHeader(Name = "AgentId")]
25 | [Required]
26 | public string AgentId
27 | { get; set; }
28 |
29 | [FromRoute]
30 | [Required]
31 | public string ModuleName
32 | { get; set; }
33 |
34 | [FromRoute]
35 | [Required]
36 | public string ModuleVersion
37 | { get; set; }
38 |
39 | public override Guid? GetAgentId()
40 | {
41 | Guid agentId;
42 | if (Guid.TryParse(AgentId, out agentId))
43 | return agentId;
44 | else
45 | return null;
46 | }
47 | }
48 |
49 | public class GetModuleResponse : DscResponse
50 | {
51 | [ToHeaderAttribute(Name = "Checksum")]
52 | public string ChecksumHeader
53 | { get; set; }
54 |
55 | [ToHeader(Name = "ChecksumAlgorithm")]
56 | public string ChecksumAlgorithmHeader
57 | { get; set; }
58 |
59 | [ToResult]
60 | public Stream Module
61 | { get; set; }
62 | }
63 | }
--------------------------------------------------------------------------------
/src/TugDSC.Abstractions/Messages/GetReports.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | using System;
6 | using System.Net.Http;
7 | using Microsoft.AspNetCore.Mvc;
8 | using TugDSC.Messages.ModelBinding;
9 | using TugDSC.Model;
10 |
11 | namespace TugDSC.Messages
12 | {
13 | public class GetReportsRequest : DscAgentRequest
14 | {
15 | public static readonly HttpMethod VERB = HttpMethod.Get;
16 |
17 | public const string ROUTE_SINGLE = "Nodes(AgentId='{AgentId}')/Reports(JobId='{JobId}')";
18 | public const string ROUTE_SINGLE_NAME = nameof(GetReportsRequest) + "Single";
19 |
20 | public const string ROUTE_ALL = "Nodes(AgentId='{AgentId}')/Reports()";
21 | public const string ROUTE_ALL_NAME = nameof(GetReportsRequest) + "All";
22 |
23 | public const string ROUTE_ALL_ALT = "Nodes(AgentId='{AgentId}')/Reports";
24 | public const string ROUTE_ALL_ALT_NAME = nameof(GetReportsRequest) + "AllAlt";
25 |
26 |
27 | [FromRoute]
28 | public Guid? JobId
29 | { get; set; }
30 | }
31 |
32 | public class GetReportsSingleResponse : DscResponse
33 | {
34 | [ToResult]
35 | public SendReportBody Body
36 | { get; set; }
37 | }
38 |
39 | public class GetReportsAllResponse : DscResponse
40 | {
41 | [ToResult]
42 | public GetReportsAllResponseBody Body
43 | { get; set; }
44 | }
45 | }
--------------------------------------------------------------------------------
/src/TugDSC.Abstractions/Messages/RegisterDscAgent.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | using System.ComponentModel.DataAnnotations;
6 | using System.Net.Http;
7 | using Microsoft.AspNetCore.Mvc;
8 | using TugDSC.Messages.ModelBinding;
9 | using TugDSC.Model;
10 |
11 | namespace TugDSC.Messages
12 | {
13 | public class RegisterDscAgentRequest : DscAgentRequest
14 | {
15 | public static readonly HttpMethod VERB = HttpMethod.Put;
16 |
17 | public const string ROUTE = "Nodes(AgentId='{AgentId}')";
18 | public const string ROUTE_NAME = nameof(RegisterDscAgentRequest);
19 |
20 | [FromBody]
21 | [Required]
22 | public RegisterDscAgentRequestBody Body
23 | { get; set; }
24 |
25 | public override object GetBody() => Body;
26 | }
27 |
28 | public class RegisterDscAgentResponse : DscResponse
29 | {
30 | ///
31 | /// We only need a single instance since there are
32 | /// no mutable elements in the object graph.
33 | ///
34 | public static readonly RegisterDscAgentResponse INSTANCE =
35 | new RegisterDscAgentResponse();
36 |
37 | [ToResult]
38 | public NoContentResult Body
39 | { get; } = new NoContentResult();
40 | }
41 | }
--------------------------------------------------------------------------------
/src/TugDSC.Abstractions/Messages/SendReport.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | using System.ComponentModel.DataAnnotations;
6 | using System.Net.Http;
7 | using Microsoft.AspNetCore.Mvc;
8 | using TugDSC.Model;
9 |
10 | namespace TugDSC.Messages
11 | {
12 | public class SendReportRequest : DscAgentRequest
13 | {
14 | public static readonly HttpMethod VERB = HttpMethod.Post;
15 |
16 | public const string ROUTE = "Nodes(AgentId='{AgentId}')/SendReport";
17 | public const string ROUTE_NAME = nameof(SendReportRequest);
18 |
19 | [FromBody]
20 | [Required(AllowEmptyStrings = true)]
21 | public SendReportBody Body
22 | { get; set; }
23 |
24 | public override bool HasStrictBody() => false;
25 |
26 | public override object GetBody() => Body;
27 | }
28 | }
--------------------------------------------------------------------------------
/src/TugDSC.Abstractions/Model/ActionDetailsItem.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | using System.ComponentModel.DataAnnotations;
6 |
7 | namespace TugDSC.Model
8 | {
9 | public class ActionDetailsItem : Util.ExtDataIndexerBase
10 | {
11 | [Required(AllowEmptyStrings = true)]
12 | public string ConfigurationName
13 | { get; set; } = string.Empty;
14 |
15 | [Required]
16 | [EnumDataTypeAttribute(typeof(DscActionStatus))]
17 | public DscActionStatus Status
18 | { get; set; }
19 | }
20 | }
--------------------------------------------------------------------------------
/src/TugDSC.Abstractions/Model/AgentInformation.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | using System.ComponentModel.DataAnnotations;
6 |
7 | namespace TugDSC.Model
8 | {
9 | public class AgentInformation : Util.ExtDataIndexerBase
10 | {
11 | // NOTE: DO NOT CHANGE THE ORDER OF THESE PROPERTIES!!!
12 | // Apparently the order of these properties is important
13 | // to successfully fulfill the RegKey authz requirements
14 |
15 | [Required]
16 | public string LCMVersion
17 | { get; set; }
18 |
19 | [Required]
20 | public string NodeName
21 | { get; set; }
22 |
23 | [Required(AllowEmptyStrings = true)]
24 | public string IPAddress
25 | { get; set; }
26 | }
27 | }
--------------------------------------------------------------------------------
/src/TugDSC.Abstractions/Model/CertificateInformation.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | using System.ComponentModel.DataAnnotations;
6 |
7 | namespace TugDSC.Model
8 | {
9 | public class CertificateInformation : Util.ExtDataIndexerBase
10 | {
11 | public CertificateInformation()
12 | { }
13 |
14 | public CertificateInformation(CertificateInformation copyFrom)
15 | {
16 | this.FriendlyName = copyFrom.FriendlyName;
17 | this.Issuer = copyFrom.Issuer;
18 | this.NotAfter = copyFrom.NotAfter;
19 | this.NotBefore = copyFrom.NotBefore;
20 | this.Subject = copyFrom.Subject;
21 | this.PublicKey = copyFrom.PublicKey;
22 | this.Thumbprint = copyFrom.Thumbprint;
23 | }
24 |
25 | // NOTE: DO NOT CHANGE THE ORDER OF THESE PROPERTIES!!!
26 | // Apparently the order of these properties is important
27 | // to successfully fulfill the RegKey authz requirements
28 |
29 | [Required]
30 | public string FriendlyName
31 | { get; set; }
32 |
33 | [Required]
34 | public string Issuer
35 | { get; set; }
36 |
37 | [Required]
38 | public string NotAfter
39 | { get; set; }
40 |
41 | [Required]
42 | public string NotBefore
43 | { get; set; }
44 |
45 | [Required]
46 | public string Subject
47 | { get; set; }
48 |
49 | [Required]
50 | public string PublicKey
51 | { get; set; }
52 |
53 | [Required]
54 | public string Thumbprint
55 | { get; set; }
56 |
57 | // This *MUST* be an int or RegisterDscAction will fail with a
58 | // 401 Unauthorized error and eroneously report an invalid
59 | // Registration Key -- as HOURS of debugging has proven!
60 | [Required]
61 | public int Version
62 | { get; set; }
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/src/TugDSC.Abstractions/Model/ClientStatusItem.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | using System.ComponentModel.DataAnnotations;
6 | using Newtonsoft.Json;
7 |
8 | namespace TugDSC.Model
9 | {
10 | public class ClientStatusItem : Util.ExtDataIndexerBase
11 | {
12 | // NOTE: DO NOT CHANGE THE ORDER OF THESE PROPERTIES!!!
13 | // Apparently the order of these properties is important
14 | // to successfully satisfy the strict input validation
15 |
16 | // Based on testing and observation, this property
17 | // is completely omitted when it has no value
18 | [JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
19 | public string ConfigurationName
20 | { get; set; }
21 |
22 | [Required(AllowEmptyStrings = true)]
23 | public string Checksum
24 | { get; set; }
25 |
26 | [Required]
27 | [CustomValidation(typeof(ClientStatusItem),
28 | nameof(ValidateChecksumAlgorithm))]
29 | public string ChecksumAlgorithm
30 | { get; set; }
31 |
32 | public static ValidationResult ValidateChecksumAlgorithm(string value)
33 | {
34 | return "SHA-256" == value
35 | ? ValidationResult.Success
36 | : new ValidationResult("unsupported or unknown checksum algorithm");
37 | }
38 | }
39 | }
--------------------------------------------------------------------------------
/src/TugDSC.Abstractions/Model/GetDscActionRequestBody.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | using System.ComponentModel.DataAnnotations;
6 |
7 | namespace TugDSC.Model
8 | {
9 | public class GetDscActionRequestBody : Util.ExtDataIndexerBase
10 | {
11 | [Required]
12 | [MinLengthAttribute(1)]
13 | public ClientStatusItem[] ClientStatus
14 | { get; set; }
15 | }
16 | }
--------------------------------------------------------------------------------
/src/TugDSC.Abstractions/Model/GetDscActionResponseBody.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | using System.ComponentModel.DataAnnotations;
6 |
7 | namespace TugDSC.Model
8 | {
9 | public class GetDscActionResponseBody : Util.ExtDataIndexerBase
10 | {
11 | [Required]
12 | [EnumDataTypeAttribute(typeof(DscActionStatus))]
13 | public DscActionStatus NodeStatus
14 | { get; set; }
15 |
16 | public ActionDetailsItem[] Details
17 | { get; set; }
18 | }
19 | }
--------------------------------------------------------------------------------
/src/TugDSC.Abstractions/Model/GetReportsResponseBody.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | using System.Collections.Generic;
6 | using Newtonsoft.Json;
7 |
8 | namespace TugDSC.Model
9 | {
10 | public class GetReportsAllResponseBody : Util.ExtDataIndexerBase
11 | {
12 | [JsonProperty(PropertyName = "value")]
13 | public IEnumerable Value
14 | { get; set; }
15 | }
16 | }
--------------------------------------------------------------------------------
/src/TugDSC.Abstractions/Model/RegisterDscAgentRequestBody.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | using System.ComponentModel.DataAnnotations;
6 | using Newtonsoft.Json;
7 |
8 | namespace TugDSC.Model
9 | {
10 | ///
11 | /// https://msdn.microsoft.com/en-us/library/dn365245.aspx
12 | ///
13 | public class RegisterDscAgentRequestBody : Util.ExtDataIndexerBase
14 | {
15 | // NOTE: DO NOT CHANGE THE ORDER OF THESE PROPERTIES!!!
16 | // Apparently the order of these properties is important
17 | // to successfully fulfill the RegKey authz requirements
18 |
19 | [Required]
20 | public AgentInformation AgentInformation
21 | { get; set; }
22 |
23 | // Based on testing and observation, this property
24 | // is completely omitted when it has no value
25 | [JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
26 | public string[] ConfigurationNames
27 | { get; set; }
28 |
29 | [Required]
30 | public RegistrationInformation RegistrationInformation
31 | { get; set; }
32 | }
33 | }
--------------------------------------------------------------------------------
/src/TugDSC.Abstractions/Model/RegistrationInformation.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | using System.ComponentModel.DataAnnotations;
6 |
7 | namespace TugDSC.Model
8 | {
9 | public class RegistrationInformation : Util.ExtDataIndexerBase
10 | {
11 | // NOTE: DO NOT CHANGE THE ORDER OF THESE PROPERTIES!!!
12 | // Apparently the order of these properties is important
13 | // to successfully fulfill the RegKey authz requirements
14 |
15 | [Required]
16 | public CertificateInformation CertificateInformation
17 | { get; set; }
18 |
19 | [Required]
20 | public string RegistrationMessageType
21 | { get; set; }
22 | }
23 | }
--------------------------------------------------------------------------------
/src/TugDSC.Abstractions/README.md:
--------------------------------------------------------------------------------
1 | # README - TugDSC Abstractions
2 |
3 | This library defines abstractions and components that are common to both clients and servers of the DSC platform.
4 |
--------------------------------------------------------------------------------
/src/TugDSC.Abstractions/TugDSC.Abstractions.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
7 |
8 |
9 | netstandard2.0
10 | $(NoWarn);$(CommonNoWarn)
11 | TugDSC
12 |
13 |
14 |
15 | TugDSC Abstractions
16 | Common Abstractions & Components
17 |
18 |
19 |
25 |
26 |
30 |
31 |
32 |
33 |
34 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/src/TugDSC.Abstractions/Util/ExceptionExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace TugDSC.Util
4 | {
5 | public static class ExceptionExtensions
6 | {
7 | /// This extension method provides a fluent method of appending various
8 | /// meta data to an exception, useful when debugging and trying to
9 | /// isolate more contextual information from a thrown exception.
10 | public static T WithData(this T exception, object key, object value)
11 | where T : Exception
12 | {
13 | exception.Data.Add(key, value);
14 | return exception;
15 | }
16 | }
17 | }
--------------------------------------------------------------------------------
/src/TugDSC.Abstractions/Util/ExtDataBase.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | using System.Collections.Generic;
6 | using Newtonsoft.Json;
7 | using Newtonsoft.Json.Linq;
8 |
9 | namespace TugDSC.Util
10 | {
11 | /// Base class implementation supporting extension data with JSON serialization.
12 | public abstract class ExtDataBase : IExtData
13 | {
14 | [JsonExtensionData]
15 | protected IDictionary _extData = new Dictionary();
16 |
17 | IDictionary IExtData.GetExtData()
18 | {
19 | return _extData;
20 | }
21 | }
22 | }
--------------------------------------------------------------------------------
/src/TugDSC.Abstractions/Util/ExtDataExtensions.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | using System.Collections.Generic;
6 | using Newtonsoft.Json.Linq;
7 |
8 | namespace TugDSC.Util
9 | {
10 | /// Various extension methods that make working with extension data
11 | /// implementations easier and more fluid.
12 | public static class ExtDataExtensions
13 | {
14 | public static int GetExtDataCount(this IExtData extData)
15 | {
16 | return extData.GetExtData().Count;
17 | }
18 |
19 | public static IEnumerable GetExtDataKeys(this IExtData extData)
20 | {
21 | return extData.GetExtData().Keys;
22 | }
23 |
24 | public static bool ContainsExtData(this IExtData extData, string key)
25 | {
26 | return extData.GetExtData().ContainsKey(key);
27 | }
28 |
29 | public static object GetExtData(this IExtData extData, string key, object ifNotFound = null)
30 | {
31 | return extData.GetExtData().ContainsKey(key)
32 | ? extData.GetExtData()[key]
33 | : ifNotFound;
34 | }
35 |
36 | public static void SetExtData(this IExtData extData, string key, object value)
37 | {
38 | extData.GetExtData()[key] = JToken.FromObject(value);
39 | }
40 |
41 | public static void RemoveExtData(this IExtData extData, string key)
42 | {
43 | extData.GetExtData().Remove(key);
44 | }
45 | }
46 | }
--------------------------------------------------------------------------------
/src/TugDSC.Abstractions/Util/ExtDataIndexerBase.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | namespace TugDSC.Util
6 | {
7 | /// Extends the base extension data implementation with support for an
8 | /// indexer to access extension data properties.
9 | public abstract class ExtDataIndexerBase : ExtDataBase
10 | {
11 | public object this[string key]
12 | {
13 | get { return ((IExtData)this).GetExtData(key); }
14 | set { ((IExtData)this).SetExtData(key, value); }
15 | }
16 | }
17 | }
--------------------------------------------------------------------------------
/src/TugDSC.Abstractions/Util/IExtData.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | using System.Collections.Generic;
6 | using Newtonsoft.Json.Linq;
7 |
8 | namespace TugDSC.Util
9 | {
10 | /// Model entities that implement this interface support "extension data" in the context of
11 | /// serialization to/from JSON. Extension data allows us to add additional pieces of data
12 | /// to an entity that was not included in the initial entity definition. However, we use
13 | /// mostly to catch possible mismatch between client/server representations of data classes.
14 | public interface IExtData
15 | {
16 | IDictionary GetExtData();
17 | }
18 | }
--------------------------------------------------------------------------------
/src/TugDSC.Client.CLIApp/AppLog.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | using System;
6 | using Microsoft.Extensions.Logging;
7 |
8 | namespace TugDSC.Client
9 | {
10 | ///
11 | /// Implements a static access pattern for ILoggerFactory.
12 | ///
13 | ///
14 | /// This pattern is based on this static ApplicationLogging class approach.
17 | /// This allows us to introduce logging to static classes (such as Extension
18 | /// Method classes) that cannot participate in dependency-injected services.
19 | ///
20 | public static class AppLog
21 | {
22 | // private static LoggerFactory _preLoggerFactory;
23 |
24 | static AppLog()
25 | {
26 | // // We set this up to log any events that take place before the
27 | // // ultimate logging configuration is finalized and realized
28 | // _preLoggerFactory = new LoggerFactory();
29 | // // Here we configure the hard-coded settings of the pre-logger with
30 | // // anything we want before the runtime logging config is resolved
31 | // _preLoggerFactory.AddConsole();
32 |
33 | // This will be the final runtime logger factory
34 | Factory = new LoggerFactory();
35 | }
36 |
37 | // public static ILogger CreatePreLogger()
38 | // {
39 | // return _preLoggerFactory.CreateLogger();
40 | // }
41 |
42 | public static ILoggerFactory Factory
43 | { get; }
44 |
45 | public static ILogger Create(Type t)
46 | {
47 | return Factory.CreateLogger(t);
48 | }
49 |
50 | public static ILogger Create()
51 | {
52 | return Factory.CreateLogger();
53 | }
54 | }
55 | }
--------------------------------------------------------------------------------
/src/TugDSC.Client.CLIApp/FileResponse.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | namespace TugDSC.Client
6 | {
7 | // TODO: maybe we should make this a disposable and the
8 | // Content should be a stream (that would be cleaned up)
9 | // and we could provide convenience methods to get bytes,
10 | // etc. -- SOMETHING TO CONSIDER...
11 |
12 | public class FileResponse
13 | {
14 | public string ChecksumAlgorithm
15 | { get; set; }
16 |
17 | public string Checksum
18 | { get; set; }
19 |
20 | public byte[] Content
21 | { get; set; }
22 | }
23 | }
--------------------------------------------------------------------------------
/src/TugDSC.Client.CLIApp/TugDSC.Client.CLIApp.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
7 |
8 |
9 | netcoreapp2.0
10 | Exe
11 |
12 |
13 |
14 | TugDSC Command Line Interface Client
15 | DSC Pull Mode client compatible with Classic DSC Pull Server
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/src/TugDSC.Server.Abstractions/ActionStatus.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | using System.Collections.Generic;
6 | using TugDSC.Model;
7 |
8 | namespace TugDSC.Server
9 | {
10 | public class ActionStatus
11 | {
12 | public DscActionStatus NodeStatus
13 | { get; set; }
14 |
15 | public IEnumerable ConfigurationStatuses
16 | { get; set; }
17 | }
18 | }
--------------------------------------------------------------------------------
/src/TugDSC.Server.Abstractions/Configuration/AppSettings.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | namespace TugDSC.Server.Configuration
6 | {
7 | public class AppSettings
8 | {
9 | public ChecksumSettings Checksum
10 | { get; set; }
11 |
12 | public AuthzSettings Authz
13 | { get; set; }
14 |
15 | public HandlerSettings Handler
16 | { get; set; }
17 | }
18 | }
--------------------------------------------------------------------------------
/src/TugDSC.Server.Abstractions/Configuration/AuthzSettings.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | using System.Collections.Generic;
6 |
7 | namespace TugDSC.Server.Configuration
8 | {
9 | public class AuthzSettings
10 | {
11 | // TODO: Need to think about the extensibility model for
12 | // authorization, if we want to use the Provider mechanism
13 |
14 | // public ExtSettings Ext
15 | // { get; set; }
16 |
17 | // [Required]
18 | // public string Provider
19 | // { get; set; }
20 |
21 | // This has to be concrete class, not interface to
22 | // be able to construct during deserialization
23 | public Dictionary Params
24 | { get; set; }
25 | }
26 | }
--------------------------------------------------------------------------------
/src/TugDSC.Server.Abstractions/Configuration/ChecksumSettings.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | namespace TugDSC.Server.Configuration
6 | {
7 | public class ChecksumSettings
8 | {
9 | public ExtSettings Ext
10 | { get; set; }
11 |
12 | public string Default
13 | { get; set; } = "SHA-256";
14 | }
15 | }
--------------------------------------------------------------------------------
/src/TugDSC.Server.Abstractions/Configuration/ExtSettings.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | namespace TugDSC.Server.Configuration
6 | {
7 | public class ExtSettings
8 | {
9 | public bool ReplaceExtAssemblies
10 | { get; set; }
11 |
12 | public string[] SearchAssemblies
13 | { get; set; }
14 |
15 | public bool ReplaceExtPaths
16 | { get; set; }
17 |
18 | public string[] SearchPaths
19 | { get; set; }
20 | }
21 | }
--------------------------------------------------------------------------------
/src/TugDSC.Server.Abstractions/Configuration/HandlerSettings.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | using System.Collections.Generic;
6 | using System.ComponentModel.DataAnnotations;
7 |
8 | namespace TugDSC.Server.Configuration
9 | {
10 | public class HandlerSettings
11 | {
12 | public ExtSettings Ext
13 | { get; set; }
14 |
15 | [Required]
16 | public string Provider
17 | { get; set; } = "basic";
18 |
19 | // This has to be concrete class, not interface to
20 | // be able to construct during deserialization
21 | public Dictionary Params
22 | { get; set; }
23 | }
24 | }
--------------------------------------------------------------------------------
/src/TugDSC.Server.Abstractions/Configuration/LogSettings.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | using System;
6 |
7 | namespace TugDSC.Server.Configuration
8 | {
9 | public class LogSettings
10 | {
11 | public LogType LogType
12 | { get; set; }
13 |
14 | public bool DebugLog
15 | { get; set; }
16 | }
17 |
18 | [Flags]
19 | public enum LogType
20 | {
21 | None = 0x0,
22 |
23 | Console = 0x1,
24 |
25 | NLog = 0x2,
26 |
27 | All = Console | NLog,
28 | }
29 | }
--------------------------------------------------------------------------------
/src/TugDSC.Server.Abstractions/DscHandlerConfig.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | using System.Collections.Generic;
6 |
7 | namespace TugDSC.Server
8 | {
9 | public class DscHandlerConfig
10 | {
11 | public IDictionary InitParams
12 | { get; set; }
13 | }
14 | }
--------------------------------------------------------------------------------
/src/TugDSC.Server.Abstractions/FileContent.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | using System.IO;
6 |
7 | namespace TugDSC.Server
8 | {
9 | public class FileContent
10 | {
11 | public string ChecksumAlgorithm
12 | { get; set; }
13 |
14 | public string Checksum
15 | { get; set; }
16 |
17 | public Stream Content
18 | { get; set; }
19 | }
20 | }
--------------------------------------------------------------------------------
/src/TugDSC.Server.Abstractions/IChecksumAlgorithm.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | using System.IO;
6 | using TugDSC.Ext;
7 |
8 | namespace TugDSC
9 | {
10 | public interface IChecksumAlgorithm : IProviderProduct
11 | {
12 | string AlgorithmName
13 | { get; }
14 |
15 | string ComputeChecksum(byte[] bytes);
16 |
17 | string ComputeChecksum(Stream stream);
18 | }
19 | }
--------------------------------------------------------------------------------
/src/TugDSC.Server.Abstractions/README.md:
--------------------------------------------------------------------------------
1 | # README - TugDSC Server Abstractions
2 |
3 | This library defines abstractions and components that are common to different implementations of servers of the DSC platform.
4 |
--------------------------------------------------------------------------------
/src/TugDSC.Server.Abstractions/TugDSC.Server.Abstractions.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
7 |
8 |
9 | netstandard2.0
10 | TugDSC.Server
11 |
12 |
13 |
14 | TugDSC Server Abstractions
15 | Server-specific Abstractions & Components
16 |
17 |
18 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/src/TugDSC.Server.WebAppHost/AppLog.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | using System;
6 | using Microsoft.Extensions.Logging;
7 |
8 | namespace TugDSC.Server.WebAppHost
9 | {
10 | ///
11 | /// Implements a static access pattern for ILoggerFactory.
12 | ///
13 | ///
14 | /// This pattern is based on this static ApplicationLogging class approach.
17 | /// This allows us to introduce logging to static classes (such as Extension
18 | /// Method classes) that cannot participate in dependency-injected services.
19 | ///
20 | public static class AppLog
21 | {
22 | private static LoggerFactory _preLoggerFactory;
23 |
24 | static AppLog()
25 | {
26 | // We set this up to log any events that take place before the
27 | // ultimate logging configuration is finalized and realized
28 | _preLoggerFactory = new LoggerFactory();
29 | // Here we configure the hard-coded settings of the pre-logger with
30 | // anything we want before the runtime logging config is resolved
31 | _preLoggerFactory.AddConsole();
32 |
33 | // This will be the final runtime logger factory
34 | Factory = new LoggerFactory();
35 | }
36 |
37 | public static ILogger CreatePreLogger()
38 | {
39 | return _preLoggerFactory.CreateLogger();
40 | }
41 |
42 | public static ILoggerFactory Factory
43 | { get; }
44 |
45 | public static ILogger Create(Type t)
46 | {
47 | return Factory.CreateLogger(t);
48 | }
49 |
50 | public static ILogger Create()
51 | {
52 | return Factory.CreateLogger();
53 | }
54 | }
55 | }
--------------------------------------------------------------------------------
/src/TugDSC.Server.WebAppHost/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "iisSettings": {
3 | "windowsAuthentication": false,
4 | "anonymousAuthentication": true,
5 | "iisExpress": {
6 | "applicationUrl": "http://localhost:61577/",
7 | "sslPort": 0
8 | }
9 | },
10 | "profiles": {
11 | "IIS Express": {
12 | "commandName": "IISExpress",
13 | "launchBrowser": true,
14 | "environmentVariables": {
15 | "ASPNETCORE_ENVIRONMENT": "Development"
16 | }
17 | },
18 | "TugDSC.Server.WebAppHost": {
19 | "commandName": "Project",
20 | "launchBrowser": true,
21 | "environmentVariables": {
22 | "ASPNETCORE_ENVIRONMENT": "Development"
23 | },
24 | "applicationUrl": "http://localhost:61579/"
25 | }
26 | }
27 | }
--------------------------------------------------------------------------------
/src/TugDSC.Server.WebAppHost/Providers/Sha256ChecksumAlgorithmProvider.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | using System;
6 | using System.Collections.Generic;
7 | using System.IO;
8 | using System.Security.Cryptography;
9 | using TugDSC.Ext;
10 |
11 | namespace TugDSC.Providers
12 | {
13 | public class Sha256ChecksumAlgorithmProvider : IChecksumAlgorithmProvider
14 | {
15 | public const string PROVIDER_NAME = "SHA-256";
16 |
17 | private static readonly ProviderInfo INFO = new ProviderInfo(PROVIDER_NAME);
18 |
19 | private static readonly ProviderParameterInfo[] PARAMS = new ProviderParameterInfo[0];
20 |
21 | private IDictionary _productParams;
22 |
23 | public ProviderInfo Describe() => INFO;
24 |
25 | public IEnumerable DescribeParameters() => PARAMS;
26 |
27 | public void SetParameters(IDictionary productParams = null)
28 | {
29 | _productParams = productParams;
30 | }
31 |
32 | public IChecksumAlgorithm Produce()
33 | {
34 | return new Sha256ChecksumAlgorithm();
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/TugDSC.Server.WebAppHost/README.md:
--------------------------------------------------------------------------------
1 | # README - TugDSC Server Web App Host
2 |
3 | This is an implementation of a DSC Pull Server implemented as a ASP.NET Core MVC Web App.
4 |
5 | ## Running as a Windows Service
6 |
7 | You can run this TugDSC Server implementation as a Windows Service if you following these
8 | guidelines.
9 |
10 | * First, you must be running this TugDSC Server on the .NET Framework 4.6.1 or greater,
11 | so be sure that it's installed on the target host and be sure to run the version of
12 | the TugDSC Server application that has been compiled to target that platform.
13 | * Next, be sure the required `appsettings.json` file is located in the same path as the
14 | binary which will be executed (`TugDSC.Server.WebAppHost.exe`). Additionally, if you
15 | want to provide an optional hosting configuration file (`hosting.json`), it too must
16 | be located in the same path as the binary executable.
17 | * Finally, you need to install the application as a Windows Service that gets invoked with the
18 | `--service` CLI flag, for example:
19 | ```batch
20 | sc.exe create TugDSC binPath= "\"c:\path\to\binary\TugDSC.Server.WebAppHost.exe\" --service "
21 | sc.exe start TugDSC
22 | ```
23 |
24 | > NOTE: The above example is assumed to be executed from a Windows command shell (cmd.exe).
25 | > If executing the same set of commands from PowerShell, make sure the use the appropriate
26 | > method of escaping within quoted string (the backtick).
27 |
--------------------------------------------------------------------------------
/src/TugDSC.Server.WebAppHost/StartupLogger.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.Extensions.Configuration;
2 | using Microsoft.Extensions.Logging;
3 |
4 | namespace TugDSC.Server.WebAppHost
5 | {
6 | /// This helper class allows us to access the logging subsystem
7 | /// before runtime logging is fully configured. It sets up some
8 | /// hard-coded defaults with support for some environment-based
9 | /// configuration to control its behavior.
10 | public static class StartupLogger
11 | {
12 | /// An optional environment variable that points to a full file
13 | /// path that we load to pass on to the Console logging provider.
14 | public const string STARTUP_LOG_CONFIG = "TUG_STARTUP_LOG_CONFIG";
15 |
16 | private static LoggerFactory _startupLoggerFactory;
17 |
18 | static StartupLogger()
19 | {
20 | var cfgFile = System.Environment.GetEnvironmentVariable(STARTUP_LOG_CONFIG);
21 |
22 | _startupLoggerFactory = new LoggerFactory();
23 |
24 | if (!string.IsNullOrEmpty(cfgFile))
25 | {
26 | var cfg = new ConfigurationBuilder()
27 | .AddJsonFile(cfgFile, optional: false)
28 | .Build();
29 | _startupLoggerFactory.AddConsole(cfg);
30 | }
31 | else
32 | {
33 | _startupLoggerFactory.AddConsole();
34 | }
35 | }
36 |
37 | public static ILogger CreateLogger(string logName) =>
38 | _startupLoggerFactory.CreateLogger(logName);
39 |
40 | public static ILogger CreateLogger() =>
41 | _startupLoggerFactory.CreateLogger();
42 | }
43 | }
--------------------------------------------------------------------------------
/src/TugDSC.Server.WebAppHost/appsettings.Development.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "IncludeScopes": false,
4 | "LogLevel": {
5 | "Default": "Debug",
6 | "System": "Information",
7 | "Microsoft": "Information"
8 | }
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/src/TugDSC.Server.WebAppHost/appsettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "IncludeScopes": false,
4 | "Debug": {
5 | "LogLevel": {
6 | "Default": "Warning"
7 | }
8 | },
9 | "Console": {
10 | "LogLevel": {
11 | "Default": "Warning"
12 | }
13 | }
14 | },
15 |
16 |
17 | // "logSettings": {
18 | // "LogType": "nlog",
19 | // "DebugLog": "true"
20 | // },
21 | "appSettings": {
22 | "checksum": {
23 | "default": "SHA-256"
24 | },
25 |
26 | "authz": {
27 | "params": {
28 | // This is where we look for the file containing reg keys,
29 | // which is named "RegistrationKeys.txt" by default. In this
30 | // file we look for non-blank lines after removing any comments
31 | // starting with the '#' character and trimming from both ends
32 | "RegistrationKeyPath": "_IGNORE/DscService/Authz",
33 | // We keep our own copy of registrations that is separate from
34 | // those saved by the Pull Handler down below which is strictly
35 | // for authz purposes -- these may overlap but could cause conflicts
36 | "RegistrationSavePath": "_IGNORE/DscService/Authz/Registrations"
37 | }
38 | },
39 |
40 | // Enable this setup to use the BASIC DSC Handler
41 | "handler": {
42 | // No need for "provider" as it defaults to "basic"
43 | //"provider": "basic",
44 | "params": {
45 | // For testing purposes, we redefine these to make sure they get
46 | // placed under the _IGNORE subfolder so they are ignored by Git
47 | "RegistrationSavePath": "_IGNORE/DscService/Registrations",
48 | "ConfigurationPath": "_IGNORE/DscService/Configuration",
49 | "ModulePath": "_IGNORE/DscService/Modules",
50 | "ReportsPath": "_IGNORE/DscService/Reports"
51 | }
52 | }
53 | }
54 | }
--------------------------------------------------------------------------------
/src/bundles/Tug.Server-ps5/Tug.Server-ps5.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | en-US
5 | github.com/PowerShellOrg/tug/graphs/contributors
6 | net452
7 | $(NoWarn);CS0169;CS0649
8 | portable
9 | Tug.Server-ps5
10 | Tug.Server-ps5
11 | false
12 | false
13 | false
14 | false
15 | false
16 | false
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 | $(DefineConstants);DOTNET_FRAMEWORK
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/src/bundles/Tug.Server-ps5/build-posh-module.cmd:
--------------------------------------------------------------------------------
1 | @SETLOCAL
2 | @SET THIS=%0
3 | @SET THIS_DIR=%~dp0
4 |
5 | @ECHO THIS=%THIS%
6 | @ECHO THIS_DIR=%THIS_DIR%
7 |
8 | @SET PUBLISH_DIR=%THIS_DIR%bin\posh-modules\Tug.Server-ps5
9 | @IF EXIST "%PUBLISH_DIR%" RD %PUBLISH_DIR% /s /q
10 | @ECHO Publishing to [%PUBLISH_DIR%]
11 |
12 | @REM We need to publish each of the Tug.Server and the PS5 Handler
13 | @REM projects to produce the necessary artifacts for deployment
14 | dotnet publish %THIS_DIR%..\..\Tug.Server -o %PUBLISH_DIR%\bin -f net452 -r win7-x64
15 | dotnet publish %THIS_DIR%..\..\Tug.Server.Providers.Ps5DscHandler -o %PUBLISH_DIR%\bin\ext -f net452 -r win7-x64
16 | dotnet publish %THIS_DIR% -o %PUBLISH_DIR%\bin -f net452 -r win7-x64
17 |
18 | @REM We iterate through each file that's in EXT and if it exists
19 | @REM exactly the same in the parent bin folder, we can remove it
20 | @FOR /F %%f IN ('DIR %PUBLISH_DIR%\bin\ext\* /a-d/b') DO @(
21 | @IF EXIST %PUBLISH_DIR%\bin\%%f (
22 | @FC /B %PUBLISH_DIR%\bin\ext\%%f %PUBLISH_DIR%\bin\%%f > nul
23 | @IF "%ERRORLEVEL%"=="0" @DEL %PUBLISH_DIR%\bin\ext\%%f
24 | )
25 | )
26 |
27 | @REM Copy over the supporting config and
28 | @REM doc files exactly as they are
29 | xcopy %THIS_DIR%posh-res %PUBLISH_DIR%\ /E
30 |
31 | @REM Copy over the Basic Tug PS cmdlets over from the test folder
32 | copy %THIS_DIR%..\..\..\test\run-net452-ps5\BasicTugCmdlets.ps1 %PUBLISH_DIR%\samples
33 |
34 | @ENDLOCAL
35 |
--------------------------------------------------------------------------------
/src/bundles/Tug.Server-ps5/posh-res/samples/RegistrationKeys.txt:
--------------------------------------------------------------------------------
1 | ## This is a sample 'Registration Keys' file. This file is only relevant
2 | ## if "Registration Key Authorization" (RegKey Authz) is enabled.
3 |
4 | ## In this file Tug will use any non-blank lines after stripping out
5 | ## comments starting with the '#' character and trimming whitespace
6 | ## from both ends.
7 |
8 | ## A similar file needs to be placed in the folder defined by the
9 | ## "RegistrationKeyPath" authorization parameter.
10 |
11 | #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
12 | #!! NOTE: this is a sample ONLY -- be sure to edit and populate
13 | #!! with your own *SECRET* registration keys
14 | #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
15 |
16 | c3ea5066-ce5a-4d12-a42a-850be287b2d8
17 |
--------------------------------------------------------------------------------
/src/bundles/Tug.Server-ps5/posh-res/samples/hosting.json.sample:
--------------------------------------------------------------------------------
1 | {
2 | ///////////////////////////////////////////////////////////////////////
3 | // These are the default settings that can be overridden
4 | ///////////////////////////////////////////////////////////////////////
5 |
6 | // "applicationName": "Tug.Server",
7 | // "environment": "PRODUCTION",
8 | // "captureStartupErrors": "false",
9 | // "contentRoot": ".",
10 | // "detailedErrors": "false",
11 | // "urls" : "http://*:5000"
12 |
13 | }
--------------------------------------------------------------------------------
/src/bundles/Tug.Server-ps5/posh-res/samples/tug-server.cmd:
--------------------------------------------------------------------------------
1 | @SETLOCAL
2 | @SET THIS=%0
3 | @SET THIS_DIR=%~dp0
4 |
5 | @ECHO THIS=%THIS%
6 | @ECHO THIS_DIR=%THIS_DIR%
7 |
8 | @SET ENTRY_ASM=%THIS_DIR%.\bin\Tug.Server.exe
9 |
10 | "%ENTRY_ASM%" %*
11 |
12 | @ENDLOCAL
13 |
--------------------------------------------------------------------------------
/src/bundles/TugDSC.Server.Basic/Bundles.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/src/bundles/TugDSC.Server.Basic/src/assets/RegistrationKeys.txt:
--------------------------------------------------------------------------------
1 | ## This is a sample 'Registration Keys' file. This file is only relevant
2 | ## if "Registration Key Authorization" (RegKey Authz) is enabled.
3 |
4 | ## In this file Tug will use any non-blank lines after stripping out
5 | ## comments starting with the '#' character and trimming whitespace
6 | ## from both ends.
7 |
8 | ## A similar file needs to be placed in the folder defined by the
9 | ## "RegistrationKeyPath" authorization parameter.
10 |
11 | #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
12 | #!! NOTE: this is a sample ONLY -- be sure to edit and populate
13 | #!! with your own *SECRET* registration keys
14 | #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
15 |
16 | c3ea5066-ce5a-4d12-a42a-850be287b2d8
17 |
--------------------------------------------------------------------------------
/src/bundles/TugDSC.Server.Basic/src/assets/hosting.json.sample:
--------------------------------------------------------------------------------
1 | {
2 | ///////////////////////////////////////////////////////////////////////
3 | // These are the default settings that can be overridden
4 | ///////////////////////////////////////////////////////////////////////
5 |
6 | // "applicationName": "TugDSC.Server",
7 | // "environment": "PRODUCTION",
8 | // "captureStartupErrors": "false",
9 | // "contentRoot": ".",
10 | // "detailedErrors": "false",
11 | // "urls": "http://*:5000"
12 |
13 | }
--------------------------------------------------------------------------------
/src/shared/SharedAssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyCompany("github.com/PowerShellOrg")]
9 | [assembly: AssemblyProduct("TugDSC")]
10 | [assembly: AssemblyCopyright("Copyright (c) The DevOps Collective, Inc. All rights reserved. Licensed under the MIT license.")]
11 | [assembly: AssemblyTrademark("TugDSC™")]
12 |
--------------------------------------------------------------------------------
/src/shared/SharedAssemblyVersionInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 |
3 | // Version information for an assembly consists of the following four values:
4 | //
5 | // M.N.P.B
6 | //
7 | // Major Version (M)
8 | // Minor Version (N)
9 | // Patch Number (P)
10 | // Build Number (B)
11 | //
12 | // You can specify all the values or you can default the Build and Revision Numbers
13 | // by using the '*' as shown below:
14 | // [assembly: AssemblyVersion("1.0.*")]
15 | [assembly: AssemblyVersion(ASMINFO.VERSION + ".0")]
16 | [assembly: AssemblyFileVersion(ASMINFO.VERSION + ".0")]
17 |
18 | // This is used for the NuSpec version tag replacement
19 | // and is combined with nuget-specific rev and release
20 | [assembly: AssemblyInformationalVersion(ASMINFO.VERSION)]
21 |
22 | // ReSharper disable once InconsistentNaming
23 | internal static class ASMINFO
24 | {
25 |
26 | // DON'T FORGET TO UPDATE APPVEYOR.YML
27 | // ReSharper disable once InconsistentNaming
28 | public const string VERSION = "0.7.0";
29 | }
30 |
--------------------------------------------------------------------------------
/src/shared/SharedGlobalSuppressions.cs:
--------------------------------------------------------------------------------
1 |
2 | // This file is used by Code Analysis to maintain SuppressMessage
3 | // attributes that are applied to this project.
4 | // Project-level suppressions either have no target or are given
5 | // a specific target and scoped to a namespace, type, member, etc.
6 |
7 | [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage(
8 | "Redundancies in Code", "RECS0113:Redundant comma in array initializer",
9 | Justification = "Personal Preference in Coding Style")]
--------------------------------------------------------------------------------
/src/testing/TugDSC.Testing.MSTest/TugDSC.Testing.MSTest.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
7 |
8 |
9 | netstandard2.0
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/test/Tug.Ext-tests-aux/FuncThingy.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | using System;
6 |
7 | namespace Tug.TestExt.Impl
8 | {
9 | public class FuncThingy : IThingy
10 | {
11 | private string _thing;
12 |
13 | public Func Func
14 | { get; set; }
15 |
16 | public bool IsDisposed
17 | { get; private set; }
18 |
19 | public void SetThing(string value)
20 | {
21 | _thing = Func(_thing);
22 | }
23 |
24 | public string GetThing()
25 | {
26 | return _thing;
27 | }
28 |
29 | #region IDisposable Support
30 |
31 | protected virtual void Dispose(bool disposing)
32 | {
33 | if (!IsDisposed)
34 | {
35 | if (disposing)
36 | {
37 | // TODO: dispose managed state (managed objects).
38 | }
39 |
40 | // TODO: free unmanaged resources (unmanaged objects) and override a finalizer below.
41 | // TODO: set large fields to null.
42 |
43 | IsDisposed = true;
44 | }
45 | }
46 |
47 | // TODO: override a finalizer only if Dispose(bool disposing) above has code to free unmanaged resources.
48 | // ~FuncThingy() {
49 | // // Do not change this code. Put cleanup code in Dispose(bool disposing) above.
50 | // Dispose(false);
51 | // }
52 |
53 | // This code added to correctly implement the disposable pattern.
54 | public void Dispose()
55 | {
56 | // Do not change this code. Put cleanup code in Dispose(bool disposing) above.
57 | Dispose(true);
58 | // TODO: uncomment the following line if the finalizer is overridden above.
59 | // GC.SuppressFinalize(this);
60 | }
61 |
62 | #endregion
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/test/Tug.Ext-tests-aux/FuncThingyProvider.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | using System;
6 | using System.Collections.Generic;
7 | using Tug.Ext;
8 |
9 | namespace Tug.TestExt.Impl
10 | {
11 | public class FuncThingyProvider : IThingyProvider
12 | {
13 | private Func _func;
14 |
15 | private static readonly ProviderInfo INFO = new ProviderInfo("func");
16 | private static readonly IEnumerable PARAMS = new[]
17 | {
18 | new ProviderParameterInfo(nameof(FuncThingy.Func),
19 | label: "Thingy Func",
20 | description: "A Func that will be applied to derive a new thingy",
21 | isRequired: true),
22 | };
23 |
24 | public ProviderInfo Describe() => INFO;
25 | public IEnumerable DescribeParameters() => PARAMS;
26 |
27 | public void SetParameters(IDictionary productParams)
28 | {
29 | if (productParams.ContainsKey(nameof(FuncThingy.Func)))
30 | throw new KeyNotFoundException("missing required parameter 'Func'");
31 |
32 | _func = (Func)productParams[nameof(FuncThingy.Func)];
33 | }
34 |
35 | public IThingy Produce()
36 | {
37 | if (_func == null)
38 | throw new InvalidOperationException("parameters have not been set");
39 |
40 | return new FuncThingy
41 | {
42 | Func = _func,
43 | };
44 | }
45 | }
46 | }
--------------------------------------------------------------------------------
/test/Tug.Ext-tests-aux/README.md:
--------------------------------------------------------------------------------
1 | # Project `Tug.Ext-tests-aux`
2 |
3 | This project is actually an auxilary library to support unit tests within the
4 | `Tug.Ext-tests` project.
5 |
6 | It's used to test out the dynamic discovery and loading features within the
7 | Tug Provider extension model and is therefore not directly refernced in the
8 | main unit test project.
9 |
--------------------------------------------------------------------------------
/test/Tug.Ext-tests-aux/Tug.Ext-tests-aux.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 0.5.0
5 | netcoreapp1.0;net452
6 | $(NoWarn);CS0169;CS0649
7 | portable
8 | Tug.Ext-tests-aux
9 | Tug.Ext-tests-aux
10 | $(PackageTargetFallback);dotnet5.4;portable-net451+win8
11 | 1.1.2
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/test/Tug.Ext-tests/README.md:
--------------------------------------------------------------------------------
1 | # Project `Tug.Ext-tests`
2 |
3 | This is a collection of unit tests over the Tug Provider extension model.
4 |
--------------------------------------------------------------------------------
/test/Tug.Ext-tests/TestExt/DynamicThingyProviderManager.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | using System.Collections.Generic;
6 | using System.Reflection;
7 | using Microsoft.Extensions.Logging;
8 |
9 | namespace Tug.TestExt
10 | {
11 | ///
12 | /// A test provider manager implementation that is based on MEF
13 | /// support for dynamica discovery and loading of provider impls.
14 | ///
15 | public class DynamicThingyProviderManager : Ext.Util.ProviderManagerBase
16 | {
17 | private static readonly ILogger LOG = new LoggerFactory()
18 | .CreateLogger();
19 |
20 | public DynamicThingyProviderManager(
21 | IEnumerable searchAssemblies = null,
22 | IEnumerable searchPaths = null,
23 | bool resetBuiltIns = false,
24 | bool resetSearchAssemblies = false,
25 | bool resetSearchPaths = false)
26 | : base(LOG)
27 | {
28 | // Check if any of the default search
29 | // collections should be cleared
30 | if (resetBuiltIns)
31 | base.ClearBuiltIns();
32 | if (resetSearchAssemblies)
33 | base.ClearSearchAssemblies();
34 | if (resetSearchPaths)
35 | base.ClearSearchPaths();
36 |
37 | // Add to the searchable assembly collection
38 | if (searchAssemblies != null)
39 | base.AddSearchAssemblies(searchAssemblies);
40 |
41 | // Add to the searchable path collection
42 | if (searchPaths != null)
43 | base.AddSearchPath(searchPaths);
44 | }
45 | }
46 | }
--------------------------------------------------------------------------------
/test/Tug.Ext-tests/TestExt/IThingy.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | namespace Tug.TestExt
6 | {
7 | public interface IThingy : Tug.Ext.IProviderProduct
8 | {
9 | void SetThing(string value);
10 |
11 | string GetThing();
12 | }
13 | }
--------------------------------------------------------------------------------
/test/Tug.Ext-tests/TestExt/IThingyProvider.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | namespace Tug.TestExt
6 | {
7 | public interface IThingyProvider : Tug.Ext.IProvider
8 | { }
9 | }
--------------------------------------------------------------------------------
/test/Tug.Ext-tests/TestExt/SimpleThingyProviderManager.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | using System.Collections.Generic;
6 |
7 | namespace Tug.TestExt
8 | {
9 | public class SimpleThingyProviderManager : Tug.Ext.IProviderManager
10 | {
11 | private IThingyProvider _provider = new Impl.BasicThingyProvider();
12 |
13 | public IEnumerable FoundProvidersNames
14 | {
15 | get
16 | {
17 | yield return "basic";
18 | }
19 | }
20 |
21 | public IThingyProvider GetProvider(string name)
22 | {
23 | if (name == "basic")
24 | return _provider;
25 |
26 | return null;
27 | }
28 | }
29 | }
--------------------------------------------------------------------------------
/test/Tug.Ext-tests/Tug.Ext-tests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 0.5.0
5 | netcoreapp1.0;net452
6 | $(NoWarn);CS0169;CS0649
7 | portable
8 | Tug.Ext-tests
9 | Tug.Ext-tests
10 | true
11 | $(PackageTargetFallback);dotnet5.4;portable-net451+win8
12 | 1.1.2
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 | $(DefineConstants);DOTNET_CORE
32 |
33 |
34 |
35 | $(DefineConstants);DOTNET_FRAMEWORK
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/test/Tug.Ext-tests/project.xunit.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "1.0.0-*",
3 | "buildOptions": {
4 | "debugType": "portable"
5 | },
6 | "dependencies": {
7 | "System.Runtime.Serialization.Primitives": "4.1.1",
8 | "xunit": "2.1.0",
9 | "dotnet-test-xunit": "1.0.0-rc2-192208-24"
10 | },
11 | "testRunner": "xunit",
12 | "frameworks": {
13 | "netcoreapp1.0": {
14 | "dependencies": {
15 | "Microsoft.NETCore.App": {
16 | "type": "platform",
17 | "version": "1.0.1"
18 | }
19 | },
20 | "imports": [
21 | "dotnet5.4",
22 | "portable-net451+win8"
23 | ]
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/test/Tug.UnitTesting/Tug.UnitTesting.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netcoreapp1.0;net452
5 | $(NoWarn);CS0169;CS0649
6 | portable
7 | Tug.UnitTesting
8 | Tug.UnitTesting
9 | $(PackageTargetFallback);dotnet5.4;portable-net451+win8
10 | 1.1.2
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/test/Tug.UnitTesting/TugAssert.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | using System;
6 | using Microsoft.VisualStudio.TestTools.UnitTesting;
7 |
8 | namespace Tug.UnitTesting
9 | {
10 | public static class TugAssert
11 | {
12 | public static void ThrowsExceptionWhen(Func condition,
13 | Action action, string message = null)
14 | where T : Exception
15 | {
16 | ThrowsExceptionWhen(condition, action, message, null);
17 | }
18 |
19 | public static void ThrowsExceptionWhen(Func condition,
20 | Action action, string message, params object[] parameters)
21 | where T : Exception
22 | {
23 | Exception expected = null;
24 | try
25 | {
26 | action();
27 | }
28 | catch (Exception ex)
29 | {
30 | expected = ex;
31 | }
32 |
33 | Assert.ThrowsException(() =>
34 | {
35 | if (expected != null) throw expected;
36 | }, message, parameters);
37 |
38 | Assert.IsTrue(condition((T)expected), message, parameters);
39 | }
40 | }
41 | }
--------------------------------------------------------------------------------
/test/client/Tug.Client-tests/Tug.Client-tests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netcoreapp1.0
5 | $(NoWarn);CS0169;CS0649
6 | portable
7 | Tug.Client-tests
8 | Tug.Client-tests
9 | true
10 | $(PackageTargetFallback);dotnet5.4;portable-net451+win8
11 | 1.1.2
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/test/client/Tug.Client-tests/test-default.cmd:
--------------------------------------------------------------------------------
1 | @SETLOCAL
2 | @SET THIS=%0
3 | @SET THIS_DIR=%~dp0
4 |
5 | @ECHO THIS=%THIS%
6 | @ECHO THIS_DIR=%THIS_DIR%
7 |
8 | dotnet test %THIS_DIR% %* -- /adjust_for_wmf_50=false
9 |
10 | @ENDLOCAL
11 |
--------------------------------------------------------------------------------
/test/client/Tug.Client-tests/test-lambda-with-fiddler.cmd:
--------------------------------------------------------------------------------
1 | @SETLOCAL
2 | @SET THIS=%0
3 | @SET THIS_DIR=%~dp0
4 |
5 | @ECHO THIS=%THIS%
6 | @ECHO THIS_DIR=%THIS_DIR%
7 | @ECHO.
8 |
9 | @REM Assuming SERVER2 is a Win2012R2 server with WMF 5.0 so we
10 | @REM don't touch the default setting of /adjust_for_wmf_50=true
11 |
12 | @SET SERVER_URL=http://DSC-SERVER2.tugnet:8080/PSDSCPullServer.svc/
13 | @SET PROXY_URL="http://localhost:8888"
14 |
15 | @IF NOT "%TUG_LAMBDA_SERVER%"=="" @GOTO :SERVER_RESOLVED
16 | @ECHO **************************************
17 | @ECHO Lambda Server endpoint is UNDEFINED!!!
18 | @ECHO Define the EnvVar TUG_LAMBDA_SERVER
19 | @ECHO **************************************
20 | @GOTO :eof
21 |
22 | :SERVER_RESOLVED
23 |
24 | @SET SERVER_URL=https://%TUG_LAMBDA_SERVER%/
25 | @SET WMF5_ADJUST=/adjust_for_wmf_50=false
26 |
27 | dotnet test %THIS_DIR% %* -- /server_url=%SERVER_URL% -- /proxy_url=%PROXY_URL%
28 |
29 | @ENDLOCAL
30 |
--------------------------------------------------------------------------------
/test/client/Tug.Client-tests/test-localhost5000.cmd:
--------------------------------------------------------------------------------
1 | @SETLOCAL
2 | @SET THIS=%0
3 | @SET THIS_DIR=%~dp0
4 |
5 | @FOR %%* IN (.) DO @SET THIS_PROJ=%%~nx*
6 |
7 | @ECHO THIS=%THIS%
8 | @ECHO THIS_DIR=%THIS_DIR%
9 | @ECHO THIS_PROJ=%THIS_PROJ%
10 | @ECHO.
11 |
12 | @REM TSTCFG_-prefixed env vars are used to convey test params
13 | @SET TSTCFG_adjust_for_wmf_50=false
14 | @SET TSTCFG_server_url=http://localhost:5000/
15 |
16 | @ECHO *** REMEMBER - WE'RE SKIPPING THE BUILD ***
17 | dotnet test %THIS_DIR%%THIS_PROJ%.csproj --no-build %*
18 |
19 | @REM dotnet test %THIS_DIR% %* -- /server_url=http://localhost:5000/ -- /adjust_for_wmf_50=false
20 |
21 | @ENDLOCAL
22 |
--------------------------------------------------------------------------------
/test/client/Tug.Client-tests/test-server1_5000-with-fiddler.cmd:
--------------------------------------------------------------------------------
1 | @SETLOCAL
2 | @SET THIS=%0
3 | @SET THIS_DIR=%~dp0
4 |
5 | @ECHO THIS=%THIS%
6 | @ECHO THIS_DIR=%THIS_DIR%
7 |
8 | dotnet test %THIS_DIR% %* -- /server_url=http://DSC-SERVER1.tugnet:5000/ -- /proxy_url="http://localhost:8888" -- /adjust_for_wmf_50=false
9 |
10 | @ENDLOCAL
11 |
--------------------------------------------------------------------------------
/test/client/Tug.Client-tests/test-server2-with-fiddler.cmd:
--------------------------------------------------------------------------------
1 | @SETLOCAL
2 | @SET THIS=%0
3 | @SET THIS_DIR=%~dp0
4 |
5 | @ECHO THIS=%THIS%
6 | @ECHO THIS_DIR=%THIS_DIR%
7 |
8 | @REM Assuming SERVER2 is a Win2012R2 server with WMF 5.0 so we
9 | @REM don't touch the default setting of /adjust_for_wmf_50=true
10 |
11 | dotnet test %THIS_DIR% %* -- /server_url=http://DSC-SERVER2.tugnet:8080/PSDSCPullServer.svc/ -- /proxy_url="http://localhost:8888"
12 |
13 | @ENDLOCAL
14 |
--------------------------------------------------------------------------------
/test/client/Tug.Client-tests/test-with-fiddler.cmd:
--------------------------------------------------------------------------------
1 | @SETLOCAL
2 | @SET THIS=%0
3 | @SET THIS_DIR=%~dp0
4 |
5 | @ECHO THIS=%THIS%
6 | @ECHO THIS_DIR=%THIS_DIR%
7 |
8 | dotnet test %THIS_DIR% %* -- /proxy_url="http://localhost:8888" -- /adjust_for_wmf_50=false
9 |
10 | @ENDLOCAL
11 |
--------------------------------------------------------------------------------
/test/client/TugDSC.Client.CLIApp-tests/TugDSC.Client.CLIApp-tests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netcoreapp2.0
5 |
6 | false
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/test/client/run-client.ps1:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env pwsh
2 |
3 | param(
4 | [Parameter(Mandatory)]
5 | [ValidateSet(
6 | 'netcore')]
7 | [string]$RunProfile,
8 |
9 | [ValidateSet(
10 | 'netcoreapp2.0',
11 | 'net461')]
12 | $Framework = 'netcoreapp2.0'
13 | )
14 |
15 | $runProfilePath = [System.IO.Path]::Combine($PSScriptRoot, "run-profiles/$($RunProfile)")
16 | $jsonFile = [System.IO.Path]::Combine($runProfilePath, "appsettings.json")
17 |
18 | $runProjName = "TugDSC.Client.CLIApp"
19 | $runProjRoot = [System.IO.Path]::Combine($PSScriptRoot, "..\..\src\$($runProjName)")
20 |
21 | try {
22 | Push-Location $runProfilePath
23 | & dotnet run -p $runProjRoot -f $Framework --config $jsonFile
24 | }
25 | finally {
26 | Pop-Location
27 | }
28 |
--------------------------------------------------------------------------------
/test/client/run-profiles/netcore/appsettings.json:
--------------------------------------------------------------------------------
1 | {
2 | // Allows to add additional optional overriding configs
3 | "AddJsonFile": "_IGNORE/appsettings.local.json",
4 |
5 | "AgentId": "67217804-cc0b-4836-a396-5cc67eb9672e",
6 |
7 | // Alternatively, populate with all values manually
8 | // "AgentInformation": {
9 | // "LCMVersion": "2.0",
10 | // "NodeName": "MyHostName",
11 | // "IPAddress": "10.10.10.10;127.0.0.1;fe80::0123:4567:890a:55e9%6;::2000:0:0:0;::1;::2000:0:0:0"
12 | // },
13 |
14 | // For now, this can only have one element
15 | "ConfigurationNames": [
16 | "ClientConfig"
17 | ],
18 |
19 | // Cert info is a *MUS* when using RegKey authorization
20 | "CertificateInformation": {
21 | "FriendlyName": "DSC-OaaS Client Authentication",
22 | "Issuer": "CN=DSC-OaaS",
23 | "NotBefore": "2016-12-21T11:40:36.0000000-05:00",
24 | "NotAfter": "2017-12-21T11:40:36.0000000-05:00",
25 | "Subject": "CN=DSC-OaaS",
26 | "PublicKey": "U3lzdGVtLlNlY3VyaXR5LkNyeXB0b2dyYXBoeS5YNTA5Q2VydGlmaWNhdGVzLlB1YmxpY0tleQ==",
27 | "Thumbprint": "C0287B5430452DA1CD948351F16C2B06634279F2",
28 | "Version": 3
29 | },
30 |
31 | "ConfigurationRepositoryServer": {
32 | // OVERRIDE this with a Local Config File, Env Variable OR CLI Parameter
33 | // or make sure the DNS name resolves to a compatible DSC Pull Server
34 | "ServerUrl": "http://dsc-server:8080/PSDSCPullServer.svc/",
35 | "RegistrationKey": "00000000-0000-0000-0000-000000000000"
36 |
37 | // // Construct a proxy for dev/debugging via Fiddler
38 | // ,
39 | // "Proxy": {
40 | // "TypeName": "Tug.Client.Util.BasicWebProxy, Tug.Client",
41 | // "Instance": {
42 | // "ProxyAddress": "http://localhost:8888"
43 | // }
44 | // }
45 | }
46 | }
--------------------------------------------------------------------------------
/test/server/Tug.Server-itests/BasicPullHandlerRoot/Configuration/SHARED/FYI/StaticTestConfig.dsc.ps1:
--------------------------------------------------------------------------------
1 | Configuration StaticTestConfig {
2 |
3 | Node StaticTestConfig {
4 | File TempDir {
5 | Ensure = 'Present'
6 | Type = 'Directory'
7 | DestinationPath = 'c:\temp'
8 | }
9 |
10 | File TempFile {
11 | DependsOn = "[File]TempDir"
12 | Ensure = 'Present'
13 | Type = 'File'
14 | DestinationPath = 'c:\temp\dsc-statictestconfig-file.txt'
15 | Contents = 'STATIC TEST CONFIG'
16 | }
17 | }
18 | }
19 |
20 | StaticTestConfig
21 |
22 | Publish-MOFToPullServer -PullServerWebConfig C:\DscService\WebSite\web.config -FullName .\StaticTestConfig\StaticTestConfig.mof -Verbose
23 |
--------------------------------------------------------------------------------
/test/server/Tug.Server-itests/BasicPullHandlerRoot/Configuration/SHARED/FYI/StaticTestConfig.mof.checksum:
--------------------------------------------------------------------------------
1 | 75D3763E4FFE0ED9CFE17F9EE915F1B81FE06E9B6D2287B09561565D61D1009C
--------------------------------------------------------------------------------
/test/server/Tug.Server-itests/BasicPullHandlerRoot/Configuration/SHARED/StaticTestConfig.mof:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PowerShellOrg/tug/aab51f407b92475ae64cc14a0dea33d459fe9885/test/server/Tug.Server-itests/BasicPullHandlerRoot/Configuration/SHARED/StaticTestConfig.mof
--------------------------------------------------------------------------------
/test/server/Tug.Server-itests/BasicPullHandlerRoot/Modules/xPSDesiredStateConfiguration/5.1.0.0.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PowerShellOrg/tug/aab51f407b92475ae64cc14a0dea33d459fe9885/test/server/Tug.Server-itests/BasicPullHandlerRoot/Modules/xPSDesiredStateConfiguration/5.1.0.0.zip
--------------------------------------------------------------------------------
/test/server/Tug.Server-itests/BasicPullHandlerRoot/Modules/xPSDesiredStateConfiguration/FYI/5.1.0.0.zip.checksum:
--------------------------------------------------------------------------------
1 | 8FB19218B06E212F1FF251B6F8DE0B261DF3806F0FFD545090E3265A481A9716
--------------------------------------------------------------------------------
/test/server/Tug.Server-itests/BasicPullHandlerRoot/RegKeys/RegistrationKeys.txt:
--------------------------------------------------------------------------------
1 | c3ea5066-ce5a-4d12-a42a-850be287b2d8
2 |
--------------------------------------------------------------------------------
/test/server/Tug.Server-itests/IntegTestDscHandler.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Tug.Server.Providers
4 | {
5 | public class IntegTestDscHandler : BasicDscHandler
6 | {
7 | public IntegTestDscHandler()
8 | {
9 | Console.WriteLine("CONSTRUCTING INTEG-TEST HANDLER");
10 | }
11 | }
12 | }
--------------------------------------------------------------------------------
/test/server/Tug.Server-itests/IntegTestDscHandlerProvider.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Microsoft.Extensions.Logging;
3 | using Tug.Ext;
4 | using Tug.Server.Util;
5 |
6 | namespace Tug.Server.Providers
7 | {
8 | public class IntegTestDscHandlerProvider : BasicDscHandlerProvider
9 | {
10 | private static readonly ProviderInfo MY_INFO = new ProviderInfo("integTest");
11 |
12 | public override ProviderInfo Describe() => MY_INFO;
13 |
14 | public IntegTestDscHandlerProvider(
15 | ILogger pLogger,
16 | ILogger hLogger,
17 | ChecksumAlgorithmManager checksumManager,
18 | ChecksumHelper checksumHelper)
19 | : base(pLogger, hLogger, checksumManager, checksumHelper)
20 | {
21 | Console.WriteLine("CONSTRUCTING INTEG-TEST HANDLER PROVIDER");
22 | }
23 |
24 | protected override BasicDscHandler ConstructHandler()
25 | {
26 | return new IntegTestDscHandler();
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/test/server/Tug.Server-itests/appsettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "logSettings": {
3 | "LogType": "nlog",
4 | "DebugLog": "true"
5 | },
6 | "appSettings": {
7 | "checksum": {
8 | "default": "SHA-256"
9 | },
10 |
11 | "authz": {
12 | "params": {
13 | "RegistrationKeyPath": "BasicPullHandlerRoot/RegKeys",
14 | "RegistrationSavePath": "BasicPullHandlerRoot/Registrations"
15 | }
16 | },
17 |
18 | // Enable this setup to use the BASIC DSC Handler
19 | "handler": {
20 | // The default provider is "basic" but we're going
21 | // going to use a specialized subclass that we've
22 | // built specifically to support our testing
23 | "provider": "integTest",
24 |
25 | // Our specialized handler inherits all the base features
26 | // of the "basic" pull handler including parameters
27 | "params": {
28 | // For testing purposes, we redefine these to make sure they get
29 | // placed under the _IGNORE subfolder so they are ignored by Git
30 | "RegistrationKeyPath": "BasicPullHandlerRoot/RegKeys",
31 | "RegistrationSavePath": "BasicPullHandlerRoot/Registrations",
32 | "ConfigurationPath": "BasicPullHandlerRoot/Configuration",
33 | "ModulePath": "BasicPullHandlerRoot/Modules",
34 | "ReportsPath": "BasicPullHandlerRoot/Reports"
35 | }
36 | }
37 | }
38 | }
--------------------------------------------------------------------------------
/test/server/Tug.Server-itests/project.json.ORIG:
--------------------------------------------------------------------------------
1 | {
2 | "version": "1.0.0-*",
3 | "buildOptions": {
4 | "debugType": "portable"
5 | },
6 | "dependencies": {
7 | "System.Runtime.Serialization.Primitives": "4.1.1",
8 | "xunit": "2.1.0",
9 | "dotnet-test-xunit": "1.0.0-rc2-192208-24"
10 | },
11 | "testRunner": "xunit",
12 | "frameworks": {
13 | "netcoreapp1.0": {
14 | "dependencies": {
15 | "Microsoft.NETCore.App": {
16 | "type": "platform",
17 | "version": "1.0.1"
18 | }
19 | },
20 | "imports": [
21 | "dotnet5.4",
22 | "portable-net451+win8"
23 | ]
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/test/server/Tug.Server-itests/test-framework-net462.cmd:
--------------------------------------------------------------------------------
1 | @SETLOCAL
2 | @SET THIS=%0
3 | @SET THIS_DIR=%~dp0
4 |
5 | @FOR %%* IN (.) DO @SET THIS_PROJ=%%~nx*
6 |
7 | @ECHO THIS=%THIS%
8 | @ECHO THIS_DIR=%THIS_DIR%
9 | @ECHO THIS_PROJ=%THIS_PROJ%
10 | @ECHO.
11 |
12 | @ECHO *** REMEMBER - WE'RE SKIPPING THE BUILD ***
13 | dotnet test %THIS_DIR%%THIS_PROJ%.csproj --no-build -f net462 %*
14 |
15 | @ENDLOCAL
16 |
--------------------------------------------------------------------------------
/test/server/Tug.Server.FaaS.AwsLambda-tests/SampleRequests/Get-Base.json:
--------------------------------------------------------------------------------
1 | {
2 | "resource": "/{proxy+}",
3 | "path": "/TO-BE-REPLACED",
4 | "httpMethod": "GET",
5 | "headers": null,
6 | "queryStringParameters": null,
7 | "pathParameters": {
8 | "proxy": "api/values"
9 | },
10 | "stageVariables": null,
11 | "requestContext": {
12 | "accountId": "AAAAAAAAAAAA",
13 | "resourceId": "5agfss",
14 | "stage": "test-invoke-stage",
15 | "requestId": "test-invoke-request",
16 | "identity": {
17 | "cognitoIdentityPoolId": null,
18 | "accountId": "AAAAAAAAAAAA",
19 | "cognitoIdentityId": null,
20 | "caller": "BBBBBBBBBBBB",
21 | "apiKey": "test-invoke-api-key",
22 | "sourceIp": "test-invoke-source-ip",
23 | "cognitoAuthenticationType": null,
24 | "cognitoAuthenticationProvider": null,
25 | "userArn": "arn:aws:iam::AAAAAAAAAAAA:root",
26 | "userAgent": "Apache-HttpClient/4.5.x (Java/1.8.0_102)",
27 | "user": "AAAAAAAAAAAA"
28 | },
29 | "resourcePath": "/{proxy+}",
30 | "httpMethod": "GET",
31 | "apiId": "t2yh6sjnmk"
32 | },
33 | "body": null
34 | }
--------------------------------------------------------------------------------
/test/server/Tug.Server.FaaS.AwsLambda-tests/SampleRequests/Get-Default.json:
--------------------------------------------------------------------------------
1 | {
2 | "resource": "/{proxy+}",
3 | "path": "/", //api/values",
4 | "httpMethod": "GET",
5 | "headers": null,
6 | "queryStringParameters": null,
7 | "pathParameters": {
8 | "proxy": "api/values"
9 | },
10 | "stageVariables": null,
11 | "requestContext": {
12 | "accountId": "AAAAAAAAAAAA",
13 | "resourceId": "5agfss",
14 | "stage": "test-invoke-stage",
15 | "requestId": "test-invoke-request",
16 | "identity": {
17 | "cognitoIdentityPoolId": null,
18 | "accountId": "AAAAAAAAAAAA",
19 | "cognitoIdentityId": null,
20 | "caller": "BBBBBBBBBBBB",
21 | "apiKey": "test-invoke-api-key",
22 | "sourceIp": "test-invoke-source-ip",
23 | "cognitoAuthenticationType": null,
24 | "cognitoAuthenticationProvider": null,
25 | "userArn": "arn:aws:iam::AAAAAAAAAAAA:root",
26 | "userAgent": "Apache-HttpClient/4.5.x (Java/1.8.0_102)",
27 | "user": "AAAAAAAAAAAA"
28 | },
29 | "resourcePath": "/{proxy+}",
30 | "httpMethod": "GET",
31 | "apiId": "t2yh6sjnmk"
32 | },
33 | "body": null
34 | }
--------------------------------------------------------------------------------
/test/server/Tug.Server.FaaS.AwsLambda-tests/Tug.Server.FaaS.AwsLambda-tests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netcoreapp1.0
5 | Tug.Server.FaaS.AwsLambda-tests
6 | Tug.Server.FaaS.AwsLambda-tests
7 | true
8 | 1.1.2
9 | $(PackageTargetFallback);dnxcore50;portable-net45+win8
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/test/server/Tug.Server.FaaS.AwsLambda-tests/appsettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "AWS": {
3 | "Profile": "tug-deploy@tug-aws",
4 | "Region": "us-east-1"
5 | }
6 | }
--------------------------------------------------------------------------------
/test/server/TugDSC.Server-tests/BasicPullHandlerRoot/Configuration/SHARED/FYI/StaticTestConfig.dsc.ps1:
--------------------------------------------------------------------------------
1 | Configuration StaticTestConfig {
2 |
3 | Node StaticTestConfig {
4 | File TempDir {
5 | Ensure = 'Present'
6 | Type = 'Directory'
7 | DestinationPath = 'c:\temp'
8 | }
9 |
10 | File TempFile {
11 | DependsOn = "[File]TempDir"
12 | Ensure = 'Present'
13 | Type = 'File'
14 | DestinationPath = 'c:\temp\dsc-statictestconfig-file.txt'
15 | Contents = 'STATIC TEST CONFIG'
16 | }
17 | }
18 | }
19 |
20 | StaticTestConfig
21 |
22 | Publish-MOFToPullServer -PullServerWebConfig C:\DscService\WebSite\web.config -FullName .\StaticTestConfig\StaticTestConfig.mof -Verbose
23 |
--------------------------------------------------------------------------------
/test/server/TugDSC.Server-tests/BasicPullHandlerRoot/Configuration/SHARED/FYI/StaticTestConfig.mof.checksum:
--------------------------------------------------------------------------------
1 | 75D3763E4FFE0ED9CFE17F9EE915F1B81FE06E9B6D2287B09561565D61D1009C
--------------------------------------------------------------------------------
/test/server/TugDSC.Server-tests/BasicPullHandlerRoot/Configuration/SHARED/StaticTestConfig.mof:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PowerShellOrg/tug/aab51f407b92475ae64cc14a0dea33d459fe9885/test/server/TugDSC.Server-tests/BasicPullHandlerRoot/Configuration/SHARED/StaticTestConfig.mof
--------------------------------------------------------------------------------
/test/server/TugDSC.Server-tests/BasicPullHandlerRoot/Modules/xPSDesiredStateConfiguration/5.1.0.0.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PowerShellOrg/tug/aab51f407b92475ae64cc14a0dea33d459fe9885/test/server/TugDSC.Server-tests/BasicPullHandlerRoot/Modules/xPSDesiredStateConfiguration/5.1.0.0.zip
--------------------------------------------------------------------------------
/test/server/TugDSC.Server-tests/BasicPullHandlerRoot/Modules/xPSDesiredStateConfiguration/FYI/5.1.0.0.zip.checksum:
--------------------------------------------------------------------------------
1 | 8FB19218B06E212F1FF251B6F8DE0B261DF3806F0FFD545090E3265A481A9716
--------------------------------------------------------------------------------
/test/server/TugDSC.Server-tests/BasicPullHandlerRoot/RegKeys/RegistrationKeys.txt:
--------------------------------------------------------------------------------
1 | c3ea5066-ce5a-4d12-a42a-850be287b2d8
2 |
--------------------------------------------------------------------------------
/test/server/TugDSC.Server-tests/IntegTestDscHandler.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace TugDSC.Server.Providers
4 | {
5 | public class IntegTestDscHandler : BasicDscHandler
6 | {
7 | public IntegTestDscHandler()
8 | {
9 | Console.WriteLine("CONSTRUCTING INTEG-TEST HANDLER");
10 | }
11 | }
12 | }
--------------------------------------------------------------------------------
/test/server/TugDSC.Server-tests/IntegTestDscHandlerProvider.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Microsoft.Extensions.Logging;
3 | using TugDSC.Ext;
4 | using TugDSC.Server.Util;
5 |
6 | namespace TugDSC.Server.Providers
7 | {
8 | public class IntegTestDscHandlerProvider : BasicDscHandlerProvider
9 | {
10 | private static readonly ProviderInfo MY_INFO = new ProviderInfo("integTest");
11 |
12 | public override ProviderInfo Describe() => MY_INFO;
13 |
14 | public IntegTestDscHandlerProvider(
15 | ILogger pLogger,
16 | ILogger hLogger,
17 | ChecksumAlgorithmManager checksumManager,
18 | ChecksumHelper checksumHelper)
19 | : base(pLogger, hLogger, checksumManager, checksumHelper)
20 | {
21 | Console.WriteLine("CONSTRUCTING INTEG-TEST HANDLER PROVIDER");
22 | }
23 |
24 | protected override BasicDscHandler ConstructHandler()
25 | {
26 | return new IntegTestDscHandler();
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/test/server/TugDSC.Server-tests/TugDSC.Server-tests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netcoreapp2.0
5 |
6 | false
7 |
8 |
9 |
10 |
11 | PreserveNewest
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/test/server/TugDSC.Server-tests/appsettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "logSettings": {
3 | "LogType": "nlog",
4 | "DebugLog": "true"
5 | },
6 | "appSettings": {
7 | "checksum": {
8 | "default": "SHA-256"
9 | },
10 |
11 | "authz": {
12 | "params": {
13 | "RegistrationKeyPath": "BasicPullHandlerRoot/RegKeys",
14 | "RegistrationSavePath": "BasicPullHandlerRoot/Registrations"
15 | }
16 | },
17 |
18 | // Enable this setup to use the BASIC DSC Handler
19 | "handler": {
20 | // The default provider is "basic" but we're going
21 | // going to use a specialized subclass that we've
22 | // built specifically to support our testing
23 | "provider": "integTest",
24 |
25 | // Our specialized handler inherits all the base features
26 | // of the "basic" pull handler including parameters
27 | "params": {
28 | // For testing purposes, we redefine these to make sure they get
29 | // placed under the _IGNORE subfolder so they are ignored by Git
30 | "RegistrationKeyPath": "BasicPullHandlerRoot/RegKeys",
31 | "RegistrationSavePath": "BasicPullHandlerRoot/Registrations",
32 | "ConfigurationPath": "BasicPullHandlerRoot/Configuration",
33 | "ModulePath": "BasicPullHandlerRoot/Modules",
34 | "ReportsPath": "BasicPullHandlerRoot/Reports"
35 | }
36 | }
37 | }
38 | }
--------------------------------------------------------------------------------
/test/server/ext/README.md:
--------------------------------------------------------------------------------
1 | # Testing `TugDSC.Ext`
2 |
3 | This folder contains a collection of projects supporting testing of the TugDSC extension model.
4 |
5 | We define a *fake* extension hierarchy sample in the `Sample.TestExt` namespace.
6 |
7 | There are two supporting library projects:
8 |
9 | * `Sample.TestExt.Thingy` - defines the extension interface and its corresponding provider;
10 | also defines a default implementation (`basic`)
11 | * `Sample.TestExt.DynamicThingy` - defines a second implementation of the extension interface
12 | and associated provider to be used for dynamic discovery and loading (`dynaThingy`).
13 |
14 | Across these two projects, the hierarchy of components is as follows:
15 |
16 | * `Sample.TestExt.Thingy`:
17 | * `IThingy`
18 | * `IThingyProvider`
19 | * `SimpleThingyProviderManager` - a provider manager that tests out static
20 | references (build-time) to extension
21 | * `DynamicThingyProviderManager` - a provider manager that tests out dynamic
22 | discovery and loading of extensions
23 |
24 | * `Sample.TestExt.Thingy.Impl`:
25 | * `BasicThingy`
26 | * `BasicThingyProvider`
27 |
28 | * `Sample.TestExt.DynamicThingy.Impl`:
29 | * `DynamicThingy`
30 | * `DynamicThingyProvider`
31 |
32 |
33 | The main testing project `TugDSC.Ext-tests` has an explicit, build-time project reference
34 | to the `Sample.TestExt.Thingy` library project and no reference at all to the
35 | `Sample.TestExt.DynamicThingy` library project.
36 |
37 | The first set of tests all focus on verifying the core functions of discovery and resolution
38 | against the statically referenced provider (`basic`).
39 |
40 | The latter set of tests add dynamic paths and library references to the second implementation
41 | (`dynaThingy`) to test out dynamic discovery and load features.
42 |
--------------------------------------------------------------------------------
/test/server/ext/Sample.TestExt.DynamicThingy/DynamicThingyProvider.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | using System;
6 | using System.Collections.Generic;
7 | using Sample.TestExt.Thingy;
8 | using TugDSC.Ext;
9 |
10 | namespace Sample.TestExt.DynamicThingy.Impl
11 | {
12 | public class DynamicThingyProvider : IThingyProvider
13 | {
14 | private Func _func;
15 |
16 | private static readonly ProviderInfo INFO = new ProviderInfo("dynaThingy");
17 | private static readonly IEnumerable PARAMS = new[]
18 | {
19 | new ProviderParameterInfo(nameof(DynamicThingy.Func),
20 | label: "Thingy Func",
21 | description: "A Func that will be applied to derive a new thingy",
22 | isRequired: true),
23 | };
24 |
25 | public ProviderInfo Describe() => INFO;
26 | public IEnumerable DescribeParameters() => PARAMS;
27 |
28 | public void SetParameters(IDictionary productParams)
29 | {
30 | if (productParams.ContainsKey(nameof(DynamicThingy.Func)))
31 | throw new KeyNotFoundException("missing required parameter 'Func'");
32 |
33 | _func = (Func)productParams[nameof(DynamicThingy.Func)];
34 | }
35 |
36 | public IThingy Produce()
37 | {
38 | if (_func == null)
39 | throw new InvalidOperationException("parameters have not been set");
40 |
41 | return new DynamicThingy
42 | {
43 | Func = _func,
44 | };
45 | }
46 | }
47 | }
--------------------------------------------------------------------------------
/test/server/ext/Sample.TestExt.DynamicThingy/Sample.TestExt.DynamicThingy.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/test/server/ext/Sample.TestExt.Thingy/DynamicThingyProviderManager.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | using System.Collections.Generic;
6 | using System.Reflection;
7 | using Microsoft.Extensions.Logging;
8 | using TugDSC.Ext.Util;
9 |
10 | namespace Sample.TestExt.Thingy
11 | {
12 | ///
13 | /// A test provider manager implementation that is based on MEF
14 | /// support for dynamic discovery and loading of provider implementations.
15 | ///
16 | public class DynamicThingyProviderManager : ProviderManagerBase
17 | {
18 | private static readonly ILogger LOG = new LoggerFactory()
19 | .CreateLogger();
20 |
21 | public DynamicThingyProviderManager(
22 | IEnumerable searchAssemblies = null,
23 | IEnumerable searchPaths = null,
24 | bool resetBuiltIns = false,
25 | bool resetSearchAssemblies = false,
26 | bool resetSearchPaths = false)
27 | : base(LOG)
28 | {
29 | // Check if any of the default search
30 | // collections should be cleared
31 | if (resetBuiltIns)
32 | base.ClearBuiltIns();
33 | if (resetSearchAssemblies)
34 | base.ClearSearchAssemblies();
35 | if (resetSearchPaths)
36 | base.ClearSearchPaths();
37 |
38 | // Add to the searchable assembly collection
39 | if (searchAssemblies != null)
40 | base.AddSearchAssemblies(searchAssemblies);
41 |
42 | // Add to the searchable path collection
43 | if (searchPaths != null)
44 | base.AddSearchPath(searchPaths);
45 | }
46 | }
47 | }
--------------------------------------------------------------------------------
/test/server/ext/Sample.TestExt.Thingy/IThingy.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | namespace Sample.TestExt.Thingy
6 | {
7 | public interface IThingy : TugDSC.Ext.IProviderProduct
8 | {
9 | void SetThing(string value);
10 |
11 | string GetThing();
12 | }
13 | }
--------------------------------------------------------------------------------
/test/server/ext/Sample.TestExt.Thingy/IThingyProvider.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | namespace Sample.TestExt.Thingy
6 | {
7 | public interface IThingyProvider : TugDSC.Ext.IProvider
8 | { }
9 | }
--------------------------------------------------------------------------------
/test/server/ext/Sample.TestExt.Thingy/Sample.TestExt.Thingy.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/test/server/ext/Sample.TestExt.Thingy/SimpleThingyProviderManager.cs:
--------------------------------------------------------------------------------
1 | // PowerShell.org Tug DSC Pull Server
2 | // Copyright (c) The DevOps Collective, Inc. All rights reserved.
3 | // Licensed under the MIT license. See the LICENSE file in the project root for more information.
4 |
5 | using System.Collections.Generic;
6 |
7 | namespace Sample.TestExt.Thingy
8 | {
9 | public class SimpleThingyProviderManager : TugDSC.Ext.IProviderManager
10 | {
11 | private IThingyProvider _provider = new Impl.BasicThingyProvider();
12 |
13 | public IEnumerable FoundProvidersNames
14 | {
15 | get
16 | {
17 | yield return "basic";
18 | }
19 | }
20 |
21 | public IThingyProvider GetProvider(string name)
22 | {
23 | if (name == "basic")
24 | return _provider;
25 |
26 | return null;
27 | }
28 | }
29 | }
--------------------------------------------------------------------------------
/test/server/ext/TugDSC.Ext-tests/TugDSC.Ext-tests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
6 | netcoreapp2.0;net461
7 |
8 | false
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/test/server/misc/TugDSC.Configuration-tests/TugDSC.Configuration-tests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netcoreapp2.0
5 |
6 | false
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/test/server/misc/TugDSC.Configuration-tests/test1.json:
--------------------------------------------------------------------------------
1 | {
2 | "StrKey": "StrVal",
3 |
4 | "IntKey1": 199,
5 | "IntKey2": "299",
6 |
7 | "BoolKey1": true,
8 | "BoolKey2": "true",
9 |
10 | "StrListKey": [
11 | "One",
12 | "Two",
13 | "Three"
14 | ],
15 |
16 | "Type1Key0": {
17 | "S1": "s1Value",
18 | "I1": "499",
19 | "B1": "true"
20 | },
21 |
22 | "Type1Key1": {
23 | "$type": "TugDSC.Configuration.Tests.OfTypeTests+Type2, TugDSC.Configuration-tests",
24 | "S1": "s1Value",
25 | "I1": "499",
26 | "B1": "true",
27 |
28 | "ValueGetter": {
29 | "$type": "TugDSC.Configuration.Tests.OfTypeTests+BasicValueGetter, TugDSC.Configuration-tests",
30 | "Value": "FooBar"
31 | }
32 | },
33 |
34 | "Type1Key2": {
35 | "$type": "TugDSC.Configuration.Tests.OfTypeTests+Type2, TugDSC.Configuration-tests",
36 | "S1": "s1Value",
37 | "I1": "499",
38 | "B1": "true",
39 |
40 | "ValueGetter": {
41 | "$type": "TugDSC.Configuration.Tests.OfTypeTests+ToUpperValueGetter, TugDSC.Configuration-tests",
42 | "Value": "FooBar"
43 | }
44 | }
45 | }
--------------------------------------------------------------------------------
/test/server/run-profiles/net461/appsettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "logSettings": {
3 | "LogType": "nlog",
4 | "DebugLog": "true"
5 | },
6 | "appSettings": {
7 | "checksum": {
8 | "default": "SHA-256"
9 | },
10 |
11 | "authz": {
12 | "params": {
13 | // This is where we look for the file containing reg keys,
14 | // which is named "RegistrationKeys.txt" by default. In this
15 | // file we look for non-blank lines after removing any comments
16 | // starting with the '#' character and trimming from both ends
17 | "RegistrationKeyPath": "_IGNORE/DscService/Authz",
18 | // We keep our own copy of registrations that is separate from
19 | // those saved by the Pull Handler down below which is strictly
20 | // for authz purposes -- these may overlap but could cause conflicts
21 | "RegistrationSavePath": "_IGNORE/DscService/Authz/Registrations"
22 | }
23 | },
24 |
25 | // Enable this setup to use the BASIC DSC Handler
26 | "handler": {
27 | // No need for "provider" as it defaults to "basic"
28 | // "provider": "basic",
29 | "params": {
30 | // For testing purposes, we redefine these to make sure they get
31 | // placed under the _IGNORE subfolder so they are ignored by Git
32 | "RegistrationSavePath": "_IGNORE/DscService/Registrations",
33 | "ConfigurationPath": "_IGNORE/DscService/Configuration",
34 | "ModulePath": "_IGNORE/DscService/Modules",
35 | "ReportsPath": "_IGNORE/DscService/Reports"
36 | }
37 | }
38 | }
39 | }
--------------------------------------------------------------------------------
/test/server/run-profiles/netcore/appsettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "logSettings": {
3 | "LogType": "nlog",
4 | "DebugLog": "true"
5 | },
6 | "appSettings": {
7 | "checksum": {
8 | "ext": {
9 | // TODO: Temporary to resolve deps
10 | "replaceExtAssemblies": true,
11 | "searchAssemblies": [
12 | "..\\..\\..\\..\\src\\TugDSC.Server.WebAppHost\\bin\\Debug\\netcoreapp2.0\\TugDSC.Server.WebAppHost.dll"
13 | ]
14 | },
15 | "default": "SHA-256"
16 | },
17 |
18 | // Enable this setup to use the BASIC DSC Handler
19 | "handler": {
20 | // No need for "provider" as it defaults to "basic"
21 | // "provider": "basic",
22 | "params": {
23 | // For testing purposes, we redefine these to make sure they get
24 | // placed under the _IGNORE subfolder so they are ignored by Git
25 | "RegistrationKeyPath": "_IGNORE/DscService",
26 | "RegistrationSavePath": "_IGNORE/DscService/Registrations",
27 | "ConfigurationPath": "_IGNORE/DscService/Configuration",
28 | "ModulePath": "_IGNORE/DscService/Modules"
29 | }
30 | }
31 | }
32 | }
--------------------------------------------------------------------------------
/test/server/run-server.ps1:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env pwsh
2 |
3 | param(
4 | [Parameter(Mandatory)]
5 | [ValidateSet(
6 | 'netcore',
7 | 'net461')]
8 | [string]$RunProfile,
9 |
10 | # [ValidateSet(
11 | # 'netcoreapp2.0',
12 | # 'net461')]
13 | # $Framework = 'netcoreapp2.0'
14 |
15 | [switch]$Restart
16 | )
17 |
18 | $runProfilePath = [System.IO.Path]::Combine($PSScriptRoot, "run-profiles/$($RunProfile)")
19 | $jsonFile = [System.IO.Path]::Combine($runProfilePath, "appsettings.json")
20 |
21 | $runProjName = "TugDSC.Server.WebAppHost"
22 | $runProjRoot = [System.IO.Path]::Combine($PSScriptRoot, "..\..\src\$($runProjName)")
23 |
24 |
25 | if ($Restart) {
26 | try {
27 | Write-Warning "Looking for existing process [$($runProjName)]"
28 | Get-Process -Name $runProjName -ErrorAction Stop
29 | Write-Warning "Stopping existing process [$($runProjName)]"
30 | Stop-Process -Name $runProjName
31 | }
32 | catch {}
33 | }
34 |
35 |
36 | $fw = 'netcoreapp2.0'
37 | switch ($RunProfile) {
38 | 'netcore' {
39 | }
40 | 'net461' {
41 | $fw = 'net461'
42 | }
43 | 'net461-ps5' {
44 | $fw = 'net461'
45 | }
46 | }
47 |
48 | try {
49 | Push-Location $runProfilePath
50 | & dotnet run -p $runProjRoot -f $fw --config=$jsonFile
51 | }
52 | finally {
53 | Pop-Location
54 | }
55 |
--------------------------------------------------------------------------------
/tools/ci/DSC/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore all the generated MOF files of child config folders
2 | ## Note, this will *NOT* ignore any MOF files that are in the
3 | ## immediately current folder, such as fixed static MOF files
4 | */*.mof
5 |
--------------------------------------------------------------------------------
/tools/ci/DSC/DscCommon.ps1:
--------------------------------------------------------------------------------
1 | $dscServicePath = 'C:\DscService'
2 | $regKeyDirPath = "$dscServicePath\RegKeys"
3 | $regKeyPath = "$regKeyDirPath\RegistrationKeys.txt"
4 | $webSitePath = "$dscServicePath\WebSite"
5 | $modulePath = "$dscServicePath\Modules"
6 | $configPath = "$dscServicePath\Configurations"
7 | $dbPath = "$dscServicePath\Data\DB"
8 |
--------------------------------------------------------------------------------
/tools/ci/DSC/StaticTestConfig-copy.ps1:
--------------------------------------------------------------------------------
1 | <#
2 | # PowerShell.org Tug DSC Pull Server
3 | # Copyright (c) The DevOps Collective, Inc. All rights reserved.
4 | # Licensed under the MIT license. See the LICENSE file in the project root for more information.
5 | #>
6 |
7 | ## The StaticTestConfig DSC configuration is meant to be used
8 | ## exactly as-is, that is the MOF and checksum files are NOT
9 | ## meant to be published/computed, but copied to the target
10 | ## DSC Pull Servers config repo so that we can perform Unit
11 | ## Tests that are validating expected content
12 |
13 | . "$PSScriptRoot\DscCommon.ps1"
14 |
15 | copy "$PSScriptRoot\StaticTestConfig.mof" $configPath
16 | copy "$PSScriptRoot\StaticTestConfig.mof.checksum" $configPath
17 |
--------------------------------------------------------------------------------
/tools/ci/DSC/StaticTestConfig.dsc.ps1:
--------------------------------------------------------------------------------
1 | Configuration StaticTestConfig {
2 |
3 | Node StaticTestConfig {
4 | File TempDir {
5 | Ensure = 'Present'
6 | Type = 'Directory'
7 | DestinationPath = 'c:\temp'
8 | }
9 |
10 | File TempFile {
11 | DependsOn = "[File]TempDir"
12 | Ensure = 'Present'
13 | Type = 'File'
14 | DestinationPath = 'c:\temp\dsc-statictestconfig-file.txt'
15 | Contents = 'STATIC TEST CONFIG'
16 | }
17 | }
18 | }
19 |
20 | StaticTestConfig
21 |
22 | Publish-MOFToPullServer -PullServerWebConfig C:\DscService\WebSite\web.config -FullName .\StaticTestConfig\StaticTestConfig.mof -Verbose
23 |
--------------------------------------------------------------------------------
/tools/ci/DSC/StaticTestConfig.mof:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PowerShellOrg/tug/aab51f407b92475ae64cc14a0dea33d459fe9885/tools/ci/DSC/StaticTestConfig.mof
--------------------------------------------------------------------------------
/tools/ci/DSC/StaticTestConfig.mof.checksum:
--------------------------------------------------------------------------------
1 | 75D3763E4FFE0ED9CFE17F9EE915F1B81FE06E9B6D2287B09561565D61D1009C
--------------------------------------------------------------------------------
/tools/ci/DSC/TestConfig1.dsc.ps1:
--------------------------------------------------------------------------------
1 | <#
2 | # PowerShell.org Tug DSC Pull Server
3 | # Copyright (c) The DevOps Collective, Inc. All rights reserved.
4 | # Licensed under the MIT license. See the LICENSE file in the project root for more information.
5 | #>
6 |
7 | ## This DSC configuration is used by the unit tests to verify
8 | ## protocol compatibility between the Tug.Client library and
9 | ## a DSC Pull Server v2. It is published to a DSC Pull Server
10 | ## setup by the configuration settings in DscPullServer.dsc.ps1
11 |
12 | . "$PSScriptRoot\DscCommon.ps1"
13 |
14 | Configuration TestConfig1 {
15 |
16 | Import-DscResource -ModuleName 'PSDesiredStateConfiguration'
17 |
18 | Node TestConfig1 {
19 | File TempDir {
20 | Ensure = 'Present'
21 | Type = 'Directory'
22 | DestinationPath = 'c:\temp'
23 | }
24 |
25 | File TempFile {
26 | DependsOn = "[File]TempDir"
27 | Ensure = 'Present'
28 | Type = 'File'
29 | DestinationPath = 'c:\temp\tug-testconfig1-file.txt'
30 | Contents = 'This is a test!'
31 | }
32 | }
33 | }
34 |
35 | TestConfig1 @args
36 |
37 | Get-ChildItem TestConfig1\*.MOF | Publish-MOFToPullServer -Verbose `
38 | -PullServerWebConfig "$webSitePath\web.config"
39 |
--------------------------------------------------------------------------------
/tools/ci/DSC/xPSDesiredStateConfiguration-copy.ps1:
--------------------------------------------------------------------------------
1 | <#
2 | # PowerShell.org Tug DSC Pull Server
3 | # Copyright (c) The DevOps Collective, Inc. All rights reserved.
4 | # Licensed under the MIT license. See the LICENSE file in the project root for more information.
5 | #>
6 |
7 | ## The StaticTestConfig DSC configuration is meant to be used
8 | ## exactly as-is, that is the MOF and checksum files are NOT
9 | ## meant to be published/computed, but copied to the target
10 | ## DSC Pull Servers config repo so that we can perform Unit
11 | ## Tests that are validating expected content
12 |
13 | . "$PSScriptRoot\DscCommon.ps1"
14 |
15 | copy "$PSScriptRoot\xPSDesiredStateConfiguration_5.1.0.0.zip" $modulePath
16 | copy "$PSScriptRoot\xPSDesiredStateConfiguration_5.1.0.0.zip.checksum" $modulePath
17 |
--------------------------------------------------------------------------------
/tools/ci/DSC/xPSDesiredStateConfiguration_5.1.0.0.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PowerShellOrg/tug/aab51f407b92475ae64cc14a0dea33d459fe9885/tools/ci/DSC/xPSDesiredStateConfiguration_5.1.0.0.zip
--------------------------------------------------------------------------------
/tools/ci/DSC/xPSDesiredStateConfiguration_5.1.0.0.zip.checksum:
--------------------------------------------------------------------------------
1 | 8FB19218B06E212F1FF251B6F8DE0B261DF3806F0FFD545090E3265A481A9716
--------------------------------------------------------------------------------
/tools/ci/README.md:
--------------------------------------------------------------------------------
1 | # Tools/CI
2 |
3 | In here we place various resources that are used in support of our continuous integration (CI)
4 | environments.
5 |
6 | ## AppVeyor
7 |
8 | We use [AppVeyor](appveyor.com) (AV) to host CI process on Windows:
9 |
10 | > [](https://ci.appveyor.com/project/ebekker/tug)
11 |
12 | Because AV does not have full support for discoverability of .NET Core-based projects and assets,
13 | most of the build pipeline steps (setup, build, test, etc.) are manully crafted actions to make
14 | use of the .NET Core CLI tooling (`dotnet`). Once .NET Core tooling completes migration back to
15 | MSBuild-based projects, this will pby not be required, but may still offer greater flexibility.
16 |
17 |
18 | ### Using Classic DSC Pull Server v2
19 |
20 | In order to support testing and validation of the
21 | [MS-DSCPM](https://msdn.microsoft.com/en-us/library/dn393548.aspx)
22 | protocol messages and behaviors, we use the Windows-based CI to setup a local DSC Pull Server
23 | instance, using the *classic* v2 Pull Server
24 | ([xDscWebService](https://github.com/PowerShell/xPSDesiredStateConfiguration#xdscwebservice)).
25 |
26 | This is then used to support are protocol testing:
27 | * [x] Setup local Class DSC Pull Server (ClassicPullServer)
28 | * [x] Test `Tug.Client` against ClassicPullServer to validate client's compliance with DSCPM protocol
29 | * [x] Test 'Tug.Server' using 'Tug.Client' to validate server's compliance with DSCPM protocol
30 | * [ ] Test Classic Local Configuration Manager (ClassicLCM) against 'Tug.Server' to close the loop -- TODO: this is not done yet
31 |
--------------------------------------------------------------------------------
/tools/ci/appveyor-template.rdp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PowerShellOrg/tug/aab51f407b92475ae64cc14a0dea33d459fe9885/tools/ci/appveyor-template.rdp
--------------------------------------------------------------------------------
/tools/ci/av-connect.ps1:
--------------------------------------------------------------------------------
1 |
2 | $ign = "$PSScriptRoot\_IGNORE"
3 | md $ign -Force | Out-Null
4 |
5 | $rdpTemplate = "$PSScriptRoot\appveyor-template.rdp"
6 | $rdpLastServer = "$ign\lastServer.txt"
7 | $rdpProfile = "$ign\appveyor.rdp"
8 |
9 | #$avDetails = @'
10 | # Server: 74.205.54.20:33931
11 | # Username: appveyor
12 | # Password: %KFGJzhKUlcD$jX
13 | #'@
14 | $avDetails = Get-Clipboard -TextFormatType Text
15 | if (-not $avDetails -or -not "$avDetails".Trim().Length) {
16 | Write-Warning "Copy the connection details from AV console to the clipboard and TRY AGAIN!"
17 | return
18 | }
19 |
20 | $hostport = ""
21 | $username = ""
22 | $password = ""
23 |
24 | if ("$avDetails" -imatch "server:\s*([^\s]+)" ) { $hostport = $Matches[1] }
25 | if ("$avDetails" -imatch "username:\s*([^\s]+)") { $username = $Matches[1] }
26 | if ("$avDetails" -imatch "password:\s*([^\s]+)") { $password = $Matches[1] }
27 |
28 | Write-Output @"
29 | Extracted Connection Details:
30 | Server: $hostport
31 | Username: $username
32 | Password: $password
33 | "@
34 |
35 | if (-not $hostport -or -not $username -or -not $password) {
36 | Write-Warning "Unable to extract all the connection details"
37 | return
38 | }
39 |
40 | if (Test-Path -PathType Leaf $rdpLastServer) {
41 | $lastServer = [System.IO.File]::ReadAllText($rdpLastServer)
42 | Write-Warning "Detected LAST SERVER [$lastServer]"
43 | if ($lastServer) {
44 | Write-Warning "Deleting Credentials for LAST SERVER [$lastServer]"
45 | cmdkey /delete:`"$lastServer`"
46 | }
47 | }
48 |
49 | [System.IO.File]::WriteAllText($rdpLastServer, $hostport)
50 |
51 | $rdpDetails = [System.IO.File]::ReadAllText($rdpTemplate)
52 | $rdpDetails = $rdpDetails.Replace("@@SERVER@@", $hostport)
53 | [System.IO.File]::WriteAllText($rdpProfile, $rdpDetails)
54 |
55 |
56 | Write-Warning "Adding Credentials for [$hostport]"
57 | cmdkey /generic:`"$hostport`" /user:`"$username`" /pass:`"$password`"
58 |
59 | Write-Output "COPYING PASSWORD TO CLIPBOARD"
60 | Set-Clipboard -Value $password
61 |
62 | mstsc $rdpProfile
63 |
--------------------------------------------------------------------------------