Skip to content

Commit e8be72c

Browse files
Add Description for Azure RMService Connection (#516)
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
1 parent 9c2133f commit e8be72c

File tree

5 files changed

+49
-3
lines changed

5 files changed

+49
-3
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## 7.11.0
4+
5+
Merged [Pull Request](https://github.com/MethodsAndPractices/vsteam/pull/516) from [Arturo Polanco](https://github.com/arturopolanco) the following:
6+
- Added option to add a description to the Azure RM Service Connecstions.
7+
38
## 7.10.0
49

510
Merged [Pull Request](https://github.com/MethodsAndPractices/vsteam/pull/486) from [Sebastian Schütze](https://github.com/SebastianSchuetze) the following:

Source/Public/Add-VSTeamAzureRMServiceEndpoint.ps1

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ function Add-VSTeamAzureRMServiceEndpoint {
2828
[string] $servicePrincipalKey,
2929

3030
[string] $endpointName,
31+
[string] $Description,
3132

3233
[Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true)]
3334
[vsteam_lib.ProjectValidateAttribute($false)]
@@ -61,11 +62,12 @@ function Add-VSTeamAzureRMServiceEndpoint {
6162
creationMode = $creationMode
6263
}
6364
url = 'https://management.azure.com/'
65+
description = $Description
6466
}
6567

6668
return Add-VSTeamServiceEndpoint -ProjectName $ProjectName `
6769
-endpointName $endpointName `
6870
-endpointType azurerm `
6971
-object $obj
7072
}
71-
}
73+
}

Source/VSTeam.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
RootModule = 'VSTeam.psm1'
1313

1414
# Version number of this module.
15-
ModuleVersion = '7.10.0'
15+
ModuleVersion = '7.11.0'
1616

1717
# Supported PSEditions
1818
CompatiblePSEditions = @('Core', 'Desktop')
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
Set-StrictMode -Version Latest
2+
3+
Describe 'Add-VSTeamAzureRMServiceEndpoint' {
4+
BeforeAll {
5+
. "$PSScriptRoot\_testInitialize.ps1" $PSCommandPath
6+
. "$baseFolder/Source/Public/Add-VSTeamServiceEndpoint.ps1"
7+
. "$baseFolder/Source/Public/Get-VSTeamServiceEndpoint.ps1"
8+
}
9+
10+
Context 'Add-VSTeamAzureRMServiceEndpoint' {
11+
BeforeAll {
12+
Mock _getInstance { return 'https://dev.azure.com/test' }
13+
Mock _getApiVersion { return '1.0-unitTests' } -ParameterFilter { $Service -eq 'ServiceEndpoints' }
14+
15+
Mock Write-Progress
16+
Mock Invoke-RestMethod { _trackProcess }
17+
Mock Invoke-RestMethod { return @{id = '23233-2342' } } -ParameterFilter { $Method -eq 'Post' }
18+
}
19+
20+
It 'should create a new Azure RM Serviceendpoint' {
21+
Add-VSTeamAzureRMServiceEndpoint -projectName 'projectName'`
22+
-SubscriptionName 'SubscriptionName' `
23+
-SubscriptionId 'SubscriptionId' `
24+
-SubscriptionTenantId '00000000-0000-0000-0000-000000000000' `
25+
-ServicePrincipalId '00000000-0000-0000-0000-000000000000' `
26+
-ServicePrincipalKey 'clientsecret' `
27+
-EndpointName 'AzureRMTest' `
28+
-Description 'description here'
29+
30+
# On PowerShell 5 the JSON has two spaces but on PowerShell 6 it only has one so
31+
# test for both.
32+
Should -Invoke Invoke-RestMethod -Exactly -Scope It -Times 1 -ParameterFilter {
33+
$Method -eq 'Post' }
34+
}
35+
}
36+
}

Tests/function/tests/Add-VSTeamKubernetesEndpoint.Tests.ps1

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ Describe 'VSTeamKubernetesEndpoint' {
1111
BeforeAll {
1212
Mock _getInstance { return 'https://dev.azure.com/test' }
1313
Mock _getApiVersion { return '1.0-unitTests' } -ParameterFilter { $Service -eq 'ServiceEndpoints' }
14-
14+
Mock Set-VSTeamAccount -ModuleName $moduleName { return $null }
15+
Mock Set-VSTeamDefaultProject -ModuleName $moduleName { return $null }
16+
Mock Get-VSTeamProject -ModuleName $moduleName { return @{
17+
Id = "2c01ff81-274b-4831-b001-c894cfb795bb" }}
1518
Mock Write-Progress
1619
Mock Invoke-RestMethod { _trackProcess }
1720
Mock Invoke-RestMethod { return @{id = '23233-2342' } } -ParameterFilter { $Method -eq 'Post' }

0 commit comments

Comments
 (0)