diff --git a/pkg/bootstrap/builder.go b/pkg/bootstrap/builder.go index c9a4ff500..f9e2d9fc1 100644 --- a/pkg/bootstrap/builder.go +++ b/pkg/bootstrap/builder.go @@ -325,6 +325,17 @@ func (b *Builder) Build() (*probod.FullConfig, error) { }) } + if googleWorkspaceClientID := b.getEnv("CONNECTOR_GOOGLE_WORKSPACE_CLIENT_ID"); googleWorkspaceClientID != "" { + cfg.Probod.Connectors = append(cfg.Probod.Connectors, probod.ConnectorConfig{ + Provider: "GOOGLE_WORKSPACE", + Protocol: "oauth2", + RawConfig: probod.ConnectorConfigOAuth2{ + ClientID: googleWorkspaceClientID, + ClientSecret: b.getEnv("CONNECTOR_GOOGLE_WORKSPACE_CLIENT_SECRET"), + }, + }) + } + return cfg, nil } @@ -370,6 +381,7 @@ func (b *Builder) validateRequired() error { {"CONNECTOR_SENTRY", []string{"CLIENT_SECRET"}}, {"CONNECTOR_INTERCOM", []string{"CLIENT_SECRET"}}, {"CONNECTOR_BREX", []string{"CLIENT_SECRET"}}, + {"CONNECTOR_GOOGLE_WORKSPACE", []string{"CLIENT_SECRET"}}, } for _, p := range oauthProviders { diff --git a/pkg/bootstrap/builder_test.go b/pkg/bootstrap/builder_test.go index 16620f7b9..5ebbb72d7 100644 --- a/pkg/bootstrap/builder_test.go +++ b/pkg/bootstrap/builder_test.go @@ -85,6 +85,16 @@ func TestBuilder_Build_MissingRequiredEnvVars(t *testing.T) { }, wantMissing: []string{"CONNECTOR_SLACK_CLIENT_SECRET", "CONNECTOR_SLACK_SIGNING_SECRET"}, }, + { + name: "google workspace connector missing required fields", + env: map[string]string{ + "PROBOD_ENCRYPTION_KEY": "key", + "AUTH_COOKIE_SECRET": "secret", + "AUTH_PASSWORD_PEPPER": "pepper", + "CONNECTOR_GOOGLE_WORKSPACE_CLIENT_ID": "client-id", + }, + wantMissing: []string{"CONNECTOR_GOOGLE_WORKSPACE_CLIENT_SECRET"}, + }, } for _, tt := range tests { @@ -367,6 +377,27 @@ func TestBuilder_Build_CustomValues(t *testing.T) { assert.False(t, cfg.Probod.Branding) } +func TestBuilder_Build_GoogleWorkspaceConnector(t *testing.T) { + env := requiredEnv() + env["CONNECTOR_GOOGLE_WORKSPACE_CLIENT_ID"] = "gw-client-id" + env["CONNECTOR_GOOGLE_WORKSPACE_CLIENT_SECRET"] = "gw-client-secret" + + b := NewBuilder(mockEnv(env)) + b.samlCertificate = "test-cert" + b.samlPrivateKey = "test-key" + + cfg, err := b.Build() + require.NoError(t, err) + + require.Len(t, cfg.Probod.Connectors, 1) + connector := cfg.Probod.Connectors[0] + assert.Equal(t, "GOOGLE_WORKSPACE", connector.Provider) + assert.Equal(t, "oauth2", string(connector.Protocol)) + rawConfig := connector.RawConfig.(probod.ConnectorConfigOAuth2) + assert.Equal(t, "gw-client-id", rawConfig.ClientID) + assert.Equal(t, "gw-client-secret", rawConfig.ClientSecret) +} + func TestBuilder_Build_SlackConnector(t *testing.T) { env := requiredEnv() env["CONNECTOR_SLACK_CLIENT_ID"] = "slack-client-id"