Skip to content

Commit

Permalink
fix: workspace token mentions
Browse files Browse the repository at this point in the history
  • Loading branch information
wass3r committed Apr 3, 2021
1 parent 293aa31 commit 43bb611
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
SLACK_TOKEN=
SLACK_WORKSPACE_TOKEN=
SLACK_SIGNING_SECRET=
12 changes: 6 additions & 6 deletions remote/slack/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -458,17 +458,17 @@ func populateBotUsers(slackUsers []slack.User, bot *models.Bot) {
// populateUserGroups populates slack user groups
func populateUserGroups(bot *models.Bot) {
userGroups := make(map[string]string)
wsAPI := slack.New(bot.SlackToken)
ugroups, err := wsAPI.GetUserGroups()
api := slack.New(bot.SlackToken)

ugroups, err := api.GetUserGroups()
if err != nil {
bot.Log.Debugf("Unable to retrieve usergroups: %s", err.Error())
bot.Log.Debug("Please double check your Slack Workspace token")
bot.Log.Debugf("unable to retrieve usergroups: %s - confirm you have usergroups:read permission set", err.Error())
}

for _, usergroup := range ugroups {
userGroups[usergroup.Handle] = usergroup.ID
}
// we don't need API anymore
wsAPI = nil

bot.UserGroups = userGroups
}

Expand Down
1 change: 0 additions & 1 deletion utils/access_check_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ func TestCanTrigger(t *testing.T) {
{"User not in ignore list", args{"jane.doe", "F123456", models.Rule{IgnoreUsers: []string{"john.doe", "jack.jill"}}, testBot}, true},
{"User is allowed but ignored", args{"jane.doe", "F123456", models.Rule{AllowUsers: []string{"jane.doe"}, IgnoreUsers: []string{"jane.doe", "jack.jill"}}, testBot}, false},
{"User is not allowed and ignored", args{"john.doe", "F123456", models.Rule{AllowUsers: []string{"jane.doe"}, IgnoreUsers: []string{"john.doe", "jack.jill"}}, testBot}, false},
{"Group - Workspace Token not supplied", args{"jane.doe", "F123456", models.Rule{AllowUserGroups: []string{"admins"}}, testBot}, false},
{"Group - Discord - Not supported", args{"jane.doe", "F123456", models.Rule{AllowUserGroups: []string{"admins"}}, discordBot}, false},
{"Group - Chat network not supported", args{"jane.doe", "F123456", models.Rule{AllowUserGroups: []string{"admins"}}, strangeBot}, false},
// TODO: figure out how to test this below:
Expand Down

0 comments on commit 43bb611

Please sign in to comment.