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

[GH-366] - Add support for enabled_connections field in CreateOrganizationConnections #394

Merged
merged 3 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions management/organization.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ type Organization struct {
// Metadata associated with the organization, in the form of an object with
// string values (max 255 chars). Maximum of 10 metadata properties allowed.
Metadata *map[string]string `json:"metadata,omitempty"`

// OrganizationConnections that will be enabled for this organization.
// See POST enabled_connections endpoint for the object format.
// (Max of 10 connections allowed)
OrganizationConnections []*OrganizationConnection `json:"enabled_connections,omitempty"`
developerkunal marked this conversation as resolved.
Show resolved Hide resolved
}

// OrganizationBranding holds branding information for an Organization.
Expand Down
26 changes: 26 additions & 0 deletions management/organization_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,16 @@ import (
func TestOrganizationManager_Create(t *testing.T) {
configureHTTPTestRecordings(t)

orgConn := givenAnOrganizationConnectionWithoutOrgID(t)
orgConn2 := givenAnOrganizationConnectionWithoutOrgID(t)

org := &Organization{
Name: auth0.String(fmt.Sprintf("test-organization%v", rand.Intn(999))),
DisplayName: auth0.String("Test Organization"),
Branding: &OrganizationBranding{
LogoURL: auth0.String("https://example.com/logo.gif"),
},
OrganizationConnections: []*OrganizationConnection{orgConn, orgConn2},
developerkunal marked this conversation as resolved.
Show resolved Hide resolved
}

err := api.Organization.Create(context.Background(), org)
Expand Down Expand Up @@ -435,6 +439,28 @@ func givenAnOrganizationConnection(t *testing.T, orgID string) *OrganizationConn
return orgConn
}

func givenAnOrganizationConnectionWithoutOrgID(t *testing.T) *OrganizationConnection {
client := givenAClient(t)
conn := givenAConnection(t, connectionTestCase{
connection: Connection{
Name: auth0.String(fmt.Sprintf("test-conn%v", rand.Intn(999))),
DisplayName: auth0.String(fmt.Sprintf("Test Connection %v", rand.Intn(999))),
Strategy: auth0.String(ConnectionStrategyAD),
EnabledClients: &[]string{
os.Getenv("AUTH0_CLIENT_ID"),
client.GetClientID(),
},
},
})
orgConn := &OrganizationConnection{
ConnectionID: conn.ID,
AssignMembershipOnLogin: auth0.Bool(true),
ShowAsButton: auth0.Bool(true),
}

return orgConn
}

func givenAnOrganizationInvitation(t *testing.T, orgID string) *OrganizationInvitation {
t.Helper()

Expand Down
Loading
Loading