Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

node,rpc: JWT auth dialing + auth endpoints getters + auth testing #24911

Merged
merged 11 commits into from
Sep 2, 2022
Prev Previous commit
Next Next commit
node: update JWT auth test
  • Loading branch information
fjl committed Aug 31, 2022
commit 0a3e2f867f909c3eee657fb4700d81c451fc6235
8 changes: 3 additions & 5 deletions node/node_auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ type authTest struct {

func (at *authTest) Run(t *testing.T) {
ctx := context.Background()
cl, err := rpc.DialWithAuth(ctx, at.endpoint, at.prov)
cl, err := rpc.DialOptions(ctx, at.endpoint, rpc.WithHTTPAuth(at.prov))
if at.expectDialFail {
if err == nil {
t.Fatal("expected initial dial to fail")
Expand All @@ -65,6 +65,7 @@ func (at *authTest) Run(t *testing.T) {
if err != nil {
t.Fatalf("failed to dial rpc endpoint: %v", err)
}

var x string
err = cl.CallContext(ctx, &x, "engine_helloWorld")
if at.expectCall1Fail {
Expand All @@ -80,6 +81,7 @@ func (at *authTest) Run(t *testing.T) {
if x != "hello engine" {
t.Fatalf("method was silent but did not return expected value: %q", x)
}

err = cl.CallContext(ctx, &x, "eth_helloWorld")
if at.expectCall2Fail {
if err == nil {
Expand Down Expand Up @@ -203,10 +205,6 @@ func TestAuthEndpoints(t *testing.T) {
{name: "ws good", endpoint: node.WSAuthEndpoint(), prov: goodAuth, expectCall1Fail: false},
{name: "http good", endpoint: node.HTTPAuthEndpoint(), prov: goodAuth, expectCall1Fail: false},

// Try nil auth
{name: "ws nil auth provider", endpoint: node.WSAuthEndpoint(), prov: nil, expectDialFail: true},
{name: "http nil auth provider", endpoint: node.HTTPAuthEndpoint(), prov: nil, expectDialFail: true},

// Try a bad auth
{name: "ws bad", endpoint: node.WSAuthEndpoint(), prov: badAuth, expectDialFail: true}, // ws auth is immediate
{name: "http bad", endpoint: node.HTTPAuthEndpoint(), prov: badAuth, expectCall1Fail: true}, // http auth is on first call
Expand Down