From ef0588f3656eeabdef232a342bebdf5bdea73f62 Mon Sep 17 00:00:00 2001 From: Denis Arh Date: Sat, 22 Jan 2022 16:16:44 +0100 Subject: [PATCH] Fix federation node-pairing tests --- federation/service/node.go | 6 ++++-- federation/service/service.go | 1 + tests/federation/node_pairing_test.go | 4 ---- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/federation/service/node.go b/federation/service/node.go index 65e449d07..2a6c4f711 100644 --- a/federation/service/node.go +++ b/federation/service/node.go @@ -363,9 +363,11 @@ func (svc node) HandshakeConfirm(ctx context.Context, nodeID uint64) error { return err } - var accessToken []byte // Generate JWT token for the federated user - accessToken, err = svc.tokenIssuer(ctx, u) + var accessToken []byte + if accessToken, err = svc.tokenIssuer(ctx, u); err != nil { + return fmt.Errorf("could not confirm handshake: %w", err) + } n.UpdatedBy = auth.GetIdentityFromContext(ctx).Identity() n.UpdatedAt = now() diff --git a/federation/service/service.go b/federation/service/service.go index 7ee3863f8..3470c614d 100644 --- a/federation/service/service.go +++ b/federation/service/service.go @@ -95,6 +95,7 @@ func Initialize(_ context.Context, log *zap.Logger, s store.Storer, c Config) (e ctx, auth.WithIdentity(i), auth.WithScope("api"), + auth.WithAudience("federation"), ) }, c.Federation, diff --git a/tests/federation/node_pairing_test.go b/tests/federation/node_pairing_test.go index 835b3ba50..13574a979 100644 --- a/tests/federation/node_pairing_test.go +++ b/tests/federation/node_pairing_test.go @@ -180,10 +180,6 @@ func TestSuccessfulNodePairing(t *testing.T) { service.DefaultNode.SetHandshaker(&mockNodeHandshake{ init: func(ctx context.Context, n *types.Node, authToken string) error { h.apiInit(). - Debug(). - // make sure we do not use test auth-token for authentication but - // we do it with pairing token - Intercept(helpers.ReqHeaderRawAuthBearer([]byte(n.AuthToken))). Post(fmt.Sprintf("/nodes/%d/handshake", n.SharedNodeID)). FormData("pairToken", n.PairToken). FormData("authToken", authToken).