Skip to content

Commit

Permalink
[GH-366] - Add support for enabled_connections field in CreateOrganiz…
Browse files Browse the repository at this point in the history
…ation
  • Loading branch information
developerkunal committed Apr 25, 2024
1 parent 6aaee1e commit 7f53f1c
Show file tree
Hide file tree
Showing 3 changed files with 325 additions and 10 deletions.
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"`
}

// 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},
}

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

0 comments on commit 7f53f1c

Please sign in to comment.