Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding the remoteID migration, and making the synthetic user identification more robust #539

Merged
merged 13 commits into from
Mar 12, 2024
8 changes: 5 additions & 3 deletions server/ce2e/plugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import (
"golang.org/x/oauth2"
)

const pluginID = "com.mattermost.msteams-sync"

var fakeToken = oauth2.Token{Expiry: time.Now().Add(1 * time.Hour), AccessToken: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjozMDE2MjM5MDIyfQ.Kilb7fc4QwqfCad501vbAc861Ik1-30ytRtk8ZxEpgM"}

func setUserDefaultPlatform(t *testing.T, mattermost *mmcontainer.MattermostContainer, user *model.User, platform string) {
Expand All @@ -24,7 +26,7 @@ func setUserDefaultPlatform(t *testing.T, mattermost *mmcontainer.MattermostCont
require.NoError(t, err)
preferences = append(preferences, model.Preference{
UserId: user.Id,
Category: "pp_com.mattermost.msteams-sync",
Category: "pp_" + pluginID,
Name: "platform",
Value: platform,
})
Expand Down Expand Up @@ -382,7 +384,7 @@ func TestSelectiveSync(t *testing.T) {
defer conn.Close()

// Mark user as synthetic
_, err = conn.Exec("UPDATE Users SET RemoteId = (SELECT remoteId FROM remoteclusters) WHERE Username = 'msteams_synthetic'")
_, err = conn.Exec("UPDATE Users SET RemoteId = (SELECT remoteId FROM remoteclusters WHERE pluginid=$1) WHERE Username = 'msteams_synthetic'", pluginID)
require.NoError(t, err)

team, _, err := adminClient.GetTeamByName(context.Background(), "test", "")
Expand Down Expand Up @@ -489,7 +491,7 @@ func TestSelectiveSync(t *testing.T) {
for _, enabledSelectiveSync := range []bool{false, true} {
config, _, err := adminClient.GetConfig(context.Background())
require.NoError(t, err)
config.PluginSettings.Plugins["com.mattermost.msteams-sync"]["selectiveSync"] = enabledSelectiveSync
config.PluginSettings.Plugins[pluginID]["selectiveSync"] = enabledSelectiveSync
_, _, err = adminClient.UpdateConfig(context.Background(), config)
require.NoError(t, err)

Expand Down
1 change: 1 addition & 0 deletions server/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,7 @@ func (p *Plugin) onActivate() error {
if err = p.API.UnregisterPluginForSharedChannels(pluginID); err != nil {
jespino marked this conversation as resolved.
Show resolved Hide resolved
p.API.LogWarn("Unable to unregister plugin for shared channels", "error", err)
}
p.API.LogInfo("Unregistering plugin for shared channels since sync msg disabled")
jespino marked this conversation as resolved.
Show resolved Hide resolved
}

if p.store == nil {
Expand Down
1 change: 0 additions & 1 deletion server/testutils/containere2e/containere2e.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ func NewE2ETestPlugin(t *testing.T, extraOptions ...mmcontainer.MattermostCustom
options := []mmcontainer.MattermostCustomizeRequestOption{
mmcontainer.WithPlugin(filename, "com.mattermost.msteams-sync", pluginConfig),
mmcontainer.WithLogConsumers(&tLogConsumer{t: t}),
mmcontainer.WithEnv("MM_EXPERIMENTALSETTINGS_ENABLESHAREDCHANNELS", "true"),
mmcontainer.WithNetwork(newNetwork),
}
options = append(options, extraOptions...)
Expand Down
Loading