Skip to content

Commit

Permalink
Added comments to testing script
Browse files Browse the repository at this point in the history
  • Loading branch information
DCMattyG committed Oct 8, 2023
1 parent c3663b4 commit 1d4a5b0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/azure-ipam-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ name: Azure IPAM Testing
run-name: Azure IPAM Deployment & Testing

on:
push:
branches: [ ipam-pydantic-v2 ]
pull_request:
branches: [ main ]

Expand Down
23 changes: 23 additions & 0 deletions tests/azureipam.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,15 @@ BeforeAll {
}

Context 'Spaces' {
# GET /api/spaces
It 'Verify No Spaces Exist' {

$spaces, $spacesStatus = Get-ApiResource '/spaces'

$spaces | Should -Be $null
}

# POST /api/spaces
It 'Create Two Spaces' {
$spaceA = @{
name = 'TestSpace01'
Expand All @@ -158,6 +160,7 @@ Context 'Spaces' {
$spaces.Name -contains 'TestSpace02' | Should -Be $true
}

# DELETE /api/spaces/{space}
It 'Delete a Space' {
Remove-ApiResource '/spaces/TestSpace02'

Expand All @@ -168,6 +171,7 @@ Context 'Spaces' {
$spaces.Name -contains 'TestSpace02' | Should -Be $false
}

# PATCH /api/spaces/{space}
It 'Update a Space' {
$update = @(
@{
Expand All @@ -191,6 +195,7 @@ Context 'Spaces' {
$spaces[0].Desc -eq 'Test Space A' | Should -Be $true
}

# GET /api/spaces/{space}
It 'Get A Specific Space' {

$space, $spaceStatus = Get-ApiResource '/spaces/TestSpaceA'
Expand All @@ -201,13 +206,15 @@ Context 'Spaces' {
}

Context 'Blocks' {
# GET /api/spaces/{space}/blocks
It 'Verify No Blocks Exist' {

$blocks, $blocksStatus = Get-ApiResource '/spaces/TestSpaceA/blocks'

$blocks | Should -Be $null
}

# POST /api/spaces/{space}/blocks
It 'Create Two Blocks' {
$blockA = @{
name = 'TestBlock01'
Expand All @@ -229,6 +236,7 @@ Context 'Blocks' {
$blocks.Name -contains 'TestBlock02' | Should -Be $true
}

# DELETE /api/spaces/{space}/blocks/{block}
It 'Delete a Block' {
Remove-ApiResource '/spaces/TestSpaceA/blocks/TestBlock02'

Expand All @@ -239,6 +247,7 @@ Context 'Blocks' {
$blocks.Name -contains 'TestBlock02' | Should -Be $false
}

# PATCH /api/spaces/{space}/blocks/{block}
It 'Update a Block' {
$update = @(
@{
Expand All @@ -262,6 +271,7 @@ Context 'Blocks' {
$blocks[0].Cidr -eq '10.1.0.0/16' | Should -Be $true
}

# GET /api/spaces/{space}/blocks/{block}
It 'Get A Specific Block' {

$block, $blockStatus = Get-ApiResource '/spaces/TestSpaceA/blocks/TestBlockA'
Expand All @@ -272,13 +282,15 @@ Context 'Blocks' {
}

Context 'Networks' {
# GET /api/spaces/{space}/blocks/{block}/networks
It 'Verify No Networks Exist in Block' {

$networks, $networksStatus = Get-ApiResource '/spaces/TestSpaceA/blocks/TestBlockA/networks'

$networks | Should -Be $null
}

# POST /api/spaces/{space}/blocks/{block}/networks
It 'Add a Virtual Network to a Block' {
$script:newNetA = New-AzVirtualNetwork `
-Name 'TestVNet01' `
Expand All @@ -299,6 +311,7 @@ Context 'Networks' {
$($block.vnets | Select-Object -ExpandProperty id) -contains $script:newNetA.Id | Should -Be $true
}

# PUT /api/spaces/{space}/blocks/{block}/networks
It 'Replace Block Virtual Networks' {
$script:newNetB = New-AzVirtualNetwork `
-Name 'TestVNet02' `
Expand All @@ -321,6 +334,7 @@ Context 'Networks' {
$($networks | Select-Object -ExpandProperty id) -contains $script:newNetB.Id | Should -Be $true
}

# DELETE /api/spaces/{space}/blocks/{block}/networks
It 'Delete Block Virtual Network' {
$body = @(
$script:newNetB.Id
Expand All @@ -336,13 +350,15 @@ Context 'Networks' {
}

Context 'External Networks' {
# GET /api/spaces/{space}/blocks/{block}/externals
It 'Verify No External Networks Exist in Block' {

$externals, $externalsStatus = Get-ApiResource '/spaces/TestSpaceA/blocks/TestBlockA/externals'

$externals | Should -Be $null
}

# POST /api/spaces/{space}/blocks/{block}/externals
It 'Add an External Network to Block' {
$script:externalA = @{
name = "ExternalNetA"
Expand All @@ -357,6 +373,7 @@ Context 'External Networks' {
$externals.Name -contains "ExternalNetA" | Should -Be $true
}

# PUT /api/spaces/{space}/blocks/{block}/externals
It 'Replace Block External Networks' {
$script:externalB = @{
name = "ExternalNetB"
Expand Down Expand Up @@ -384,6 +401,7 @@ Context 'External Networks' {
$externals.Name -contains "ExternalNetB" | Should -Be $true
}

# DELETE /api/spaces/{space}/blocks/{block}/externals
It 'Delete Block External Network' {
$body = @(
$script:externalC.name
Expand All @@ -398,6 +416,7 @@ Context 'External Networks' {
$externals.Name -contains "ExternalNetC" | Should -Be $false
}

# GET /api/spaces/{space}/blocks/{block}/externals/{external}
It 'Get Specific Block External Network' {

$external, $externalStatus = Get-ApiResource '/spaces/TestSpaceA/blocks/TestBlockA/externals/ExternalNetB'
Expand All @@ -407,6 +426,7 @@ Context 'External Networks' {
$external.Cidr | Should -Be "10.1.2.0/24"
}

# PATCH /api/spaces/{space}/blocks/{block}/externals/{external}
It 'Delete Specific Block External Network' {

Remove-ApiResource '/spaces/TestSpaceA/blocks/TestBlockA/externals/ExternalNetB'
Expand All @@ -420,6 +440,7 @@ Context 'External Networks' {
}

Context 'Reservations' {
# GET /api/spaces/{space}/blocks/{block}/reservations
It 'Verify No Reservations Exist in Block' {

$reservations, $reservationsStatus = Get-ApiResource '/spaces/TestSpaceA/blocks/TestBlockA/reservations'
Expand Down Expand Up @@ -457,6 +478,7 @@ Context 'Reservations' {
$reservations[1].SettledOn -eq $null | Should -Be $true
}

# PUT /api/spaces/{space}/blocks/{block}/reservations
It 'Import Virtual Network via Reservation ID' {
$script:newNetC = New-AzVirtualNetwork `
-Name 'TestVNet03' `
Expand Down Expand Up @@ -485,6 +507,7 @@ Context 'Reservations' {
$reservations[1].Status -eq "wait" | Should -Be $true
}

# PATCH /api/spaces/{space}/blocks/{block}/reservations
It 'Delete A Reservation' {
$body = @(
$script:reservationB.Id
Expand Down

0 comments on commit 1d4a5b0

Please sign in to comment.