mirror of
https://github.com/absmach/magistrala.git
synced 2026-08-07 07:14:46 +00:00
MF-1261 - Use StatusUnauthorized for authn and StatusForbidden for authz (#1538)
* MF-1261 - Use StatusUnauthorized for authn and StatusForbidden for authz Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * ErrExternalKey typo Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Rename ErrUnauthorizedAcces -> ErrAuthentication Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix bootstrap error Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix status code in openapi Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix test description Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix test description Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix test description Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Add errors cases Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix status codes Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Add gRPC stutus code Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix tests description Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix openapi and encodeError Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix grpc message Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix test descriptions Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Revert sdk error Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix typo Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
This commit is contained in:
@@ -58,11 +58,11 @@ func TestCreateSubscription(t *testing.T) {
|
||||
err: errors.ErrConflict,
|
||||
},
|
||||
{
|
||||
desc: "test unauthorized access",
|
||||
desc: "test with empty token",
|
||||
token: "",
|
||||
sub: notifiers.Subscription{Contact: exampleUser1, Topic: "valid.topic"},
|
||||
id: "",
|
||||
err: errors.ErrUnauthorizedAccess,
|
||||
err: errors.ErrAuthentication,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -103,11 +103,11 @@ func TestViewSubscription(t *testing.T) {
|
||||
err: errors.ErrNotFound,
|
||||
},
|
||||
{
|
||||
desc: "test unauthorized access",
|
||||
desc: "test with empty token",
|
||||
token: "",
|
||||
id: id,
|
||||
sub: notifiers.Subscription{},
|
||||
err: errors.ErrUnauthorizedAccess,
|
||||
err: errors.ErrAuthentication,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -178,7 +178,7 @@ func TestListSubscriptions(t *testing.T) {
|
||||
err: errors.ErrNotFound,
|
||||
},
|
||||
{
|
||||
desc: "test unauthorized access",
|
||||
desc: "test with empty token",
|
||||
token: "",
|
||||
pageMeta: notifiers.PageMetadata{
|
||||
Offset: 2,
|
||||
@@ -186,7 +186,7 @@ func TestListSubscriptions(t *testing.T) {
|
||||
Topic: "topic.subtopic.13",
|
||||
},
|
||||
page: notifiers.Page{},
|
||||
err: errors.ErrUnauthorizedAccess,
|
||||
err: errors.ErrAuthentication,
|
||||
},
|
||||
{
|
||||
desc: "test with topic",
|
||||
@@ -260,10 +260,10 @@ func TestRemoveSubscription(t *testing.T) {
|
||||
err: nil,
|
||||
},
|
||||
{
|
||||
desc: "test unauthorized access",
|
||||
desc: "test with empty token",
|
||||
token: "",
|
||||
id: id,
|
||||
err: errors.ErrUnauthorizedAccess,
|
||||
err: errors.ErrAuthentication,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user