@@ -153,6 +153,7 @@ func TestConnection(t *testing.T) {
153153 t .Logf ("%v\n " , cs )
154154 })
155155}
156+
156157func TestConnectionOptions (t * testing.T ) {
157158
158159 t .Run ("GoogleOAuth2" , func (t * testing.T ) {
@@ -222,6 +223,72 @@ func TestConnectionOptions(t *testing.T) {
222223 t .Logf ("%s\n " , g )
223224 })
224225
226+ t .Run ("GoogleApps" , func (t * testing.T ) {
227+ g := & Connection {
228+ Name : auth0 .Stringf ("Test-Connection-%d" , time .Now ().Unix ()),
229+ Strategy : auth0 .String ("google-apps" ),
230+ Options : & ConnectionOptionsGoogleApps {
231+ Domain : auth0 .String ("example.com" ),
232+ TenantDomain : auth0 .String ("example.com" ),
233+ BasicProfile : auth0 .Bool (true ),
234+ ExtendedProfile : auth0 .Bool (true ),
235+ Groups : auth0 .Bool (true ),
236+ },
237+ }
238+
239+ defer func () {
240+ m .Connection .Delete (g .GetID ())
241+ assertDeleted (t , g )
242+
243+ }()
244+
245+ err := m .Connection .Create (g )
246+ if err != nil {
247+ t .Fatal (err )
248+ }
249+ c , err := m .Connection .Read (g .GetID ())
250+ if err != nil {
251+ t .Fatal (err )
252+ }
253+ o , ok := c .Options .(* ConnectionOptionsGoogleApps )
254+ if ! ok {
255+ t .Fatalf ("unexpected type %T" , o )
256+ }
257+ expect .Expect (t , o .GetBasicProfile (), true )
258+ expect .Expect (t , o .GetExtendedProfile (), true )
259+ expect .Expect (t , o .GetGroups (), true )
260+ expect .Expect (t , o .GetAdmin (), false )
261+ expect .Expect (t , o .Scopes (), []string {"basic_profile" , "ext_profile" , "ext_groups" })
262+
263+ o .NonPersistentAttrs = & []string {"gender" , "ethnicity" , "favorite_color" }
264+ err = m .Connection .Update (g .GetID (), & Connection {
265+ Options : o ,
266+ })
267+ if err != nil {
268+ t .Fatal (err )
269+ }
270+ c , _ = m .Connection .Read (g .GetID ())
271+ o , ok = c .Options .(* ConnectionOptionsGoogleApps )
272+ expect .Expect (t , o .GetNonPersistentAttrs (), []string {"gender" , "ethnicity" , "favorite_color" })
273+
274+ o .NonPersistentAttrs = & []string {"" }
275+ err = m .Connection .Update (g .GetID (), & Connection {
276+ Options : o ,
277+ })
278+ if err != nil {
279+ log .Fatal (err )
280+ }
281+
282+ c , err = m .Connection .Read (g .GetID ())
283+ if err != nil {
284+ log .Fatal (err )
285+ }
286+ o , ok = c .Options .(* ConnectionOptionsGoogleApps )
287+ expect .Expect (t , o .GetNonPersistentAttrs (), []string {"" })
288+
289+ t .Logf ("%s\n " , g )
290+ })
291+
225292 t .Run ("OIDC" , func (t * testing.T ) {
226293 o := & ConnectionOptionsOIDC {}
227294 expect .Expect (t , len (o .Scopes ()), 0 )
0 commit comments