3
0

Fix federation node-pairing tests

This commit is contained in:
Denis Arh
2022-01-22 16:16:44 +01:00
parent f9c8066e2d
commit ef0588f365
3 changed files with 5 additions and 6 deletions

View File

@@ -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()

View File

@@ -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,

View File

@@ -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).