Bound authentication probe startup synchronization
This commit is contained in:
parent
9ad8d27adf
commit
b196f9e17b
1 changed files with 36 additions and 7 deletions
|
|
@ -1,14 +1,16 @@
|
|||
module Main (main) where
|
||||
|
||||
import Control.Concurrent (threadDelay)
|
||||
import Control.Exception (throwIO, try)
|
||||
import qualified Data.ByteString as BS
|
||||
import qualified Data.ByteString.Base16 as B16
|
||||
import qualified Data.ByteString.Char8 as B8
|
||||
import Data.List (find)
|
||||
import System.Entropy (getEntropy)
|
||||
import Nuthatch.Probe.Assert
|
||||
import Nuthatch.Probe.Curl
|
||||
import Nuthatch.Probe.Oidc
|
||||
import Nuthatch.Probe.ProductClient
|
||||
import System.Entropy (getEntropy)
|
||||
import System.IO.Temp (withSystemTempDirectory)
|
||||
|
||||
main :: IO ()
|
||||
|
|
@ -17,6 +19,7 @@ main =
|
|||
context <- newProbeContext directory
|
||||
runId <- B8.unpack . B16.encode <$> getEntropy 8
|
||||
verifyCredentialScope
|
||||
waitForApplication context
|
||||
verifyPublicBoundary context
|
||||
userA <- requireEnv "NUTHATCH_OIDC_USER_A"
|
||||
sessionA <- login context True userA "a"
|
||||
|
|
@ -28,6 +31,25 @@ main =
|
|||
verifyLogout context sessionA
|
||||
putStrLn "OIDC application boundary passed"
|
||||
|
||||
waitForApplication :: ProbeContext -> IO ()
|
||||
waitForApplication context = go 30
|
||||
where
|
||||
go :: Int -> IO ()
|
||||
go remaining = do
|
||||
result <-
|
||||
try (curl
|
||||
[ "--connect-timeout", "1"
|
||||
, "--max-time", "2"
|
||||
, probeBase context <> "/readyz"
|
||||
])
|
||||
:: IO (Either CurlTransportFailure CurlResponse)
|
||||
case result of
|
||||
Right _ -> pure ()
|
||||
Left failure
|
||||
| curlTransportExitCode failure == 7 && remaining > 1 ->
|
||||
threadDelay 1000000 >> go (remaining - 1)
|
||||
| otherwise -> throwIO failure
|
||||
|
||||
verifyCredentialScope :: IO ()
|
||||
verifyCredentialScope = do
|
||||
endpoint <- requireEnv "NUTHATCH_S3_ENDPOINT"
|
||||
|
|
|
|||
Loading…
Reference in a new issue