Skip to content

Commit

Permalink
Support and test "psk" in client connection (deephaven#4378)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexpeters1208 authored Aug 28, 2023
1 parent 3c5370b commit 5627e13
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
7 changes: 7 additions & 0 deletions R/rdeephaven/R/client_wrapper.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ Client <- R6Class("Client",
} else {
stop("Basic authentication was requested, but 'auth_token' was not provided, and at most one of 'username' or 'password' was provided. Please provide either 'username' and 'password', or 'auth_token'.")
}
} else if (auth_type == "psk") {
if (auth_token != "") {
verify_string("auth_token", auth_token, TRUE)
options$set_custom_authentication("io.deephaven.authentication.psk.PskAuthenticationHandler", auth_token)
} else {
stop("Pre-shared key authentication was requested, but no 'auth_token' was provided.")
}
} else {
if (auth_token != "") {
verify_string("auth_token", auth_token, TRUE)
Expand Down
4 changes: 4 additions & 0 deletions R/rdeephaven/inst/tests/testthat/test_client_wrapper.R
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,10 @@ test_that("client constructor fails nicely with bad inputs", {
Client$new(target = "localhost:10000", auth_type = "basic", username = "user", password = "pass", auth_token = "token"),
"Basic authentication was requested, but 'auth_token' was provided, as well as least one of 'username' and 'password'. Please provide either 'username' and 'password', or 'auth_token'."
)
expect_error(
Client$new(target = "localhost:10000", auth_type = "psk"),
"Pre-shared key authentication was requested, but no 'auth_token' was provided."
)
expect_error(
Client$new(target = "localhost:10000", auth_type = "custom"),
"Custom authentication was requested, but no 'auth_token' was provided."
Expand Down

0 comments on commit 5627e13

Please sign in to comment.