/** * Bind the interfaces to their implementations in the service container. */ public function registerLdapInterfaces() { $this->app->bind('LaravelAuthLdap\\Contracts\\LdapServer', function ($app) { $server = new AdLDAPLdapServer(); $server->setAdServer(new adLDAP($app->config['adldap'])); return $server; }); $this->app->bind('LaravelAuthLdap\\Contracts\\LdapUser', function ($app) { $user = new BaseLdapUser(); $user->setConvertFields($app->config['auth-ldap.convert_fields']); $user->setUsernameField($app->config['auth-ldap.username_field']); return $user; }); $this->app->bind('LaravelAuthLdap\\Contracts\\LdapUserProvider', function ($app) { $provider = new BaseLdapUserProvider(); $driverName = array_get($app->config['auth-ldap'], 'provider.driver'); if ($driverName !== null) { $driver = $this->app['auth']->driver($driverName); $provider->setProvider($driver->getProvider()); } $provider->setLdapServer($app->make('LaravelAuthLdap\\Contracts\\LdapServer')); $mustExist = array_get($app->config['auth-ldap'], 'provider.must_exist'); $provider->setUserMustExistInProvider($mustExist === null ? false : $mustExist); $provider->setCredentialsFields($app->config['auth-ldap.credentials_fields']); return $provider; }); }
public function testUpdateRememberToken() { $provider = Mockery::mock('Illuminate\\Contracts\\Auth\\UserProvider'); $this->baseLdapUserProvider->setProvider($provider); $ldapUser = Mockery::mock('LaravelAuthLdap\\Contracts\\LdapUser'); $provider->shouldReceive('updateRememberToken')->never(); // if not using provider, don't update token $this->baseLdapUserProvider->updateRememberToken($ldapUser, 'token'); $providerUser = Mockery::mock('Illuminate\\Contracts\\Auth\\Authenticatable'); $provider->shouldReceive('updateRememberToken')->once(); // if using provider, should update token in provider $this->baseLdapUserProvider->updateRememberToken($providerUser, 'token'); }