@@ -9,7 +9,14 @@ module Oracle.Validate.Requests.TestRun.Create
9
9
10
10
import Control.Monad (when )
11
11
import Control.Monad.Trans.Class (lift )
12
- import Core.Types.Basic (Commit (.. ), Directory (.. ), Duration (.. ), Repository (.. ), Try (.. ), Username (.. ))
12
+ import Core.Types.Basic
13
+ ( Commit (.. )
14
+ , Directory (.. )
15
+ , Duration (.. )
16
+ , Repository (.. )
17
+ , Try (.. )
18
+ , Username (.. )
19
+ )
13
20
import Core.Types.Change (Change (.. ), Key (.. ))
14
21
import Core.Types.Fact (Fact (.. ))
15
22
import Core.Types.Operation (Op (.. ), Operation (.. ))
@@ -44,8 +51,8 @@ import Text.JSON.Canonical
44
51
import User.Agent.Types (WhiteListKey (.. ))
45
52
import User.Types
46
53
( Phase (PendingT )
47
- , RegisterUserKey (.. )
48
54
, RegisterRoleKey (.. )
55
+ , RegisterUserKey (.. )
49
56
, TestRun (.. )
50
57
, TestRunState (.. )
51
58
, roleOfATestRun
@@ -119,17 +126,39 @@ data TestRunRejection
119
126
120
127
instance Monad m => ToJSON m TestRunRejection where
121
128
toJSON (UnacceptableDuration minDuration maxDuration) =
122
- stringJSON $ " unacceptable duration. Expecting duration to be between " <> show minDuration <> " and " <> show maxDuration
123
- toJSON (UnacceptableCommit (Repository org repo) (Commit commit))=
124
- stringJSON $ " unacceptable commit. The specified commit " <> show commit<> " cannot be found in the repository " <> show org<> " /" <> show repo
125
- toJSON (UnacceptableTryIndex (Try maxIx))=
126
- stringJSON $ " unacceptable try index. Expecting at most " <> show maxIx<> " run attempts for a given commit"
127
- toJSON (UnacceptableRole (RegisterRoleKey _ (Repository org repo) (Username user)))=
128
- stringJSON $ " unacceptable role. User " <> show user<> " has not been registered within the repository " <> show org<> " /" <> show repo
129
+ stringJSON
130
+ $ " unacceptable duration. Expecting duration to be between "
131
+ <> show minDuration
132
+ <> " and "
133
+ <> show maxDuration
134
+ toJSON (UnacceptableCommit (Repository org repo) (Commit commit)) =
135
+ stringJSON
136
+ $ " unacceptable commit. The specified commit "
137
+ <> show commit
138
+ <> " cannot be found in the repository "
139
+ <> show org
140
+ <> " /"
141
+ <> show repo
142
+ toJSON (UnacceptableTryIndex (Try maxIx)) =
143
+ stringJSON
144
+ $ " unacceptable try index. Expecting at most "
145
+ <> show maxIx
146
+ <> " run attempts for a given commit"
147
+ toJSON ( UnacceptableRole
148
+ (RegisterRoleKey _ (Repository org repo) (Username user))
149
+ ) =
150
+ stringJSON
151
+ $ " unacceptable role. User "
152
+ <> show user
153
+ <> " has not been registered within the repository "
154
+ <> show org
155
+ <> " /"
156
+ <> show repo
129
157
toJSON NoRegisteredKeyVerifiesTheSignature =
130
- stringJSON " no registered key verifies the signature"
158
+ stringJSON
159
+ " there is no registered Ed25519 SSH key that can verify the signature"
131
160
toJSON UserHasNoRegisteredSSHKeys =
132
- stringJSON " user has no Ed25519 registered SSH keys "
161
+ stringJSON " user has no Ed25519 SSH key registered "
133
162
toJSON (GithubResponseError err) =
134
163
object [" githubResponseError" .= err]
135
164
toJSON (GithubResponseStatusCodeError err) =
@@ -143,7 +172,7 @@ checkDuration
143
172
:: TestRunValidationConfig -> Duration -> Maybe TestRunRejection
144
173
checkDuration TestRunValidationConfig {maxDuration, minDuration} (Duration n)
145
174
| n < minDuration || n > maxDuration =
146
- Just $ UnacceptableDuration minDuration maxDuration
175
+ Just $ UnacceptableDuration minDuration maxDuration
147
176
| otherwise = Nothing
148
177
149
178
checkRole
0 commit comments