function Set-RedisToken { <# .SYNOPSIS Method to set a Redis token to simulate a login event from Synthetic user. .PARAMETER BankUrl Full URL of the bank we're going to auth to. .PARAMETER UserName Username of the Synthetic .PARAMETER ComparisonOrbVersion Supply a string of the orb version you want to compare against for determining redis key string formatting .EXAMPLE $nonce = Set-RedisToken -BankUrl https://cu1-red9.dev.alkamitech.com -UserName -mike.brady .NOTES Returns a guid representing the nonce that was inserted #> [cmdletbinding()] param ( [Parameter(Mandatory = $true)] $BankUrl, [Parameter(Mandatory = $true)] $UserName, [Parameter(Mandatory = $false)] $ComparisonOrbVersion = "2021.4" ) $logLead = (Get-LogLeadName) $logFilePath = (Get-WebTestLogPath -BankUrl $BankUrl) $orbVersion = Get-OrbVersion Write-Host "$loglead : orb version detected: $orbVersion" -ForegroundColor Green $comparedSemVer = Compare-SemVer -Version1 $orbVersion -Version2 $ComparisonOrbVersion Write-Host "$loglead : Compared SemVer Result: $comparedSemVer" -ForegroundColor Green if($comparedSemVer -eq -1){ Write-Host "$loglead : Detected orb version is LESS than $ComparisonOrbVersion" -ForegroundColor Green Write-Host "$loglead : Setting Redis Key with 'E:' prefix" -ForegroundColor Green $key = "E:{${BankUrl}}:System.String:${UserName}__AUTHENTICATION_NONCE__" } else { Write-Host "$loglead : Detected orb version is Not LESS than $ComparisonOrbVersion" -ForegroundColor Green Write-Host "$loglead : Setting Redis Key without 'E:' prefix" -ForegroundColor Green $key = "{${BankUrl}}:System.String:${UserName}__AUTHENTICATION_NONCE__" } $guid = New-Guid $nonce = "`"$guid`"" $redisConnectionString = Get-ConnectionString -name "RedisSetting" "$logLead : key : $key" | Tee-OutFile -Append -FilePath $logFilePath | Write-Verbose "$logLead : nonce : $nonce" | Tee-OutFile -Append -FilePath $logFilePath | Write-Verbose try { Invoke-RedisScript -ConnectionString $redisConnectionString -ScriptBlock { $ttlTimespan = [System.TimeSpan]::new(0,10,0) Add-RedisKey -Key $key -Value $nonce -TTL $ttlTimespan | Out-Null } } catch { $_.exception | Tee-OutFile -Append -FilePath $logFilePath | Write-Error } # do we need to do an audit to the audit table? return $guid }