NOISSUE - Fix SDK Tests (#49)

* NOISSUE - Fix Users Tests (#42)

* Fix users tests

Fix tests in users service to ensure there are no failing tests

* test: update tests with domains

Added test cases to cover the authn and authz functionality of the user service with domains integration.  The tests involve mocking function calls, setting up expectations, and checking for expected results. The code includes conditional statements and different scenarios to ensure the proper behavior of the functions.
This commit also fixes updating client secret

Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>

* NOISSUE - Fix loading Auth config (#64)

Fix bug in loading auth config and also refactor postgres connect

---------

Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>

* Fix failing tests in SDK

Fix failing tests in `sdk` package.

* fix(tests): update sdk tests with domains

Add domain integration and fix failing tests on SDK package

Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>

---------

Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
This commit is contained in:
b1ackd0t
2023-11-27 17:50:03 +03:00
committed by GitHub
parent 98007ad669
commit 151eaeb2b3
27 changed files with 756 additions and 661 deletions
+1 -15
View File
@@ -109,8 +109,7 @@ var cmdThings = []cobra.Command{
"Usage:\n" +
"\tmagistrala-cli things update <thing_id> '{\"name\":\"new name\", \"metadata\":{\"key\": \"value\"}}' $USERTOKEN\n" +
"\tmagistrala-cli things update tags <thing_id> '{\"tag1\":\"value1\", \"tag2\":\"value2\"}' $USERTOKEN\n" +
"\tmagistrala-cli things update secret <thing_id> newsecret $USERTOKEN\n" +
"\tmagistrala-cli things update owner <thing_id> <owner_id> $USERTOKEN\n",
"\tmagistrala-cli things update secret <thing_id> <newsecret> $USERTOKEN\n",
Run: func(cmd *cobra.Command, args []string) {
if len(args) != 4 && len(args) != 3 {
logUsage(cmd.Use)
@@ -145,19 +144,6 @@ var cmdThings = []cobra.Command{
return
}
if args[0] == "owner" {
thing.ID = args[1]
thing.Owner = args[2]
thing, err := sdk.UpdateThingOwner(thing, args[3])
if err != nil {
logError(err)
return
}
logJSON(thing)
return
}
if err := json.Unmarshal([]byte(args[1]), &thing); err != nil {
logError(err)
return
+4 -5
View File
@@ -148,8 +148,7 @@ var cmdUsers = []cobra.Command{
"Usage:\n" +
"\tmagistrala-cli users update <user_id> '{\"name\":\"new name\", \"metadata\":{\"key\": \"value\"}}' $USERTOKEN - updates user name and metadata\n" +
"\tmagistrala-cli users update tags <user_id> '[\"tag1\", \"tag2\"]' $USERTOKEN - updates user tags\n" +
"\tmagistrala-cli users update identity <user_id> newidentity@example.com $USERTOKEN - updates user identity\n" +
"\tmagistrala-cli users update owner <user_id> <owner_id> $USERTOKEN - updates user owner\n",
"\tmagistrala-cli users update identity <user_id> newidentity@example.com $USERTOKEN - updates user identity\n",
Run: func(cmd *cobra.Command, args []string) {
if len(args) != 4 && len(args) != 3 {
logUsage(cmd.Use)
@@ -187,10 +186,10 @@ var cmdUsers = []cobra.Command{
}
if args[0] == "owner" {
if args[0] == "role" {
user.ID = args[1]
user.Owner = args[2]
user, err := sdk.UpdateUserOwner(user, args[3])
user.Role = args[2]
user, err := sdk.UpdateUserRole(user, args[3])
if err != nil {
logError(err)
return