Skip to content

Commit

Permalink
Fix GitHub Repository Dependabot Functions Pipeline Input (#272)
Browse files Browse the repository at this point in the history
Fixes the pipeline input for the following GitHub Repository functions:
- `Disable-GitHubRepositoryVulnerabilityAlert`
- `Enable-GitHubRepositorySecurityFix`
- `Disable-GitHubRepositorySecurityFix`

The unit tests for the functions are also updated to add pipeline tests.

Fixes #270
  • Loading branch information
X-Guardian committed Aug 10, 2020
1 parent 7de63ab commit 4ded2fa
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 4 deletions.
3 changes: 3 additions & 0 deletions GitHubRepositories.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2543,6 +2543,7 @@ filter Disable-GitHubRepositoryVulnerabilityAlert
Position = 1,
ValueFromPipelineByPropertyName,
ParameterSetName='Uri')]
[Alias('RepositoryUrl')]
[string] $Uri,

[string] $AccessToken,
Expand Down Expand Up @@ -2662,6 +2663,7 @@ filter Enable-GitHubRepositorySecurityFix
Position = 1,
ValueFromPipelineByPropertyName,
ParameterSetName='Uri')]
[Alias('RepositoryUrl')]
[string] $Uri,

[string] $AccessToken,
Expand Down Expand Up @@ -2780,6 +2782,7 @@ filter Disable-GitHubRepositorySecurityFix
Position = 1,
ValueFromPipelineByPropertyName,
ParameterSetName='Uri')]
[Alias('RepositoryUrl')]
[string] $Uri,

[string] $AccessToken,
Expand Down
62 changes: 58 additions & 4 deletions Tests/GitHubRepositories.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1246,6 +1246,16 @@ try
}
}

Context "When specifiying the 'URI' Parameter from the Pipeline" {
BeforeAll -ScriptBlock {
$status = $repo | Test-GitHubRepositoryVulnerabilityAlert
}

It 'Should return an object of the correct type' {
$status | Should -BeOfType System.Boolean
}
}

AfterAll -ScriptBlock {
Remove-GitHubRepository -Uri $repo.svn_url -Force
}
Expand All @@ -1263,6 +1273,17 @@ try
}
}

Context "When specifiying the 'URI' Parameter from the Pipeline" {
BeforeAll -ScriptBlock {
Disable-GitHubRepositoryVulnerabilityAlert -Uri $repo.svn_url
}

It 'Should not throw' {
{ $repo | Enable-GitHubRepositoryVulnerabilityAlert } |
Should -Not -Throw
}
}

AfterAll -ScriptBlock {
Remove-GitHubRepository -Uri $repo.svn_url -Force
}
Expand All @@ -1271,12 +1292,23 @@ try
Describe 'GitHubRepositories\Disable-GitHubRepositoryVulnerabilityAlert' {
BeforeAll {
$repo = New-GitHubRepository -RepositoryName ([Guid]::NewGuid().Guid)
Enable-GitHubRepositoryVulnerabilityAlert -Uri $repo.svn_url
Enable-GitHubRepositoryVulnerabilityAlert -Uri $repo.svn_url
}

Context 'When Disabling GitHub Repository Vulnerability Alerts' {
It 'Should not throw' {
{ Disable-GitHubRepositoryVulnerabilityAlert -Uri $repo.svn_url } |
{ Disable-GitHubRepositoryVulnerabilityAlert -Uri $repo.svn_url } |
Should -Not -Throw
}
}

Context "When specifiying the 'URI' Parameter from the Pipeline" {
BeforeAll -ScriptBlock {
Enable-GitHubRepositoryVulnerabilityAlert -Uri $repo.svn_url
}

It 'Should not throw' {
{ $repo | Disable-GitHubRepositoryVulnerabilityAlert } |
Should -Not -Throw
}
}
Expand All @@ -1294,7 +1326,18 @@ try

Context 'When Enabling GitHub Repository Security Fixes' {
It 'Should not throw' {
{ Enable-GitHubRepositorySecurityFix -Uri $repo.svn_url } |
{ Enable-GitHubRepositorySecurityFix -Uri $repo.svn_url } |
Should -Not -Throw
}
}

Context "When specifiying the 'URI' Parameter from the Pipeline" {
BeforeAll -ScriptBlock {
Disable-GitHubRepositorySecurityFix -Uri $repo.svn_url
}

It 'Should not throw' {
{ $repo | Enable-GitHubRepositorySecurityFix } |
Should -Not -Throw
}
}
Expand All @@ -1313,7 +1356,18 @@ try

Context 'When Disabling GitHub Repository Security Fixes' {
It 'Should not throw' {
{ Disable-GitHubRepositorySecurityFix -Uri $repo.svn_url } |
{ Disable-GitHubRepositorySecurityFix -Uri $repo.svn_url } |
Should -Not -Throw
}
}

Context "When specifiying the 'URI' Parameter from the Pipeline" {
BeforeAll -ScriptBlock {
Enable-GitHubRepositorySecurityFix -Uri $repo.svn_url
}

It 'Should not throw' {
{ $repo | Disable-GitHubRepositorySecurityFix } |
Should -Not -Throw
}
}
Expand Down

0 comments on commit 4ded2fa

Please sign in to comment.