-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c244176
commit 483701a
Showing
2 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
test_that("Envelope reading works", { | ||
|
||
key <- keygen_kyber() | ||
secret_message <- "Hello world!!" | ||
env <- envelope_create(secret_message, key$public) | ||
fn <- write_envelope(env) | ||
|
||
retrieved_envelope <- read_envelope(fn) | ||
expect_identical(env, retrieved_envelope) | ||
|
||
expect_error(read_envelope("/not_a_valid/file"), "Invalid 'file_name'") | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
test_that("Envelope writing works", { | ||
|
||
key <- keygen_kyber() | ||
secret_message <- "Hello world!!" | ||
env <- envelope_create(secret_message, key$public) | ||
dest <- tempfile() | ||
|
||
fn <- write_envelope(env, dest) | ||
expect_equal(fn, dest) | ||
expect_true(file.exists(fn)) | ||
|
||
fn <- write_envelope(env) | ||
expect_true(file.exists(fn)) | ||
|
||
expect_error(write_envelope("envelope"), | ||
"'envelope' parameter does not have the expected class") | ||
expect_error(write_envelope(key), | ||
"'envelope' parameter does not have the expected class") | ||
|
||
if (Sys.info()[1] == "Linux") { | ||
dest <- "/home/file.env" # Shouldn't be able to write into root's home dir | ||
} else if ((Sys.info()[1] == "Windows")) { | ||
dest <- "c:/Windows/system32/file.env" # Shouldn't be able to write into system dir | ||
} else { | ||
skip("Unknown OS") | ||
} | ||
expect_error(write_envelope(env, dest), "Permission denied") | ||
}) |