Skip to content

Commit

Permalink
Add Description for Azure RMService Connection (#516)
Browse files Browse the repository at this point in the history
feat: add description field to Add-VSTeamAzureRMServiceEndpoint cmdlet

* Update Add-VSTeamAzureRMServiceEndpoint.ps1 to include description field
* Create Add-VSTeamAzureRMServiceEndpoint.Tests.ps1 for tests
* Update CHANGELOG.md to reflect changes
* Update cmdlet name to VSTeamAzureRMServiceEndpoint
* Add necessary mocks and fix typos in tests
  • Loading branch information
arturopolanco authored Apr 18, 2023
1 parent 9c2133f commit e8be72c
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 7.11.0

Merged [Pull Request](https://github.com/MethodsAndPractices/vsteam/pull/516) from [Arturo Polanco](https://github.com/arturopolanco) the following:
- Added option to add a description to the Azure RM Service Connecstions.

## 7.10.0

Merged [Pull Request](https://github.com/MethodsAndPractices/vsteam/pull/486) from [Sebastian Schütze](https://github.com/SebastianSchuetze) the following:
Expand Down
4 changes: 3 additions & 1 deletion Source/Public/Add-VSTeamAzureRMServiceEndpoint.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ function Add-VSTeamAzureRMServiceEndpoint {
[string] $servicePrincipalKey,

[string] $endpointName,
[string] $Description,

[Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true)]
[vsteam_lib.ProjectValidateAttribute($false)]
Expand Down Expand Up @@ -61,11 +62,12 @@ function Add-VSTeamAzureRMServiceEndpoint {
creationMode = $creationMode
}
url = 'https://management.azure.com/'
description = $Description
}

return Add-VSTeamServiceEndpoint -ProjectName $ProjectName `
-endpointName $endpointName `
-endpointType azurerm `
-object $obj
}
}
}
2 changes: 1 addition & 1 deletion Source/VSTeam.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
RootModule = 'VSTeam.psm1'

# Version number of this module.
ModuleVersion = '7.10.0'
ModuleVersion = '7.11.0'

# Supported PSEditions
CompatiblePSEditions = @('Core', 'Desktop')
Expand Down
36 changes: 36 additions & 0 deletions Tests/function/tests/Add-VSTeamAzureRMServiceEndpoint.Tests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
Set-StrictMode -Version Latest

Describe 'Add-VSTeamAzureRMServiceEndpoint' {
BeforeAll {
. "$PSScriptRoot\_testInitialize.ps1" $PSCommandPath
. "$baseFolder/Source/Public/Add-VSTeamServiceEndpoint.ps1"
. "$baseFolder/Source/Public/Get-VSTeamServiceEndpoint.ps1"
}

Context 'Add-VSTeamAzureRMServiceEndpoint' {
BeforeAll {
Mock _getInstance { return 'https://dev.azure.com/test' }
Mock _getApiVersion { return '1.0-unitTests' } -ParameterFilter { $Service -eq 'ServiceEndpoints' }

Mock Write-Progress
Mock Invoke-RestMethod { _trackProcess }
Mock Invoke-RestMethod { return @{id = '23233-2342' } } -ParameterFilter { $Method -eq 'Post' }
}

It 'should create a new Azure RM Serviceendpoint' {
Add-VSTeamAzureRMServiceEndpoint -projectName 'projectName'`
-SubscriptionName 'SubscriptionName' `
-SubscriptionId 'SubscriptionId' `
-SubscriptionTenantId '00000000-0000-0000-0000-000000000000' `
-ServicePrincipalId '00000000-0000-0000-0000-000000000000' `
-ServicePrincipalKey 'clientsecret' `
-EndpointName 'AzureRMTest' `
-Description 'description here'

# On PowerShell 5 the JSON has two spaces but on PowerShell 6 it only has one so
# test for both.
Should -Invoke Invoke-RestMethod -Exactly -Scope It -Times 1 -ParameterFilter {
$Method -eq 'Post' }
}
}
}
5 changes: 4 additions & 1 deletion Tests/function/tests/Add-VSTeamKubernetesEndpoint.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ Describe 'VSTeamKubernetesEndpoint' {
BeforeAll {
Mock _getInstance { return 'https://dev.azure.com/test' }
Mock _getApiVersion { return '1.0-unitTests' } -ParameterFilter { $Service -eq 'ServiceEndpoints' }

Mock Set-VSTeamAccount -ModuleName $moduleName { return $null }
Mock Set-VSTeamDefaultProject -ModuleName $moduleName { return $null }
Mock Get-VSTeamProject -ModuleName $moduleName { return @{
Id = "2c01ff81-274b-4831-b001-c894cfb795bb" }}
Mock Write-Progress
Mock Invoke-RestMethod { _trackProcess }
Mock Invoke-RestMethod { return @{id = '23233-2342' } } -ParameterFilter { $Method -eq 'Post' }
Expand Down

0 comments on commit e8be72c

Please sign in to comment.