Skip to content

Commit

Permalink
50037 - Fix smoketests (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
volllly authored Mar 14, 2022
1 parent 52bfae0 commit 0e66f65
Show file tree
Hide file tree
Showing 6 changed files with 210 additions and 119 deletions.
145 changes: 72 additions & 73 deletions azure-pipelines/middleware-launcher-android-ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,63 +104,55 @@ stages:
artifactName: 'drop'
targetPath: '$(Build.ArtifactStagingDirectory)'

# - powershell: |
# $tssId = "$([guid]::NewGuid())"
# $adminPin = "$(Get-Random -Minimum 100000 -Maximum 10000000)"
- powershell: |
$tssId = "$([guid]::NewGuid())"
$adminPin = "1234567890"
# echo "##vso[task.setvariable variable=tssId;isOutput=true]$tssId"
# echo "##vso[task.setvariable variable=adminPin;isOutput=true]$adminPin"
# name: setTssVariablesStep
# displayName: 'Set TSS variables'
echo "##vso[task.setvariable variable=tssId;isOutput=true]$tssId"
echo "##vso[task.setvariable variable=adminPin;isOutput=true]$adminPin"
name: setTssVariablesStep
displayName: 'Set TSS variables'
# - task: PowerShell@2
# inputs:
# targetType: 'filePath'
# filePath: azure-pipelines/scripts/create-fiskaly-tse.ps1
# arguments: >
# -FiskalyApiKey "$(TestFiskalyApiKey)"
# -FiskalyApiSecret "$(TestFiskalyApiSecret)"
# -TssAdminPin "$(setTssVariablesStep.adminPin)"
# -TssId "$(setTssVariablesStep.tssId)"
# displayName: 'Re-create test TSE'

# - task: PowerShell@2
# inputs:
# targetType: 'filePath'
# filePath: azure-pipelines/scripts/update-scu.ps1
# arguments: >
# -AccountId "$(TestAccountId)"
# -AccountAccessToken "$(TestAccountAccessToken)"
# -ScuId "$(TestScuIdHttp)"
# -FiskalyApiKey "$(TestFiskalyApiKey)"
# -FiskalyApiSecret "$(TestFiskalyApiSecret)"
# -TssAdminPin "$(setTssVariablesStep.adminPin)"
# -TssId "$(setTssVariablesStep.tssId)"
# displayName: 'Update TSS values in HTTP SCU'
- task: PowerShell@2
inputs:
targetType: 'filePath'
filePath: azure-pipelines/scripts/create-fiskaly-tse.ps1
arguments: >
-FiskalyApiKey "$(TestFiskalyApiKey)"
-FiskalyApiSecret "$(TestFiskalyApiSecret)"
-TssAdminPin "$(setTssVariablesStep.adminPin)"
-TssId "$(setTssVariablesStep.tssId)"
displayName: 'Re-create test TSE'

# - task: PowerShell@2
# inputs:
# targetType: 'filePath'
# filePath: azure-pipelines/scripts/update-scu.ps1
# arguments: >
# -AccountId "$(TestAccountId)"
# -AccountAccessToken "$(TestAccountAccessToken)"
# -ScuId "$(TestScuIdGrpc)"
# -FiskalyApiKey "$(TestFiskalyApiKey)"
# -FiskalyApiSecret "$(TestFiskalyApiSecret)"
# -TssAdminPin "$(setTssVariablesStep.adminPin)"
# -TssId "$(setTssVariablesStep.tssId)"
# displayName: 'Update TSS values in gRPC SCU'
- task: PowerShell@2
inputs:
targetType: 'filePath'
filePath: azure-pipelines/scripts/create-cashbox.ps1
arguments: >
-AccountId "$(TestAccountId)"
-AccountAccessToken "$(TestAccountAccessToken)"
-TemplatePath "$(Build.SourcesDirectory)/azure-pipelines/scripts/http-cashbox.json"
-FiskalyApiKey "$(TestFiskalyApiKey)"
-FiskalyApiSecret "$(TestFiskalyApiSecret)"
-TssAdminPin "$(setTssVariablesStep.adminPin)"
-TssId "$(setTssVariablesStep.tssId)"
name: CreateHttpCashBox
displayName: 'Create cashbox with HTTP SCU'

# - powershell: |
# function Rebuild-Configuration($cashboxId, $accesstoken) {
# $headers = @{ accesstoken = $accesstoken ; cashboxid = $cashboxid }
# $uri = "https://helipad-sandbox.fiskaltrust.cloud/api/Configuration?rebuild=true"
# Invoke-WebRequest -uri $uri -Headers $headers
# }
# Rebuild-Configuration "0a54122c-e247-4498-9e40-cc667c17e6aa" "BH0MPsyWk3uqFy6fL3W2fPCRmjhXJrobOYSL9reW7c44kR7ycBN3G1vWmc1bdUbh4grU/c6CsQzYGcMH6RTJPr8="
# Rebuild-Configuration "61385be4-7d8d-403b-8860-fbc5a07ed128" "BKmQdtsJvAmhT12xewUXW39XyzJZhePtUN//u4svDPLAVlEs2nRefmZ9iFH7dCARdQjB7XYG6yILXmsmSVMtheE="
# displayName: 'Rebuild test cashboxes'
- task: PowerShell@2
inputs:
targetType: 'filePath'
filePath: azure-pipelines/scripts/create-cashbox.ps1
arguments: >
-AccountId "$(TestAccountId)"
-AccountAccessToken "$(TestAccountAccessToken)"
-TemplatePath "$(Build.SourcesDirectory)/azure-pipelines/scripts/grpc-cashbox.json"
-FiskalyApiKey "$(TestFiskalyApiKey)"
-FiskalyApiSecret "$(TestFiskalyApiSecret)"
-TssAdminPin "$(setTssVariablesStep.adminPin)"
-TssId "$(setTssVariablesStep.tssId)"
name: CreateGrpcCashBox
displayName: 'Create cashbox with gRPC SCU'

- task: NuGetToolInstaller@1

Expand All @@ -187,6 +179,11 @@ stages:
msbuildArgs: '/p:OutputPath=$(testOutputDirectory)'
configuration: '$(buildConfiguration)'

- task: Npm@1
inputs:
command: 'custom'
customCommand: '-g install appcenter-cli@latest'

- task: AppCenterTest@1
inputs:
appFile: '$(build.artifactStagingDirectory)/eu.fiskaltrust.androidlauncher.grpc.$(Build.BuildNumber).apk'
Expand All @@ -197,11 +194,12 @@ stages:
credentialsOption: 'serviceEndpoint'
serverEndpoint: 'VS App Center'
appSlug: 'fiskaltrust/fiskaltrust.Launcher'
devices: 'fdd661d1'
devices: 'fiskaltrust/smoke-tests'
localeOption: 'en_US'
prepareOptions: '--include-category grpc'
runOptions: --test-parameter "test_env=CASHBOXID=$(CreateGrpcCashBox.cashboxId)" --test-parameter "test_env=ACCESSTOKEN=$(CreateGrpcCashBox.accessToken)" --test-parameter "test_env=URL=$(CreateGrpcCashBox.url)"
displayName: Smoke tests (gRPC)

- task: AppCenterTest@1
inputs:
appFile: '$(build.artifactStagingDirectory)/eu.fiskaltrust.androidlauncher.http.$(Build.BuildNumber).apk'
Expand All @@ -212,28 +210,29 @@ stages:
credentialsOption: 'serviceEndpoint'
serverEndpoint: 'VS App Center'
appSlug: 'fiskaltrust/fiskaltrust.Launcher'
devices: 'fdd661d1'
devices: 'fiskaltrust/smoke-tests'
localeOption: 'en_US'
prepareOptions: '--include-category http'
runOptions: --test-parameter "test_env=CASHBOXID=$(CreateHttpCashBox.cashboxId)" --test-parameter "test_env=ACCESSTOKEN=$(CreateHttpCashBox.accessToken)" --test-parameter "test_env=URL=$(CreateHttpCashBox.url)"
displayName: Smoke tests (HTTP)

# - job: Cleanup
# dependsOn: SmokeTest
# condition: and(succeededOrFailed(), or(eq(variables['build.sourceBranch'], 'refs/heads/master'), startsWith(variables['build.sourceBranch'], 'refs/tags')))
# variables:
# FiskalyAdminPin: $[ dependencies.SmokeTest.outputs['setTssVariablesStep.adminPin'] ]
# FiskalyTssId: $[ dependencies.SmokeTest.outputs['setTssVariablesStep.tssId'] ]
# steps:
# - task: PowerShell@2
# inputs:
# targetType: 'filePath'
# filePath: azure-pipelines/scripts/delete-fiskaly-tse.ps1
# arguments: >
# -FiskalyApiKey "$(TestFiskalyApiKey)"
# -FiskalyApiSecret "$(TestFiskalyApiSecret)"
# -TssAdminPin "$(FiskalyAdminPin)"
# -TssId "$(FiskalyTssId)"
# displayName: 'Disable fiskaly test TSE'
- job: Cleanup
dependsOn: SmokeTest
condition: and(succeededOrFailed(), or(eq(variables['build.sourceBranch'], 'refs/heads/master'), startsWith(variables['build.sourceBranch'], 'refs/tags')))
variables:
FiskalyAdminPin: $[ dependencies.SmokeTest.outputs['setTssVariablesStep.adminPin'] ]
FiskalyTssId: $[ dependencies.SmokeTest.outputs['setTssVariablesStep.tssId'] ]
steps:
- task: PowerShell@2
inputs:
targetType: 'filePath'
filePath: azure-pipelines/scripts/delete-fiskaly-tse.ps1
arguments: >
-FiskalyApiKey "$(TestFiskalyApiKey)"
-FiskalyApiSecret "$(TestFiskalyApiSecret)"
-TssAdminPin "$(FiskalyAdminPin)"
-TssId "$(FiskalyTssId)"
displayName: 'Disable fiskaly test TSE'

- stage: ReleaseSandbox
displayName: Release packages to sandbox
Expand Down
19 changes: 19 additions & 0 deletions azure-pipelines/scripts/create-cashbox.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
param(
[string]$AccountId,
[string]$AccountAccessToken,
[string]$TemplatePath,
[string]$FiskalyApiKey,
[string]$FiskalyApiSecret,
[string]$TssAdminPin,
[string]$TssId)

$template = [string](Get-Content $TemplatePath -Raw)

$uri = "https://helipad-sandbox.fiskaltrust.cloud/api/configuration?description=delete-launcher-smoketests-$($env:BUILD_BUILDID)&fyapikey=$([uri]::EscapeDataString($FiskalyApiKey))&fyapisecret=$([uri]::EscapeDataString($FiskalyApiSecret))&fytssid=$([uri]::EscapeDataString($TssId))&fyadminpin=$([uri]::EscapeDataString($TssAdminPin))"
$headers = @{ accountid = $AccountId; accesstoken = $AccountAccessToken }

$response = Invoke-WebRequest -uri $uri -Headers $headers -Method POST -ContentType "application/json; charset=utf-8" -Body $($template | ConvertTo-Json) | ConvertFrom-Json

echo "##vso[task.setvariable variable=cashboxId;isOutput=true]$($response.cashboxid)"
echo "##vso[task.setvariable variable=accessToken;isOutput=true]$($response.accesstoken)"
echo "##vso[task.setvariable variable=url;isOutput=true]$($($response.configuration | ConvertFrom-Json).ftQueues[0].Url[0])"
55 changes: 55 additions & 0 deletions azure-pipelines/scripts/grpc-cashbox.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"ftCashBoxId": "|[cashbox_id]|",
"ftSignaturCreationDevices": [
{
"Id": "|[scu0_id]|",
"Package": "fiskaltrust.Middleware.SCU.DE.FiskalyCertified",
"Configuration": {
"ApiKey": "|[fyapikey]|",
"ApiSecret": "|[fyapisecret]|",
"TssId": "|[fytssid]|",
"AdminPin": "|[fyadminpin]|"
},
"Url": [
"grpc://localhost:18004"
]
}
],
"ftQueues": [
{
"Id": "|[queue0_id]|",
"Package": "fiskaltrust.Middleware.Queue.SQLite",
"Configuration": {
"init_ftQueue": [
{
"ftQueueId": "|[queue0_id]|",
"ftCashBoxId": "|[cashbox_id]|",
"CountryCode": "DE",
"Timeout": 15000
}
],
"init_ftQueueDE": [
{
"ftQueueDEId": "|[queue0_id]|",
"ftSignaturCreationUnitDEId": "|[scu0_id]|",
"CashBoxIdentification": "ft|[queue0_id_base64withoutspecialchars]|"
}
],
"init_ftSignaturCreationUnitAT": [],
"init_ftSignaturCreationUnitDE": [
{
"ftSignaturCreationUnitDEId": "|[scu0_id]|",
"Url": "[\"grpc://localhost:18004\"]"
}
],
"init_ftSignaturCreationUnitFR": [],
"init_ftCashBox": {
"ftCashBoxId": "|[cashbox_id]|"
}
},
"Url": [
"grpc://localhost:18005"
]
}
]
}
55 changes: 55 additions & 0 deletions azure-pipelines/scripts/http-cashbox.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"ftCashBoxId": "|[cashbox_id]|",
"ftSignaturCreationDevices": [
{
"Id": "|[scu0_id]|",
"Package": "fiskaltrust.Middleware.SCU.DE.FiskalyCertified",
"Configuration": {
"ApiKey": "|[fyapikey]|",
"ApiSecret": "|[fyapisecret]|",
"TssId": "|[fytssid]|",
"AdminPin": "|[fyadminpin]|"
},
"Url": [
"rest://localhost:18004"
]
}
],
"ftQueues": [
{
"Id": "|[queue0_id]|",
"Package": "fiskaltrust.Middleware.Queue.SQLite",
"Configuration": {
"init_ftQueue": [
{
"ftQueueId": "|[queue0_id]|",
"ftCashBoxId": "|[cashbox_id]|",
"CountryCode": "DE",
"Timeout": 15000
}
],
"init_ftQueueDE": [
{
"ftQueueDEId": "|[queue0_id]|",
"ftSignaturCreationUnitDEId": "|[scu0_id]|",
"CashBoxIdentification": "ft|[queue0_id_base64withoutspecialchars]|"
}
],
"init_ftSignaturCreationUnitAT": [],
"init_ftSignaturCreationUnitDE": [
{
"ftSignaturCreationUnitDEId": "|[scu0_id]|",
"Url": "[\"rest://localhost:18004\"]"
}
],
"init_ftSignaturCreationUnitFR": [],
"init_ftCashBox": {
"ftCashBoxId": "|[cashbox_id]|"
}
},
"Url": [
"rest://localhost:18005"
]
}
]
}
39 changes: 0 additions & 39 deletions azure-pipelines/scripts/update-scu.ps1

