Skip to content

Commit

Permalink
Remove mesh private key on logout
Browse files Browse the repository at this point in the history
  • Loading branch information
bartoszWojciechO committed Jan 16, 2025
1 parent a70aae6 commit 2c6eae6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions daemon/rpc_logout.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ func (r *RPC) Logout(ctx context.Context, in *pb.LogoutRequest) (payload *pb.Pay
delete(c.TokensData, c.AutoConnectData.ID)
c.AutoConnectData.ID = 0
c.Mesh = false
c.MeshPrivateKey = ""
return c
}); err != nil {
return nil, err
Expand Down
6 changes: 5 additions & 1 deletion daemon/rpc_logout_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@ func (mockApi) DeleteToken(token string) error { return nil }
func (mockApi) Logout(token string) error { return nil }

func TestLogout_Token(t *testing.T) {
cfgManagerMock := newMockConfigManager()

rpc := RPC{
ac: &workingLoginChecker{},
cm: newMockConfigManager(),
cm: cfgManagerMock,
norduser: &testnorduser.MockNorduserCombinedService{},
netw: &networker.Mock{},
ncClient: mockNC{},
Expand Down Expand Up @@ -84,12 +86,14 @@ func TestLogout_Token(t *testing.T) {
}
tokenData.Token = "1234"
c.TokensData[c.AutoConnectData.ID] = tokenData
c.MeshPrivateKey = "key"
return c
})
assert.NoError(t, err)
resp, err := rpc.Logout(context.Background(), &pb.LogoutRequest{PersistToken: test.persistToken})
assert.NoError(t, err)
assert.Equal(t, test.result, resp.Type)
assert.Equal(t, "", cfgManagerMock.c.MeshPrivateKey, "Mesh private key not removed after logout.")
})
}
}

0 comments on commit 2c6eae6

Please sign in to comment.