diff --git a/internal/auth0/connection/expand.go b/internal/auth0/connection/expand.go index 3014de378..67aed58c6 100644 --- a/internal/auth0/connection/expand.go +++ b/internal/auth0/connection/expand.go @@ -851,6 +851,8 @@ func passThroughUnconfigurableConnectionOptions( err = passThroughUnconfigurableConnectionOptionsADFS(ctx, api, connectionID, connection) case management.ConnectionStrategyPingFederate: err = passThroughUnconfigurableConnectionOptionsPingFederate(ctx, api, connectionID, connection) + case management.ConnectionStrategyGoogleApps: + err = passThroughUnconfigurableConnectionOptionsGoogleApps(ctx, api, connectionID, connection) } return err @@ -1021,6 +1023,35 @@ func passThroughUnconfigurableConnectionOptionsPingFederate( return nil } +func passThroughUnconfigurableConnectionOptionsGoogleApps( + ctx context.Context, + api *management.Management, + connectionID string, + connection *management.Connection, +) error { + existingConnection, err := api.Connection.Read(ctx, connectionID) + if err != nil { + return err + } + + if existingConnection.Options == nil { + return nil + } + + existingOptions := existingConnection.Options.(*management.ConnectionOptionsGoogleApps) + + expandedOptions := connection.Options.(*management.ConnectionOptionsGoogleApps) + expandedOptions.AdminAccessToken = existingOptions.AdminAccessToken + expandedOptions.AdminRefreshToken = existingOptions.AdminRefreshToken + expandedOptions.AdminAccessTokenExpiresIn = existingOptions.AdminAccessTokenExpiresIn + expandedOptions.HandleLoginFromSocial = existingOptions.HandleLoginFromSocial + expandedOptions.MapUserIDtoID = existingOptions.MapUserIDtoID + + connection.Options = expandedOptions + + return nil +} + // checkForUnmanagedConfigurationSecrets is used to assess keys diff because values are sent back encrypted. func checkForUnmanagedConfigurationSecrets(configFromTF, configFromAPI map[string]string) diag.Diagnostics { var warnings diag.Diagnostics diff --git a/test/data/recordings/TestAccConnectionGoogleApps.yaml b/test/data/recordings/TestAccConnectionGoogleApps.yaml index d56065df6..9ed29e386 100644 --- a/test/data/recordings/TestAccConnectionGoogleApps.yaml +++ b/test/data/recordings/TestAccConnectionGoogleApps.yaml @@ -13,13 +13,13 @@ interactions: remote_addr: "" request_uri: "" body: | - {"name":"Acceptance-Test-Google-Apps-TestAccConnectionGoogleApps","strategy":"google-apps","is_domain_connection":false,"show_as_button":false,"options":{"client_id":"","client_secret":"","domain":"example.com","tenant_domain":"example.com","api_enable_users":true,"ext_profile":true,"ext_groups":true,"domain_aliases":["api.example.com","example.com"],"upstream_params":{"screen_name":{"alias":"login_hint"}}}} + {"name":"Acceptance-Test-Google-Apps-TestAccConnectionGoogleApps","strategy":"google-apps","is_domain_connection":false,"show_as_button":false,"options":{"client_id":"","client_secret":"","domain":"example.com","tenant_domain":"example.com","ext_profile":true,"ext_groups":true,"api_enable_users":true,"domain_aliases":["api.example.com","example.com"],"upstream_params":{"screen_name":{"alias":"login_hint"}}}} form: {} headers: Content-Type: - application/json User-Agent: - - Go-Auth0-SDK/0.17.2 + - Go-Auth0/1.1.0 url: https://terraform-provider-auth0-dev.eu.auth0.com/api/v2/connections method: POST response: @@ -28,15 +28,15 @@ interactions: proto_minor: 0 transfer_encoding: [] trailer: {} - content_length: 732 + content_length: 756 uncompressed: false - body: '{"id":"con_5Gyv6SKJ9p3gXbOA","options":{"client_id":"","client_secret":"","domain":"example.com","tenant_domain":"example.com","api_enable_users":true,"ext_profile":true,"ext_groups":true,"domain_aliases":["api.example.com","example.com"],"upstream_params":{"screen_name":{"alias":"login_hint"}},"map_user_id_to_id":false,"email":true,"profile":true,"scope":["email","profile"],"handle_login_from_social":true},"strategy":"google-apps","name":"Acceptance-Test-Google-Apps-TestAccConnectionGoogleApps","provisioning_ticket_url":"https://login.eu.auth0.com/terraform-provider-auth0-dev/p/google-apps/XKJmmzJi","is_domain_connection":false,"show_as_button":false,"enabled_clients":[],"realms":["Acceptance-Test-Google-Apps-TestAccConnectionGoogleApps"]}' + body: '{"id":"con_hy0MZYEegYu4ycOZ","options":{"client_id":"","client_secret":"","domain":"example.com","tenant_domain":"example.com","ext_profile":true,"ext_groups":true,"api_enable_users":true,"domain_aliases":["api.example.com","example.com"],"upstream_params":{"screen_name":{"alias":"login_hint"}},"map_user_id_to_id":false,"email":true,"profile":true,"scope":["email","profile"],"handle_login_from_social":true},"strategy":"google-apps","name":"Acceptance-Test-Google-Apps-TestAccConnectionGoogleApps","provisioning_ticket_url":"https://login.eu.auth0.com/terraform-provider-auth0-dev/p/google-apps/iHRVCEx4","is_domain_connection":false,"show_as_button":false,"enabled_clients":[],"realms":["Acceptance-Test-Google-Apps-TestAccConnectionGoogleApps"]}' headers: Content-Type: - application/json; charset=utf-8 status: 201 Created code: 201 - duration: 175.913458ms + duration: 306.8775ms - id: 1 request: proto: HTTP/1.1 @@ -55,8 +55,8 @@ interactions: Content-Type: - application/json User-Agent: - - Go-Auth0-SDK/0.17.2 - url: https://terraform-provider-auth0-dev.eu.auth0.com/api/v2/connections/con_5Gyv6SKJ9p3gXbOA + - Go-Auth0/1.1.0 + url: https://terraform-provider-auth0-dev.eu.auth0.com/api/v2/connections/con_hy0MZYEegYu4ycOZ method: GET response: proto: HTTP/2.0 @@ -66,13 +66,13 @@ interactions: trailer: {} content_length: -1 uncompressed: true - body: '{"id":"con_5Gyv6SKJ9p3gXbOA","options":{"email":true,"scope":["email","profile"],"domain":"example.com","profile":true,"client_id":"","ext_groups":true,"ext_profile":true,"client_secret":"","tenant_domain":"example.com","domain_aliases":["api.example.com","example.com"],"upstream_params":{"screen_name":{"alias":"login_hint"}},"api_enable_users":true,"map_user_id_to_id":false,"handle_login_from_social":true},"strategy":"google-apps","name":"Acceptance-Test-Google-Apps-TestAccConnectionGoogleApps","provisioning_ticket_url":"https://login.eu.auth0.com/terraform-provider-auth0-dev/p/google-apps/XKJmmzJi","is_domain_connection":false,"show_as_button":false,"enabled_clients":[],"realms":["Acceptance-Test-Google-Apps-TestAccConnectionGoogleApps"]}' + body: '{"id":"con_hy0MZYEegYu4ycOZ","options":{"email":true,"scope":["email","profile"],"domain":"example.com","profile":true,"client_id":"","ext_groups":true,"ext_profile":true,"client_secret":"","tenant_domain":"example.com","domain_aliases":["api.example.com","example.com"],"upstream_params":{"screen_name":{"alias":"login_hint"}},"api_enable_users":true,"map_user_id_to_id":false,"handle_login_from_social":true},"strategy":"google-apps","name":"Acceptance-Test-Google-Apps-TestAccConnectionGoogleApps","provisioning_ticket_url":"https://login.eu.auth0.com/terraform-provider-auth0-dev/p/google-apps/iHRVCEx4","is_domain_connection":false,"show_as_button":false,"enabled_clients":[],"realms":["Acceptance-Test-Google-Apps-TestAccConnectionGoogleApps"]}' headers: Content-Type: - application/json; charset=utf-8 status: 200 OK code: 200 - duration: 192.823ms + duration: 206.686584ms - id: 2 request: proto: HTTP/1.1 @@ -91,8 +91,8 @@ interactions: Content-Type: - application/json User-Agent: - - Go-Auth0-SDK/0.17.2 - url: https://terraform-provider-auth0-dev.eu.auth0.com/api/v2/connections/con_5Gyv6SKJ9p3gXbOA + - Go-Auth0/1.1.0 + url: https://terraform-provider-auth0-dev.eu.auth0.com/api/v2/connections/con_hy0MZYEegYu4ycOZ method: GET response: proto: HTTP/2.0 @@ -102,13 +102,13 @@ interactions: trailer: {} content_length: -1 uncompressed: true - body: '{"id":"con_5Gyv6SKJ9p3gXbOA","options":{"email":true,"scope":["email","profile"],"domain":"example.com","profile":true,"client_id":"","ext_groups":true,"ext_profile":true,"client_secret":"","tenant_domain":"example.com","domain_aliases":["api.example.com","example.com"],"upstream_params":{"screen_name":{"alias":"login_hint"}},"api_enable_users":true,"map_user_id_to_id":false,"handle_login_from_social":true},"strategy":"google-apps","name":"Acceptance-Test-Google-Apps-TestAccConnectionGoogleApps","provisioning_ticket_url":"https://login.eu.auth0.com/terraform-provider-auth0-dev/p/google-apps/XKJmmzJi","is_domain_connection":false,"show_as_button":false,"enabled_clients":[],"realms":["Acceptance-Test-Google-Apps-TestAccConnectionGoogleApps"]}' + body: '{"id":"con_hy0MZYEegYu4ycOZ","options":{"email":true,"scope":["email","profile"],"domain":"example.com","profile":true,"client_id":"","ext_groups":true,"ext_profile":true,"client_secret":"","tenant_domain":"example.com","domain_aliases":["api.example.com","example.com"],"upstream_params":{"screen_name":{"alias":"login_hint"}},"api_enable_users":true,"map_user_id_to_id":false,"handle_login_from_social":true},"strategy":"google-apps","name":"Acceptance-Test-Google-Apps-TestAccConnectionGoogleApps","provisioning_ticket_url":"https://login.eu.auth0.com/terraform-provider-auth0-dev/p/google-apps/iHRVCEx4","is_domain_connection":false,"show_as_button":false,"enabled_clients":[],"realms":["Acceptance-Test-Google-Apps-TestAccConnectionGoogleApps"]}' headers: Content-Type: - application/json; charset=utf-8 status: 200 OK code: 200 - duration: 136.95725ms + duration: 98.787417ms - id: 3 request: proto: HTTP/1.1 @@ -127,8 +127,8 @@ interactions: Content-Type: - application/json User-Agent: - - Go-Auth0-SDK/0.17.2 - url: https://terraform-provider-auth0-dev.eu.auth0.com/api/v2/connections/con_5Gyv6SKJ9p3gXbOA + - Go-Auth0/1.1.0 + url: https://terraform-provider-auth0-dev.eu.auth0.com/api/v2/connections/con_hy0MZYEegYu4ycOZ method: GET response: proto: HTTP/2.0 @@ -138,34 +138,34 @@ interactions: trailer: {} content_length: -1 uncompressed: true - body: '{"id":"con_5Gyv6SKJ9p3gXbOA","options":{"email":true,"scope":["email","profile"],"domain":"example.com","profile":true,"client_id":"","ext_groups":true,"ext_profile":true,"client_secret":"","tenant_domain":"example.com","domain_aliases":["api.example.com","example.com"],"upstream_params":{"screen_name":{"alias":"login_hint"}},"api_enable_users":true,"map_user_id_to_id":false,"handle_login_from_social":true},"strategy":"google-apps","name":"Acceptance-Test-Google-Apps-TestAccConnectionGoogleApps","provisioning_ticket_url":"https://login.eu.auth0.com/terraform-provider-auth0-dev/p/google-apps/XKJmmzJi","is_domain_connection":false,"show_as_button":false,"enabled_clients":[],"realms":["Acceptance-Test-Google-Apps-TestAccConnectionGoogleApps"]}' + body: '{"id":"con_hy0MZYEegYu4ycOZ","options":{"email":true,"scope":["email","profile"],"domain":"example.com","profile":true,"client_id":"","ext_groups":true,"ext_profile":true,"client_secret":"","tenant_domain":"example.com","domain_aliases":["api.example.com","example.com"],"upstream_params":{"screen_name":{"alias":"login_hint"}},"api_enable_users":true,"map_user_id_to_id":false,"handle_login_from_social":true},"strategy":"google-apps","name":"Acceptance-Test-Google-Apps-TestAccConnectionGoogleApps","provisioning_ticket_url":"https://login.eu.auth0.com/terraform-provider-auth0-dev/p/google-apps/iHRVCEx4","is_domain_connection":false,"show_as_button":false,"enabled_clients":[],"realms":["Acceptance-Test-Google-Apps-TestAccConnectionGoogleApps"]}' headers: Content-Type: - application/json; charset=utf-8 status: 200 OK code: 200 - duration: 94.49725ms + duration: 95.908084ms - id: 4 request: proto: HTTP/1.1 proto_major: 1 proto_minor: 1 - content_length: 366 + content_length: 5 transfer_encoding: [] trailer: {} host: terraform-provider-auth0-dev.eu.auth0.com remote_addr: "" request_uri: "" body: | - {"is_domain_connection":false,"show_as_button":false,"options":{"client_id":"","client_secret":"","domain":"example.com","tenant_domain":"example.com","api_enable_users":true,"ext_profile":true,"ext_groups":true,"set_user_root_attributes":"on_first_login","domain_aliases":["api.example.com","example.com"],"upstream_params":{"screen_name":{"alias":"login_hint"}}}} + null form: {} headers: Content-Type: - application/json User-Agent: - - Go-Auth0-SDK/0.17.2 - url: https://terraform-provider-auth0-dev.eu.auth0.com/api/v2/connections/con_5Gyv6SKJ9p3gXbOA - method: PATCH + - Go-Auth0/1.1.0 + url: https://terraform-provider-auth0-dev.eu.auth0.com/api/v2/connections/con_hy0MZYEegYu4ycOZ + method: GET response: proto: HTTP/2.0 proto_major: 2 @@ -174,14 +174,50 @@ interactions: trailer: {} content_length: -1 uncompressed: true - body: '{"id":"con_5Gyv6SKJ9p3gXbOA","options":{"email":true,"scope":["email","profile"],"domain":"example.com","profile":true,"client_id":"","ext_groups":true,"ext_profile":true,"client_secret":"","tenant_domain":"example.com","domain_aliases":["api.example.com","example.com"],"upstream_params":{"screen_name":{"alias":"login_hint"}},"api_enable_users":true,"map_user_id_to_id":false,"handle_login_from_social":true,"set_user_root_attributes":"on_first_login"},"strategy":"google-apps","name":"Acceptance-Test-Google-Apps-TestAccConnectionGoogleApps","provisioning_ticket_url":"https://login.eu.auth0.com/terraform-provider-auth0-dev/p/google-apps/XKJmmzJi","is_domain_connection":false,"show_as_button":false,"enabled_clients":[],"realms":["Acceptance-Test-Google-Apps-TestAccConnectionGoogleApps"]}' + body: '{"id":"con_hy0MZYEegYu4ycOZ","options":{"email":true,"scope":["email","profile"],"domain":"example.com","profile":true,"client_id":"","ext_groups":true,"ext_profile":true,"client_secret":"","tenant_domain":"example.com","domain_aliases":["api.example.com","example.com"],"upstream_params":{"screen_name":{"alias":"login_hint"}},"api_enable_users":true,"map_user_id_to_id":false,"handle_login_from_social":true},"strategy":"google-apps","name":"Acceptance-Test-Google-Apps-TestAccConnectionGoogleApps","provisioning_ticket_url":"https://login.eu.auth0.com/terraform-provider-auth0-dev/p/google-apps/iHRVCEx4","is_domain_connection":false,"show_as_button":false,"enabled_clients":[],"realms":["Acceptance-Test-Google-Apps-TestAccConnectionGoogleApps"]}' headers: Content-Type: - application/json; charset=utf-8 status: 200 OK code: 200 - duration: 264.379ms + duration: 87.228292ms - id: 5 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 424 + transfer_encoding: [] + trailer: {} + host: terraform-provider-auth0-dev.eu.auth0.com + remote_addr: "" + request_uri: "" + body: | + {"is_domain_connection":false,"show_as_button":false,"options":{"client_id":"","client_secret":"","domain":"example.com","tenant_domain":"example.com","ext_profile":true,"ext_groups":true,"api_enable_users":true,"set_user_root_attributes":"on_first_login","map_user_id_to_id":false,"handle_login_from_social":true,"domain_aliases":["api.example.com","example.com"],"upstream_params":{"screen_name":{"alias":"login_hint"}}}} + form: {} + headers: + Content-Type: + - application/json + User-Agent: + - Go-Auth0/1.1.0 + url: https://terraform-provider-auth0-dev.eu.auth0.com/api/v2/connections/con_hy0MZYEegYu4ycOZ + method: PATCH + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: -1 + uncompressed: true + body: '{"id":"con_hy0MZYEegYu4ycOZ","options":{"email":true,"scope":["email","profile"],"domain":"example.com","profile":true,"client_id":"","ext_groups":true,"ext_profile":true,"client_secret":"","tenant_domain":"example.com","domain_aliases":["api.example.com","example.com"],"upstream_params":{"screen_name":{"alias":"login_hint"}},"api_enable_users":true,"map_user_id_to_id":false,"handle_login_from_social":true,"set_user_root_attributes":"on_first_login"},"strategy":"google-apps","name":"Acceptance-Test-Google-Apps-TestAccConnectionGoogleApps","provisioning_ticket_url":"https://login.eu.auth0.com/terraform-provider-auth0-dev/p/google-apps/iHRVCEx4","is_domain_connection":false,"show_as_button":false,"enabled_clients":[],"realms":["Acceptance-Test-Google-Apps-TestAccConnectionGoogleApps"]}' + headers: + Content-Type: + - application/json; charset=utf-8 + status: 200 OK + code: 200 + duration: 160.080125ms + - id: 6 request: proto: HTTP/1.1 proto_major: 1 @@ -199,8 +235,8 @@ interactions: Content-Type: - application/json User-Agent: - - Go-Auth0-SDK/0.17.2 - url: https://terraform-provider-auth0-dev.eu.auth0.com/api/v2/connections/con_5Gyv6SKJ9p3gXbOA + - Go-Auth0/1.1.0 + url: https://terraform-provider-auth0-dev.eu.auth0.com/api/v2/connections/con_hy0MZYEegYu4ycOZ method: GET response: proto: HTTP/2.0 @@ -210,14 +246,14 @@ interactions: trailer: {} content_length: -1 uncompressed: true - body: '{"id":"con_5Gyv6SKJ9p3gXbOA","options":{"email":true,"scope":["email","profile"],"domain":"example.com","profile":true,"client_id":"","ext_groups":true,"ext_profile":true,"client_secret":"","tenant_domain":"example.com","domain_aliases":["api.example.com","example.com"],"upstream_params":{"screen_name":{"alias":"login_hint"}},"api_enable_users":true,"map_user_id_to_id":false,"handle_login_from_social":true,"set_user_root_attributes":"on_first_login"},"strategy":"google-apps","name":"Acceptance-Test-Google-Apps-TestAccConnectionGoogleApps","provisioning_ticket_url":"https://login.eu.auth0.com/terraform-provider-auth0-dev/p/google-apps/XKJmmzJi","is_domain_connection":false,"show_as_button":false,"enabled_clients":[],"realms":["Acceptance-Test-Google-Apps-TestAccConnectionGoogleApps"]}' + body: '{"id":"con_hy0MZYEegYu4ycOZ","options":{"email":true,"scope":["email","profile"],"domain":"example.com","profile":true,"client_id":"","ext_groups":true,"ext_profile":true,"client_secret":"","tenant_domain":"example.com","domain_aliases":["api.example.com","example.com"],"upstream_params":{"screen_name":{"alias":"login_hint"}},"api_enable_users":true,"map_user_id_to_id":false,"handle_login_from_social":true,"set_user_root_attributes":"on_first_login"},"strategy":"google-apps","name":"Acceptance-Test-Google-Apps-TestAccConnectionGoogleApps","provisioning_ticket_url":"https://login.eu.auth0.com/terraform-provider-auth0-dev/p/google-apps/iHRVCEx4","is_domain_connection":false,"show_as_button":false,"enabled_clients":[],"realms":["Acceptance-Test-Google-Apps-TestAccConnectionGoogleApps"]}' headers: Content-Type: - application/json; charset=utf-8 status: 200 OK code: 200 - duration: 86.893709ms - - id: 6 + duration: 103.823042ms + - id: 7 request: proto: HTTP/1.1 proto_major: 1 @@ -235,8 +271,8 @@ interactions: Content-Type: - application/json User-Agent: - - Go-Auth0-SDK/0.17.2 - url: https://terraform-provider-auth0-dev.eu.auth0.com/api/v2/connections/con_5Gyv6SKJ9p3gXbOA + - Go-Auth0/1.1.0 + url: https://terraform-provider-auth0-dev.eu.auth0.com/api/v2/connections/con_hy0MZYEegYu4ycOZ method: GET response: proto: HTTP/2.0 @@ -246,14 +282,14 @@ interactions: trailer: {} content_length: -1 uncompressed: true - body: '{"id":"con_5Gyv6SKJ9p3gXbOA","options":{"email":true,"scope":["email","profile"],"domain":"example.com","profile":true,"client_id":"","ext_groups":true,"ext_profile":true,"client_secret":"","tenant_domain":"example.com","domain_aliases":["api.example.com","example.com"],"upstream_params":{"screen_name":{"alias":"login_hint"}},"api_enable_users":true,"map_user_id_to_id":false,"handle_login_from_social":true,"set_user_root_attributes":"on_first_login"},"strategy":"google-apps","name":"Acceptance-Test-Google-Apps-TestAccConnectionGoogleApps","provisioning_ticket_url":"https://login.eu.auth0.com/terraform-provider-auth0-dev/p/google-apps/XKJmmzJi","is_domain_connection":false,"show_as_button":false,"enabled_clients":[],"realms":["Acceptance-Test-Google-Apps-TestAccConnectionGoogleApps"]}' + body: '{"id":"con_hy0MZYEegYu4ycOZ","options":{"email":true,"scope":["email","profile"],"domain":"example.com","profile":true,"client_id":"","ext_groups":true,"ext_profile":true,"client_secret":"","tenant_domain":"example.com","domain_aliases":["api.example.com","example.com"],"upstream_params":{"screen_name":{"alias":"login_hint"}},"api_enable_users":true,"map_user_id_to_id":false,"handle_login_from_social":true,"set_user_root_attributes":"on_first_login"},"strategy":"google-apps","name":"Acceptance-Test-Google-Apps-TestAccConnectionGoogleApps","provisioning_ticket_url":"https://login.eu.auth0.com/terraform-provider-auth0-dev/p/google-apps/iHRVCEx4","is_domain_connection":false,"show_as_button":false,"enabled_clients":[],"realms":["Acceptance-Test-Google-Apps-TestAccConnectionGoogleApps"]}' headers: Content-Type: - application/json; charset=utf-8 status: 200 OK code: 200 - duration: 103.602083ms - - id: 7 + duration: 93.240334ms + - id: 8 request: proto: HTTP/1.1 proto_major: 1 @@ -270,8 +306,8 @@ interactions: Content-Type: - application/json User-Agent: - - Go-Auth0-SDK/0.17.2 - url: https://terraform-provider-auth0-dev.eu.auth0.com/api/v2/connections/con_5Gyv6SKJ9p3gXbOA + - Go-Auth0/1.1.0 + url: https://terraform-provider-auth0-dev.eu.auth0.com/api/v2/connections/con_hy0MZYEegYu4ycOZ method: DELETE response: proto: HTTP/2.0 @@ -281,10 +317,10 @@ interactions: trailer: {} content_length: 41 uncompressed: false - body: '{"deleted_at":"2023-06-05T10:22:50.845Z"}' + body: '{"deleted_at":"2023-09-14T11:29:26.696Z"}' headers: Content-Type: - application/json; charset=utf-8 status: 202 Accepted code: 202 - duration: 150.361875ms + duration: 114.887958ms