Tests/Multitenancy/Test.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
# This script performs a simple happy-path test of most navcontainerhelper functions

$ErrorActionPreference = "Stop"
. (Join-Path $PSScriptRoot "..\..\NavContainerHelper.ps1")
. (Join-Path $PSScriptRoot "..\settings.ps1")

$imageName = "navdocker.azurecr.io/dynamics-nav:11.0.20433.0"
$imageName2 = "navdocker.azurecr.io/dynamics-nav:11.0.20433.0-finus"
#$imageName = "microsoft/dynamics-nav:2016"
#$imageName2 = "microsoft/dynamics-nav:2016-dk"

$containerName = "test"

$fobPath = (Join-Path $PSScriptRoot "test.fob")
$txtPath = (Join-Path $PSScriptRoot "test.txt")
$deltaPath = (Join-Path $PSScriptRoot "delta")
$v1AppPath = (Join-Path $PSScriptRoot "test.navx")
$v1AppName = "Test"
$v2AppPath = (Join-Path $PSScriptRoot "xFreddy Kristiansen_mytestapp_1.0.0.0.app")
$v2AppName = "mytestapp"

# New-CSideDevContainer
New-NavContainer -accept_eula `
                 -includeCSide `
                 -containerName $containerName `
                 -imageName $imageName `
                 -licenseFile $licenseFile `
                 -credential $credential `
                 -UpdateHosts `
                 -multitenant `
                 -Auth Windows `
                 -additionalParameters @("--volume ""${deltaPath}:c:\deltas""")

# Test-NavContainer
if (Test-NavContainer -containerName $containerName) {
    Write-Host "$containerName is running!"
}

# Create Extra tenant
New-NavContainerTenant -containerName $containerName -tenantId mytenant

# Remove tenant
Remove-NavContainerTenant -containerName $containerName -tenantId mytenant

# Get-NavContainerNavVersion
$navVersion = Get-NavContainerNavVersion -containerOrImageName $imageName
Write-Host "Nav Version of $imageName is $navVersion"
$navVersion = Get-NavContainerNavVersion -containerOrImageName $containerName
Write-Host "Nav Version of $containerName is $navVersion"

# Get-NavContainerImageName
$imageName = Get-NavContainerImageName -containerName $containerName
Write-Host "ImageName of $containerName is $imageName"

# Get-NavContainerGenericTag
$tag = Get-NavContainerGenericTag -containerOrImageName $imageName
Write-Host "Generic tag of $imageName is $tag"
$tag = Get-NavContainerGenericTag -containerOrImageName $containerName
Write-Host "Generic tag of $containerName is $tag"

# Get-NavContainerOsVersion
$osversion = Get-NavContainerOsVersion -containerOrImageName $imageName
Write-Host "OS Version of $imageName is $osversion"
$osversion = Get-NavContainerOsVersion -containerOrImageName $containerName
Write-Host "OS Version of $containerName is $osversion"

# Get-NavContainerLegal
$legal = Get-NavContainerLegal -containerOrImageName $imageName
Write-Host "Legal link of $imageName is $legal"
$legal = Get-NavContainerLegal -containerOrImageName $containerName
Write-Host "Legal link of $containerName is $legal"

# Get-NavContainerCountry
$country = Get-NavContainerCountry -containerOrImageName $imageName
Write-Host "Country of $imageName is $country"
$country = Get-NavContainerCountry -containerOrImageName $containerName
Write-Host "Country of $containerName is $country"

# Get-NavContainerIpAddress
$ipAddress = Get-NavContainerIpAddress -containerName $containerName
Write-Host "IP Address of $containerName is $ipAddress"

# Get-NavContainerSharedFolders
$sharedFolders = Get-NavContainerSharedFolders -containerName $containerName
Write-Host "Shared Folders with $containerName are:"
$sharedFolders.GetEnumerator() | ForEach-Object { Write-Host ($_.Name + " -> " + $_.Value) }

# Get-NavContainerPath
$path = "c:\programdata\navcontainerhelper\extensions\$containerName\my\AdditionalSetup.ps1"
$containerPath = Get-NavContainerPath -containerName $containerName -path $path
Write-Host "Container Path of $path in $containerName is $containerPath"

# Get-NavContainerId
$containerId = Get-NavcontainerId -containerName $containerName
Write-Host "Id of $containerName is $containerId"

# Get-NavContainerName
$containerName = Get-NavcontainerName -containerId $containerId
Write-Host "Name of $containerId is $containerName"

# Import-ObjectsToNavContainer (.fob)
Import-ObjectsToNavContainer -containerName $containerName `
                             -objectsFile $fobPath

# Compile-ObjectsToNavContainer
Compile-ObjectsInNavContainer -containerName $containerName

# Import-ObjectsToNavContainer (.txt)
Import-ObjectsToNavContainer -containerName $containerName `
                             -objectsFile $txtPath

# Compile-ObjectsToNavContainer
Compile-ObjectsInNavContainer -containerName $containerName

# Import-ObjectsToNavContainer (.txt)
Import-DeltasToNavContainer -containerName $containerName `
                            -deltaFolder $deltaPath

# Compile-ObjectsToNavContainer
Compile-ObjectsInNavContainer -containerName $containerName

# Install NavSip
Install-NAVSipCryptoProviderFromNavContainer -containerName $containerName

# Create Extra tenant
New-NavContainerTenant -containerName $containerName -tenantId mytenant