This file was deleted.

16 changes: 9 additions & 7 deletions test/fiskaltrust.AndroidLauncher.SmokeTests/TestConstants.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
namespace fiskaltrust.AndroidLauncher.SmokeTests
using System;

namespace fiskaltrust.AndroidLauncher.SmokeTests
{
public static class TestConstants
{
public static class Http
{
public const string CashboxId = "0a54122c-e247-4498-9e40-cc667c17e6aa";
public const string AccessToken = "BH0MPsyWk3uqFy6fL3W2fPCRmjhXJrobOYSL9reW7c44kR7ycBN3G1vWmc1bdUbh4grU/c6CsQzYGcMH6RTJPr8=";
public const string Url = "http://localhost:1500/dec70a9c-4bb4-47e3-9686-78995b2c9f4e";
public static readonly string CashboxId = Environment.GetEnvironmentVariable("CASHBOXID");
public static readonly string AccessToken = Environment.GetEnvironmentVariable("ACCESSTOKEN");
public static readonly string Url = Environment.GetEnvironmentVariable("URL").Replace("rest://", "http://");
}

public static class Grpc
{
public const string CashboxId = "61385be4-7d8d-403b-8860-fbc5a07ed128";
public const string AccessToken = "BKmQdtsJvAmhT12xewUXW39XyzJZhePtUN//u4svDPLAVlEs2nRefmZ9iFH7dCARdQjB7XYG6yILXmsmSVMtheE=";
public const string Url = "grpc://localhost:1400";
public static readonly string CashboxId = Environment.GetEnvironmentVariable("CASHBOXID");
public static readonly string AccessToken = Environment.GetEnvironmentVariable("ACCESSTOKEN");
public static readonly string Url = Environment.GetEnvironmentVariable("URL");
}

public const string InitialOperationReceipt = @"
Expand Down

0 comments on commit 0e66f65

Please sign in to comment.