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

Remove mesh private key on logout #743

Merged
merged 1 commit into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.")
})
}
}
Loading