+ # autocreate user
+ $autocreate = 1;
+ $shib_login = 'test4321';
+ $ENV{'uid'} = 'test4321';
+ $ENV{'sn'} = "pika";
+ $ENV{'exp'} = "2017";
+ $ENV{'cat'} = "S";
+ $ENV{'add'} = 'Address';
+ $ENV{'city'} = 'City';
+
+ ( $retval, $retcard, $retuserid ) = checkpw_shib($shib_login);
+ is( $retval, "1", "user authenticated" );
+ is( $retuserid, "test4321", "expected userid returned" );
+ $logger->debug_is("koha borrower field to match: userid", "borrower match field debug info")
+ ->debug_is("shibboleth attribute to match: uid", "shib match attribute debug info")
+ ->clear();
+
+ ok my $new_user = ResultSet('Borrower')
+ ->search( { 'userid' => 'test4321' }, { rows => 1 } ), "new user found";
+ is_fields [qw/surname dateexpiry address city/], $new_user->next,
+ [qw/pika 2017 Address City/],
+ 'Found $new_users surname';
+ $autocreate = 0;
+
+ # sync user
+ $sync = 1;
+ $ENV{'city'} = 'AnotherCity';
+ ( $retval, $retcard, $retuserid ) = checkpw_shib($shib_login);
+ $logger->debug_is("koha borrower field to match: userid", "borrower match field debug info")
+ ->debug_is("shibboleth attribute to match: uid", "shib match attribute debug info")
+ ->clear();
+
+ ok my $sync_user = ResultSet('Borrower')
+ ->search( { 'userid' => 'test4321' }, { rows => 1 } ), "sync user found";
+
+ is_fields [qw/surname dateexpiry address city/], $sync_user->next,
+ [qw/pika 2017 Address AnotherCity/],
+ 'Found $sync_user synced city';
+ $sync = 0;