Skip to content

Commit

Permalink
Merge from dev
Browse files Browse the repository at this point in the history
  • Loading branch information
markekraus committed Mar 5, 2017
1 parent 338717f commit 42e945a
Show file tree
Hide file tree
Showing 11 changed files with 468 additions and 92 deletions.
1 change: 0 additions & 1 deletion .gitattributes

This file was deleted.

5 changes: 2 additions & 3 deletions PSMSGraph/Public/Get-AADGroupMember.ps1
Expand Up @@ -40,6 +40,7 @@ function Get-AADGroupMember {
[CmdletBinding(SupportsShouldProcess = $true,
HelpUri = 'http://psmsgraph.readthedocs.io/en/latest/functions/Get-AADGroupMember')]
[OutputType('MSGraphAPI.DirectoryObject.User')]
[Alias('Get-AADGroupMembers')]
param
(
[Parameter(Mandatory = $true,
Expand Down Expand Up @@ -101,6 +102,4 @@ function Get-AADGroupMember {
while ($SkipToken)
}
}
}

New-Alias -Name Get-AADGroupMembers -Value Get-AADGroupMember -Description "Alias for Get-AADGroupMember"
}
47 changes: 47 additions & 0 deletions RELEASE.md
@@ -0,0 +1,47 @@
# Version 1.0.24.17 (2017-03-05)
## Functions
### All
* Added HelpUri and .LINK's to Comment based Help

### OAuth functions
* Standardized on "Oauth" in the function and file names (was a mix of "OAuth" and "Oath")

### Get-AADGroupMember
* Made function singular instead of plural (was Get-AADGroupMembers)
* Added Get-AADGroupMembers alias
* Fixed all the millions of problems this rename caused

## Build Tools
### psake.ps1
* Restructured psake.ps1
- Init > UnitTests > Build > Test > BuildDocs > Deploy > Post Deploy
* Added AST based Function and Alias module manifest population
* Added NestedModule Population
* Added Release notes and change log auto processing and documentation
* PostDeploy is now local build friendly

## Tests
### PSScriptAnalyzer.tests.Ps1
* Moved out of Project.Tests.ps1
* Re-wroded the tests so they display better in AppVeyor test logs
* Removed .psd1 from the tests because it dose not appear to support suppression and certain test will falsely fail due to the text in RealseNotes

### Project.Tests.ps1
* Moved the PSScriptAnalyzer tests to PSScriptAnalyzer.tests.Ps1
* Added Unit tag to "General project validation" so it test before and after build

### New-GraphApplication.Unit.Tests.ps1
* Added Unit test for New-GraphApplication

### New-GraphOauthAccessToken.Unit.Tests.ps1
* Added Unit test for New-GraphOauthAccessToken

## Project
### RELEASE.md
* Added this to server as the current release notes
* Integrates automatically with ChangeLog.md through build pipeline
* Gets copied to ```docs/```

### ChangeLog.md
* Added to ```docs/```
* Automatically managed by build process
28 changes: 16 additions & 12 deletions Tests/Help.Tests.ps1
Expand Up @@ -5,24 +5,28 @@ $moduleName = Split-Path $moduleRoot -Leaf
Import-Module (Join-Path $moduleRoot "$moduleName.psd1") -force

Describe "Help tests for $moduleName" -Tags Build {

$functions = Get-Command -Module $moduleName -CommandType Function
$help = $functions | %{Get-Help $_.name}
foreach($node in $help)
{
Context $node.name {

it "has a description" {
$node.description | Should Not BeNullOrEmpty
foreach($Function in $Functions){
$help = Get-Help $Function.name
Context $help.name {
it "Has a HelpUri" {
$Function.HelpUri | Should Not BeNullOrEmpty
}
It "Has related Links" {
$help.relatedLinks.navigationLink.uri.count | Should BeGreaterThan 0
}
it "Has a description" {
$help.description | Should Not BeNullOrEmpty
}
it "has an example" {
$node.examples | Should Not BeNullOrEmpty
it "Has an example" {
$help.examples | Should Not BeNullOrEmpty
}
foreach($parameter in $node.parameters.parameter)
foreach($parameter in $help.parameters.parameter)
{
if($parameter -notmatch 'whatif|confirm')
{
it "parameter $($parameter.name) has a description" {
it "Has a Parameter description for '$($parameter.name)'" {
$parameter.Description.text | Should Not BeNullOrEmpty
}
}
Expand Down
61 changes: 61 additions & 0 deletions Tests/New-GraphApplication.Unit.Tests.ps1
@@ -0,0 +1,61 @@
<#
.NOTES
===========================================================================
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2017 v5.4.135
Created on: 2/27/2017 4:42 AM
Created by: Mark Kraus
Organization:
Filename:
===========================================================================
.DESCRIPTION
Unit Tests for New-GraphApplication
#>

$projectRoot = Resolve-Path "$PSScriptRoot\.."
$moduleRoot = Split-Path (Resolve-Path "$projectRoot\*\*.psd1")
$moduleName = Split-Path $moduleRoot -Leaf
Import-Module (Join-Path $moduleRoot "$moduleName.psd1") -force

$Command = 'New-GraphApplication'

$TypeName = 'MSGraphAPI.Application'
$ClientID = '12345'
$ClientSecret = '54321'
$SecClientSecret = $ClientSecret | ConvertTo-SecureString -AsPlainText -Force
$ClientCredential = [system.Management.Automation.PSCredential]::new($ClientID, $SecClientSecret)

$Params = @{
Name = 'Unit Test Application'
Description = 'This is a test of the emergency broadcast system'
ClientCredential = $ClientCredential
GUID = 'e2ad918e-dc87-4c23-803c-e67e43e0f217'
RedirectUri = 'https://localhost'
Tenant = 'adatum.onmicrosoft.com'
}
$RequiredParams = @(
'Tenant'
'Name'
'ClientCredential'
'RedirectUri'
)
Describe $Command -Tags Unit {
It 'Does not have errors when passed required parameters' {
$LocalParams = $Params.psobject.Copy()
{ & $Command @LocalParams -ErrorAction Stop } | Should not throw
}
Foreach ($RequiredParam in $RequiredParams) {
It "Requires the $RequiredParam parameter" {
((Get-Command $Command).Parameters[$RequiredParam].Attributes |
Where-Object { $_ -is [parameter] }).Mandatory |
Should be $true
}
}
It "Emits a $TypeName Object" {
(Get-Command $Command).OutputType.Name.where({ $_ -eq $TypeName }) | Should be $TypeName
}
It "Creates a $TypeName Object" {
$LocalParams = $Params.psobject.Copy()
$Object = & $Command @LocalParams -ErrorAction SilentlyContinue | Select-Object -First 1
$Object.psobject.typenames.where({ $_ -eq $TypeName }) | Should be $TypeName
}
}
83 changes: 83 additions & 0 deletions Tests/New-GraphOauthAccessToken.Unit.Tests.ps1
@@ -0,0 +1,83 @@
<#
.NOTES
===========================================================================
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2017 v5.4.135
Created on: 2/27/2017 4:42 AM
Created by: Mark Kraus
Organization:
Filename:
===========================================================================
.DESCRIPTION
Unit Tests for New-GraphOauthAccessToken
#>

$projectRoot = Resolve-Path "$PSScriptRoot\.."
$moduleRoot = Split-Path (Resolve-Path "$projectRoot\*\*.psd1")
$moduleName = Split-Path $moduleRoot -Leaf
Import-Module (Join-Path $moduleRoot "$moduleName.psd1") -force

$Command = 'New-GraphOauthAccessToken'

$TypeName = 'MSGraphAPI.Oauth.AccessToken'
$ClientID = '12345'
$ClientSecret = '54321'
$SecClientSecret = $ClientSecret | ConvertTo-SecureString -AsPlainText -Force
$ClientCredential = [system.Management.Automation.PSCredential]::new($ClientID, $SecClientSecret)
$Params = @{
Name = 'Unit Test Application'
Description = 'This is a test of the emergency broadcast system'
ClientCredential = $ClientCredential
GUID = 'e2ad918e-dc87-4c23-803c-e67e43e0f217'
RedirectUri = 'https://localhost'
Tenant = 'adatum.onmicrosoft.com'
}
$App = New-GraphApplication @Params

$AToken = '67890'
$SecAtoken = $Atoken | ConvertTo-SecureString -AsPlainText -Force
$AccessTokenCredential = [system.Management.Automation.PSCredential]::new('access_token', $SecAtoken)
$Rtoken = '09876'
$SecRtoken = $Rtoken | ConvertTo-SecureString -AsPlainText -Force
$RefreshTokenCredential = [system.Management.Automation.PSCredential]::new('refresh_token', $SecRtoken)

$Params = @{
'Application' = $App
'AccessTokenCredential' = $AccessTokenCredential
'RefreshTokenCredential' = $RefreshTokenCredential
'RequestedDate' = Get-Date
'Response' = [pscustomobject]@{TestResponse = 'Test'}
'ResponseHeaders' = [pscustomobject]@{ TestHeaders = 'Test' }
'LastRequestDate' = get-date
'GUID' = '1c6e3c87-8f77-435c-911d-3e97588918d0'
'Session' = [Microsoft.PowerShell.Commands.WebRequestSession]::new()
}
$RequiredParams = @(
'Application'
'AccessTokenCredential'
'RefreshTokenCredential'
'RequestedDate'
'Response'
'ResponseHeaders'
'LastRequestDate'
)
Describe $Command -Tags Unit {
It 'Does not have errors when passed required parameters' {
$LocalParams = $Params.psobject.Copy()
{ & $Command @LocalParams -ErrorAction Stop } | Should not throw
}
Foreach ($RequiredParam in $RequiredParams) {
It "Requires the $RequiredParam parameter" {
((Get-Command $Command).Parameters[$RequiredParam].Attributes |
Where-Object { $_ -is [parameter] }).Mandatory |
Should be $true
}
}
It "Emits a $TypeName Object" {
(Get-Command $Command).OutputType.Name.where({ $_ -eq $TypeName }) | Should be $TypeName
}
It "Creates a $TypeName Object" {
$LocalParams = $Params.psobject.Copy()
$Object = & $Command @LocalParams -ErrorAction SilentlyContinue | Select-Object -First 1
$Object.psobject.typenames.where({ $_ -eq $TypeName }) | Should be $TypeName
}
}
34 changes: 34 additions & 0 deletions Tests/PSScriptAnalyzer.Tests.ps1
@@ -0,0 +1,34 @@
<#
.NOTES
===========================================================================
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2017 v5.4.135
Created on: 2/28/2017 11:49 AM
Editied on: 3/4/2017
Created by: Mark Kraus
Organization:
Filename: PSScriptAnalyzer.tests.Ps1
===========================================================================
.DESCRIPTION
Runs PSScriptAnalyzer tests for every rule against every file in the module
#>
$projectRoot = Resolve-Path "$PSScriptRoot\.."
$moduleRoot = Split-Path (Resolve-Path "$projectRoot\*\*.psd1")
$moduleName = Split-Path $moduleRoot -Leaf

Describe "PSScriptAnalyzer Tests" -Tags Build {

$Rules = Get-ScriptAnalyzerRule
$scripts = Get-ChildItem $moduleRoot -Include *.ps1, *.psm1 -Recurse | Where-Object fullname -notmatch 'classes'

foreach ($Script in $scripts) {
$RelPath = $Script.FullName.Replace($moduleRoot, '') -replace '^\\', ''
Context "$RelPath" {
foreach ($rule in $rules) {
It "Passes $rule" {

(Invoke-ScriptAnalyzer -Path $script.FullName -IncludeRule $rule.RuleName).Count | Should Be 0
}
}
}
}
}
22 changes: 1 addition & 21 deletions Tests/Project.Tests.ps1
Expand Up @@ -2,27 +2,7 @@ $projectRoot = Resolve-Path "$PSScriptRoot\.."
$moduleRoot = Split-Path (Resolve-Path "$projectRoot\*\*.psd1")
$moduleName = Split-Path $moduleRoot -Leaf


Describe "Testing all Script against default PSScriptAnalyzer rule-set" {

$Rules = Get-ScriptAnalyzerRule
$scripts = Get-ChildItem $moduleRoot -Include *.ps1, *.psm1, *.psd1 -Recurse | where fullname -notmatch 'classes'

foreach ($Script in $scripts) {
Context "Testing Script '$($script.FullName)'" {

foreach ($rule in $rules) {
It "passes the PSScriptAnalyzer Rule [$rule]" {

(Invoke-ScriptAnalyzer -Path $script.FullName -IncludeRule $rule.RuleName).Count | Should Be 0
}
}
}
}
}


Describe "General project validation: $moduleName" -Tags Build {
Describe "General project validation: $moduleName" -Tags Build, Unit {

It "Module '$moduleName' can import cleanly" {
{ Import-Module (Join-Path $moduleRoot "$moduleName.psm1") -force } | Should Not Throw
Expand Down
12 changes: 0 additions & 12 deletions appveyor.yml
Expand Up @@ -19,15 +19,3 @@ build: false
#Kick off the CI/CD pipeline
test_script:
- ps: . .\build.ps1

on_success:
- git config --global credential.helper store
- ps: Add-Content "$env:USERPROFILE\.git-credentials" "https://$($env:access_token):x-oauth-basic@github.com`n"
- git config --global user.email "appveyor-psmsgraph-github@markekraus.com"
- git config --global user.name "markekraus"
- git config --global core.autocrlf true
- git checkout master
- git add -A
- git commit -m "appveyor post-build commit[ci skip]"
- git status
- git push
6 changes: 3 additions & 3 deletions build.ps1
Expand Up @@ -3,11 +3,11 @@ param ($Task = 'Default')
# Grab nuget bits, install modules, set build variables, start build.
Get-PackageProvider -Name NuGet -ForceBootstrap | Out-Null

Install-Module Psake, PSDeploy, BuildHelpers, platyPS -force
Install-Module Psake, PSDeploy, BuildHelpers, platyPS, PSScriptAnalyzer -force
Install-Module Pester -Force -SkipPublisherCheck
Import-Module Psake, BuildHelpers, platyPS
Import-Module Psake, BuildHelpers, platyPS, PSScriptAnalyzer

Set-BuildEnvironment

Invoke-psake -buildFile .\psake.ps1 -taskList $Task -nologo
exit ( [int]( -not $psake.build_success ) )
exit ([int](-not $psake.build_success))

0 comments on commit 42e945a

Please sign in to comment.