mirror of
https://github.com/status-im/nim-codex.git
synced 2025-01-10 10:55:48 +00:00
7efa9177df
* extra utilities and tweaks * add atlas lock * update ignores * break build into it's own script * update url rules * base off codexdht's * compile fixes for Nim 1.6.14 * update submodules * convert mapFailure to procs to work around type resolution issues * add toml parser for multiaddress * change error type on keyutils * bump nimbus build to use 1.6.14 * update gitignore * adding new deps submodules * bump nim ci version * even more fixes * more libp2p changes * update keys * fix eventually function * adding coverage test file * move coverage to build.nims * use nimcache/coverage * move libp2p import for tests into helper.nim * remove named bin * bug fixes for networkpeers (from Dmitriy) --------- Co-authored-by: Dmitriy Ryajov <dryajov@gmail.com>
34 lines
868 B
Nim
34 lines
868 B
Nim
import std/unittest
|
|
import std/os
|
|
import pkg/questionable
|
|
import codex/utils/keyutils
|
|
import ../helpers
|
|
|
|
when defined(windows):
|
|
import stew/windows/acl
|
|
|
|
checksuite "keyutils":
|
|
let path = getTempDir() / "CodexTest"
|
|
|
|
setup:
|
|
os.createDir(path)
|
|
|
|
teardown:
|
|
os.removeDir(path)
|
|
|
|
test "creates a key file when it does not exist yet":
|
|
check setupKey(path / "keyfile").isOk
|
|
check fileExists(path / "keyfile")
|
|
|
|
test "stores key in a file that's only readable by the user":
|
|
discard setupKey(path / "keyfile").get()
|
|
when defined(posix):
|
|
check getFilePermissions(path / "keyfile") == {fpUserRead, fpUserWrite}
|
|
when defined(windows):
|
|
check checkCurrentUserOnlyACL(path / "keyfile").get()
|
|
|
|
test "reads key file when it does exist":
|
|
let key = setupKey(path / "keyfile").get()
|
|
check setupKey(path / "keyfile").get() == key
|
|
|