@@ -9,7 +9,7 @@ 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 (.. ))
12
+ import Core.Types.Basic (Commit (.. ), Directory (.. ), Duration (.. ), Repository (.. ), Try (.. ), Username ( .. ) )
13
13
import Core.Types.Change (Change (.. ), Key (.. ))
14
14
import Core.Types.Fact (Fact (.. ))
15
15
import Core.Types.Operation (Op (.. ), Operation (.. ))
@@ -45,6 +45,7 @@ import User.Agent.Types (WhiteListKey (..))
45
45
import User.Types
46
46
( Phase (PendingT )
47
47
, RegisterUserKey (.. )
48
+ , RegisterRoleKey (.. )
48
49
, TestRun (.. )
49
50
, TestRunState (.. )
50
51
, roleOfATestRun
@@ -107,7 +108,7 @@ data TestRunRejection
107
108
= UnacceptableDuration Int Int
108
109
| UnacceptableCommit Repository Commit
109
110
| UnacceptableTryIndex Try
110
- | UnacceptableRole
111
+ | UnacceptableRole RegisterRoleKey
111
112
| NoRegisteredKeyVerifiesTheSignature
112
113
| UserHasNoRegisteredSSHKeys
113
114
| GithubResponseError GithubResponseError
@@ -123,8 +124,8 @@ instance Monad m => ToJSON m TestRunRejection where
123
124
stringJSON $ " unacceptable commit. The specified commit " <> show commit<> " cannot be found in the repository " <> show org<> " /" <> show repo
124
125
toJSON (UnacceptableTryIndex (Try maxIx))=
125
126
stringJSON $ " unacceptable try index. Expecting at most " <> show maxIx<> " run attempts for a given commit"
126
- toJSON UnacceptableRole =
127
- stringJSON " unacceptable role"
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
128
129
toJSON NoRegisteredKeyVerifiesTheSignature =
129
130
stringJSON " no registered key verifies the signature"
130
131
toJSON UserHasNoRegisteredSSHKeys =
@@ -154,7 +155,7 @@ checkRole
154
155
let roleFact = roleOfATestRun testRun
155
156
if Fact roleFact () `elem` fs
156
157
then return Nothing
157
- else return $ Just UnacceptableRole
158
+ else return $ Just ( UnacceptableRole roleFact)
158
159
159
160
checkWhiteList
160
161
:: Monad m
0 commit comments