Advertisement
Guest User

Untitled

a guest
Nov 25th, 2015
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 KB | None | 0 0
  1. $ConfigurationData = @{
  2. AllNodes = @(
  3. @{
  4. NodeName = 'sql-01'
  5. Roles = @{
  6. Computer = @{
  7. MachineName = 'sql-01'
  8. DomainName = 'example.com'
  9. Credential = 'Svc-Domain-Join@example.com'
  10. }
  11. }
  12. }
  13. )
  14. Credentials = @{
  15. 'Svc-Domain-Join@example.com' = (Join-Path -Path $PSScriptRoot -ChildPath 'ConfigDataPester.clixml')
  16. }
  17. }
  18.  
  19. # Mimic special variables in PSDSC configurations
  20. $AllNodes = $ConfigurationData.AllNodes
  21.  
  22. Describe 'Structural Tests' {
  23. It 'Defines credential files' {
  24. $ConfigurationData.Keys -icontains 'Credentials' | Should Be $true
  25. }
  26. foreach ($CredName in $ConfigurationData.Credentials.Keys) {
  27. It "Defines existing credential file for $CredName" {
  28. Test-Path -Path $ConfigurationData.Credentials.$CredName | Should Be $true
  29. }
  30. }
  31. }
  32.  
  33. # Mimic special variable $Node in enumeration
  34. foreach ($Node in $ConfigurationData.AllNodes) {
  35. Describe "Node $($Node.NodeName)" {
  36. Context 'Role computer' {
  37. It 'Contains computer role' {
  38. $Node.Roles.Keys -icontains 'Computer' | Should Be $true
  39. }
  40. It 'Resolves credential object if specified' {
  41. if ($Node.Roles.Computer.Keys -icontains 'Credential') {
  42. $ConfigurationData.Credentials.Keys -icontains $Node.Roles.Computer.Credential | Should Be $true
  43. }
  44. }
  45. It 'Specifies credentials for domain join' {
  46. $Node.Roles.Computer.Keys -icontains 'DomainName' | Should Be $true
  47. $Node.Roles.Computer.Keys -icontains 'Credential' | Should Be $true
  48. }
  49. }
  50. }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement