Skip to content

Commit ab717d9

Browse files
committed
fix: update role test
1 parent 6209c4d commit ab717d9

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

server/test/resolvers_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ import (
1111

1212
func TestResolvers(t *testing.T) {
1313
databases := map[string]string{
14-
// constants.DbTypeSqlite: "../../data.db",
14+
constants.DbTypeSqlite: "../../data.db",
1515
// constants.DbTypeArangodb: "http://localhost:8529",
1616
// constants.DbTypeMongodb: "mongodb://localhost:27017",
17-
constants.DbTypeCassandraDB: "127.0.0.1:9042",
17+
// constants.DbTypeCassandraDB: "127.0.0.1:9042",
1818
}
1919

2020
for dbType, dbURL := range databases {

server/test/update_user_test.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,7 @@ func updateUserTest(t *testing.T, s TestSetup) {
2424
})
2525

2626
user := *signupRes.User
27-
//! - Found out by testing
28-
//! that the 'supplier' role was being accepted by the server
29-
//! even though that it doesn't exist in the database.
30-
//! (checked it by doing fmt.Println() on role envs)
31-
//! But I'm not removing it as there is maybe a reason for it to be be here...
32-
//! - Appart from that, by removing it test returns 'unauthorized' successfully
27+
3328
adminRole := "supplier"
3429
userRole := "user"
3530
newRoles := []*string{&adminRole, &userRole}
@@ -46,6 +41,15 @@ func updateUserTest(t *testing.T, s TestSetup) {
4641
ID: user.ID,
4742
Roles: newRoles,
4843
})
44+
// supplier is not part of envs
45+
assert.Error(t, err)
46+
adminRole = "admin"
47+
envstore.EnvStoreObj.UpdateEnvVariable(constants.SliceStoreIdentifier, constants.EnvKeyProtectedRoles, []string{adminRole})
48+
newRoles = []*string{&adminRole, &userRole}
49+
_, err = resolvers.UpdateUserResolver(ctx, model.UpdateUserInput{
50+
ID: user.ID,
51+
Roles: newRoles,
52+
})
4953
assert.Nil(t, err)
5054
cleanData(email)
5155
})

0 commit comments

Comments
 (0)