Skip to content

Commit 89570dc

Browse files
committed
[cli] feat: decrypt URLs even when shouwing all fact test-runs
1 parent 922bb92 commit 89570dc

File tree

2 files changed

+26
-8
lines changed

2 files changed

+26
-8
lines changed

cli/docs/requester-role.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,4 +163,14 @@ You can find all running test-runs for a user with
163163
164164
```bash
165165
anti facts test-runs running --whose alice
166-
```
166+
```
167+
168+
Because the result URL is encrypted, you need to provide the requester SSH for decryption (see above). This work for the done selector and the full test-runs list.
169+
170+
```bash
171+
anti facts test-runs done --ssh-file PATH_TO_YOUR_SSH_FILE --ask-ssh-passphrase
172+
```
173+
174+
```bash
175+
anti facts test-runs --ssh-file PATH_TO_YOUR_SSH_FILE --ask-ssh-passphrase
176+
```

cli/src/Facts.hs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
{-# OPTIONS_GHC -Wno-unrecognised-pragmas #-}
2-
3-
{-# HLINT ignore "Use fewer imports" #-}
41
module Facts
52
( FactsSelection (..)
63
, TestRunSelection (..)
@@ -27,7 +24,7 @@ import Lib.SSH.Private (KeyPair (..), SSHClient, WithSelector (..))
2724
import Lib.SSH.Public (decodePublicKey)
2825
import MPFS.API (MPFS, mpfsGetTokenFacts)
2926
import Oracle.Config.Types (Config, ConfigKey)
30-
import Text.JSON.Canonical (FromJSON, JSValue, ToJSON)
27+
import Text.JSON.Canonical (FromJSON (..), JSValue, ToJSON (..))
3128
import User.Agent.Types (TestRunId (..), WhiteListKey)
3229
import User.Types
3330
( Phase (..)
@@ -127,7 +124,7 @@ factsCmd mDecrypt mpfs tokenId selection = do
127124
testRunCommon ids whose
128125
core (TestRunFacts (TestRunDone ids whose)) = do
129126
facts <-
130-
testRunCommon ids whose <&> map decrypt
127+
testRunCommon ids whose <&> fmap decrypt
131128
pure $ filterOn facts factValue $ \case
132129
Finished{} -> True
133130
_ -> False
@@ -138,12 +135,23 @@ factsCmd mDecrypt mpfs tokenId selection = do
138135
Rejected{} -> True
139136
_ -> False
140137
core (TestRunFacts (AnyTestRuns ids whose)) =
141-
testRunCommon ids whose
138+
testRunCommon ids whose <&> fmap (parseDecrypt decrypt)
142139
core ConfigFact = retrieveAnyFacts mpfs tokenId
143140
core WhiteListedFacts = retrieveAnyFacts mpfs tokenId
144-
core AllFacts = retrieveAnyFacts mpfs tokenId
141+
core AllFacts =
142+
retrieveAnyFacts mpfs tokenId
143+
145144
core selection
146145

146+
parseDecrypt
147+
:: ( Fact TestRun (TestRunState DoneT)
148+
-> Fact TestRun (TestRunState DoneT)
149+
)
150+
-> Fact TestRun JSValue
151+
-> Fact TestRun JSValue
152+
parseDecrypt decrypt f =
153+
maybe f (fmap (runIdentity . toJSON) . decrypt) $ mapM fromJSON f
154+
147155
filterOn :: [a] -> (a -> b) -> (b -> Bool) -> [a]
148156
filterOn xs f p = filter (p . f) xs
149157

0 commit comments

Comments
 (0)