# App Handling functions v1 extensions
if (Test-Path $v1AppPath) {
    Publish-NavContainerApp -containerName $containerName -appFile $v1AppPath
    Get-NavContainerAppInfo -containerName $containerName
    Install-NavContainerApp -containerName $containerName -appName $v1AppName
    Uninstall-NavContainerApp -containerName $containerName -appName $v1AppName
    Unpublish-NavContainerApp -containerName $containerName -appName $v1AppName
    Get-NavContainerAppInfo -containerName $containerName
}

if (Test-Path $v2AppPath) {
    # App Handling functions v2 extensions
    Publish-NavContainerApp -containerName $containerName -appFile $v2AppPath -skipVerification
    Get-NavContainerAppInfo -containerName $containerName
    Sync-NavContainerApp -containerName $containerName -appName $v2AppName -tenant "mytenant"
    Install-NavContainerApp -containerName $containerName -appName $v2AppName -tenant "mytenant"
    Uninstall-NavContainerApp -containerName $containerName -appName $v2AppName -tenant "mytenant"
    Unpublish-NavContainerApp -containerName $containerName -appName $v2AppName
    Get-NavContainerAppInfo -containerName $containerName
}

# Remove tenant
Remove-NavContainerTenant -containerName $containerName -tenantId mytenant

# Remove-NavContainer
Remove-NavContainer -containerName $containerName

# New-CSideDevContainer
New-NavContainer -accept_eula `
                 -includeCSide `
                 -containerName $containerName `
                 -imageName $imageName2 `
                 -licenseFile $licenseFile `
                 -credential $credential `
                 -UpdateHosts `
                 -multitenant `
                 -Auth NavUserPassword

# Test-NavContainer
if (Test-NavContainer -containerName $containerName) {
    Write-Host "$containerName is running!"
}

# Get-NavContainerNavVersion
$navVersion = Get-NavContainerNavVersion -containerOrImageName $imageName2
Write-Host "Nav Version of $imageName2 is $navVersion"
$navVersion = Get-NavContainerNavVersion -containerOrImageName $containerName
Write-Host "Nav Version of $containerName is $navVersion"

# Get-NavContainerImageName
$imageName2 = Get-NavContainerImageName -containerName $containerName
Write-Host "ImageName of $containerName is $imageName2"

# Get-NavContainerGenericTag
$tag = Get-NavContainerGenericTag -containerOrImageName $imageName2
Write-Host "Generic tag of $imageName2 is $tag"
$tag = Get-NavContainerGenericTag -containerOrImageName $containerName
Write-Host "Generic tag of $containerName is $tag"

# Get-NavContainerOsVersion
$osversion = Get-NavContainerOsVersion -containerOrImageName $imageName2
Write-Host "OS Version of $imageName2 is $osversion"
$osversion = Get-NavContainerOsVersion -containerOrImageName $containerName
Write-Host "OS Version of $containerName is $osversion"

# Get-NavContainerLegal
$legal = Get-NavContainerLegal -containerOrImageName $imageName2
Write-Host "Legal link of $imageName2 is $legal"
$legal = Get-NavContainerLegal -containerOrImageName $containerName
Write-Host "Legal link of $containerName is $legal"

# Get-NavContainerCountry
$country = Get-NavContainerCountry -containerOrImageName $imageName2
Write-Host "Country of $imageName2 is $country"
$country = Get-NavContainerCountry -containerOrImageName $containerName
Write-Host "Country of $containerName is $country"

# Get-NavContainerIpAddress
$ipAddress = Get-NavContainerIpAddress -containerName $containerName
Write-Host "IP Address of $containerName is $ipAddress"

# Get-NavContainerSharedFolders
$sharedFolders = Get-NavContainerSharedFolders -containerName $containerName
Write-Host "Shared Folders with $containerName are:"
$sharedFolders.GetEnumerator() | ForEach-Object { Write-Host ($_.Name + " -> " + $_.Value) }

# Get-NavContainerPath
$path = "c:\programdata\navcontainerhelper\extensions\$containerName\my\AdditionalSetup.ps1"
$containerPath = Get-NavContainerPath -containerName $containerName -path $path
Write-Host "Container Path of $path in $containerName is $containerPath"

# Get-NavContainerId
$containerId = Get-NavcontainerId -containerName $containerName
Write-Host "Id of $containerName is $containerId"

# Get-NavContainerName
$containerName = Get-NavcontainerName -containerId $containerId
Write-Host "Name of $containerId is $containerName"

# Import-ObjectsToNavContainer (.fob)
Import-ObjectsToNavContainer -containerName $containerName `
                             -objectsFile $fobPath `
                             -sqlCredential $sqlCredential

# Compile-ObjectsToNavContainer
Compile-ObjectsInNavContainer -containerName $containerName `
                              -sqlCredential $sqlCredential

# Import-ObjectsToNavContainer (.txt)
Import-ObjectsToNavContainer -containerName $containerName `
                             -objectsFile $txtPath `
                             -sqlCredential $sqlCredential

# Compile-ObjectsToNavContainer
Compile-ObjectsInNavContainer -containerName $containerName `
                              -sqlCredential $sqlCredential

# Convert-ModifiedObjectsToAl
#Convert-ModifiedObjectsToAl -containerName $containerName `
# -sqlCredential $sqlCredential `
# -startId 50100

# Remove-NavContainer
Remove-NavContainer -containerName $containerName