@@ -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,71 @@ 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+ BasicProfile : auth0 .Bool (true ),
233+ ExtendedProfile : auth0 .Bool (true ),
234+ Groups : auth0 .Bool (true ),
235+ },
236+ }
237+
238+ defer func () {
239+ m .Connection .Delete (g .GetID ())
240+ assertDeleted (t , g )
241+
242+ }()
243+
244+ err := m .Connection .Create (g )
245+ if err != nil {
246+ t .Fatal (err )
247+ }
248+ c , err := m .Connection .Read (g .GetID ())
249+ if err != nil {
250+ t .Fatal (err )
251+ }
252+ o , ok := c .Options .(* ConnectionOptionsGoogleApps )
253+ if ! ok {
254+ t .Fatalf ("unexpected type %T" , o )
255+ }
256+ expect .Expect (t , o .GetBasicProfile (), true )
257+ expect .Expect (t , o .GetExtendedProfile (), true )
258+ expect .Expect (t , o .GetGroups (), true )
259+ expect .Expect (t , o .GetAdmin (), false )
260+ expect .Expect (t , o .Scopes (), []string {"basic_profile" , "ext_profile" , "ext_groups" })
261+
262+ o .NonPersistentAttrs = & []string {"gender" , "ethnicity" , "favorite_color" }
263+ err = m .Connection .Update (g .GetID (), & Connection {
264+ Options : o ,
265+ })
266+ if err != nil {
267+ t .Fatal (err )
268+ }
269+ c , _ = m .Connection .Read (g .GetID ())
270+ o , ok = c .Options .(* ConnectionOptionsGoogleApps )
271+ expect .Expect (t , o .GetNonPersistentAttrs (), []string {"gender" , "ethnicity" , "favorite_color" })
272+
273+ o .NonPersistentAttrs = & []string {"" }
274+ err = m .Connection .Update (g .GetID (), & Connection {
275+ Options : o ,
276+ })
277+ if err != nil {
278+ log .Fatal (err )
279+ }
280+
281+ c , err = m .Connection .Read (g .GetID ())
282+ if err != nil {
283+ log .Fatal (err )
284+ }
285+ o , ok = c .Options .(* ConnectionOptionsGoogleApps )
286+ expect .Expect (t , o .GetNonPersistentAttrs (), []string {"" })
287+
288+ t .Logf ("%s\n " , g )
289+ })
290+
225291 t .Run ("OIDC" , func (t * testing.T ) {
226292 o := & ConnectionOptionsOIDC {}
227293 expect .Expect (t , len (o .Scopes ()), 0 )
0 commit comments