@@ -116,6 +116,58 @@ public function invalid_attribute_handlers_does_not_throw_exception()
116116 $ this ->assertInstanceOf (EloquentUser::class, $ importer ->handle ());
117117 }
118118
119+ /** @test */
120+ public function sync_attribute_as_string_will_return_null ()
121+ {
122+ config ([
123+ 'ldap_auth.sync_attributes ' => [
124+ 'email ' => 'userprincipalname ' ,
125+ 'name ' => 'cn ' ,
126+ ]
127+ ]);
128+
129+ // LDAP user does not have common name.
130+ $ user = $ this ->makeLdapUser ([
131+ 'userprincipalname ' =>
'[email protected] ' ,
132+ ]);
133+
134+ $ importer = new Import ($ user , new EloquentUser ());
135+
136+ $ model = $ importer ->handle ();
137+
138+ $ this ->assertInstanceOf (EloquentUser::class, $ model );
139+ $ this ->assertNull ($ model ->name );
140+ }
141+
142+ /** @test */
143+ public function sync_attribute_as_int_boolean_or_array_will_be_used ()
144+ {
145+ config ([
146+ 'ldap_auth.sync_attributes ' => [
147+ 'email ' => 'userprincipalname ' ,
148+ 'string ' => 'not-an-LDAP-attribute ' ,
149+ 'int ' => 1 ,
150+ 'bool ' => true ,
151+ 'array ' => ['one ' , 'two ' ]
152+ ]
153+ ]);
154+
155+ // LDAP user does not have common name.
156+ $ user = $ this ->makeLdapUser ([
157+ 'userprincipalname ' =>
'[email protected] ' ,
158+ ]);
159+
160+ $ importer = new Import ($ user , new EloquentUser ());
161+
162+ $ model = $ importer ->handle ();
163+
164+ $ this ->assertInstanceOf (EloquentUser::class, $ model );
165+ $ this ->assertNull ($ model ->string );
166+ $ this ->assertEquals ($ model ->int , 1 );
167+ $ this ->assertEquals ($ model ->bool , true );
168+ $ this ->assertEquals ($ model ->array , ['one ' , 'two ' ]);
169+ }
170+
119171 /** @test */
120172 public function auth_attempts_fallback_using_config_option ()
121173 {
0 commit comments