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:
Manuel Imperiale
2022-02-01 17:33:23 +01:00
committed by GitHub
parent e8a51842aa
commit 9e0947a355
84 changed files with 442 additions and 418 deletions
+8 -8
View File
@@ -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,
},
}