Implemented password hashing. Added and improved tests.

This commit is contained in:
Jonathan Bernard
2017-03-24 01:04:39 -05:00
parent b5a70f6de0
commit 52b7d2f48b
12 changed files with 113 additions and 56 deletions

View File

@ -35,6 +35,7 @@ type
artifactsRepo*: string
authSecret*: string
projects*: seq[ProjectDef]
pwdCost*: int8
users*: seq[UserRef]
# Equality on custom types
@ -62,7 +63,7 @@ proc getIfExists(n: JsonNode, key: string): JsonNode =
proc getOrFail(n: JsonNode, key: string, objName: string = ""): JsonNode =
# convenience method to get a key from a JObject or raise an exception
if not n.hasKey(key): raiseEx objName & " missing key " & key
if not n.hasKey(key): raiseEx objName & " missing key '" & key & "'"
return n[key]
# Configuration parsing code
@ -97,6 +98,7 @@ proc loadStrawBossConfig*(cfgFile: string): StrawBossConfig =
result = StrawBossConfig(
artifactsRepo: jsonCfg.getIfExists("artifactsRepo").getStr("artifacts"),
authSecret: jsonCfg.getOrFail("authSecret", "strawboss config").getStr,
pwdCost: int8(jsonCfg.getOrFail("pwdCost", "strawboss config").getNum),
projects: projectDefs,
users: users)
@ -170,8 +172,7 @@ proc `%`*(req: RunRequest): JsonNode =
"stepName": req.stepName,
"buildRef": req.buildRef,
"workspaceDir": req.workspaceDir,
"forceRebuild": req.forceRebuild
}
"forceRebuild": req.forceRebuild }
proc `$`*(s: BuildStatus): string = result = pretty(%s)
proc `$`*(req: RunRequest): string = result = pretty(%req)