mirror of
https://github.com/netbirdio/netbird.git
synced 2026-09-26 08:39:06 +02:00
Simply error surfacing
This commit is contained in:
@@ -26,6 +26,8 @@ func denialCode(reason string) (string, bool) {
|
||||
return "session_held", true
|
||||
case ipcauth.ErrorReasonNotProfileOwner:
|
||||
return "not_profile_owner", true
|
||||
case ipcauth.ErrorReasonProfileUnowned:
|
||||
return "profile_unowned", true
|
||||
default:
|
||||
return "permission_denied", false
|
||||
}
|
||||
|
||||
@@ -70,6 +70,7 @@ func TestClassifyMapsEveryDaemonReason(t *testing.T) {
|
||||
{"privilege", ipcauth.PrivilegeError("Claiming a profile requires root.", "sudo netbird profile claim"), "privilege_required", true},
|
||||
{"session held", ipcauth.SessionHeldError("switching profile"), "session_held", true},
|
||||
{"not owner", ipcauth.NotOwnerError("reading the profile configuration"), "not_profile_owner", false},
|
||||
{"unowned", ipcauth.UnownedError("connecting", "default", false), "profile_unowned", true},
|
||||
} {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
got := c.classify(tc.err)
|
||||
@@ -116,6 +117,12 @@ func TestDenialHeadlinesResolveInTheShippedBundle(t *testing.T) {
|
||||
"This profile belongs to another user.",
|
||||
"Reading the profile configuration is refused because the profile it addresses belongs to another user.",
|
||||
},
|
||||
{
|
||||
"unowned",
|
||||
ipcauth.UnownedError("connecting", "default", false),
|
||||
"This profile has no owner yet.",
|
||||
"Connecting is refused because the profile it addresses has no owner on record.",
|
||||
},
|
||||
} {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
got := c.classify(tc.err)
|
||||
|
||||
Reference in New Issue
Block a user