| 
      
            Lines 94-136
          subtest 'list() tests' => sub {
      
      
        Link Here
      
     | 
  
        
          | 94 | 
          };  | 
          94 | 
          };  | 
        
        
          | 95 | 
           | 
          95 | 
           | 
        
        
          | 96 | 
          subtest 'get() tests' => sub { | 
          96 | 
          subtest 'get() tests' => sub { | 
        
          
            
              | 97 | 
                  plan tests => 3;  | 
              97 | 
                  plan tests => 2;  | 
            
        
          | 98 | 
           | 
          98 | 
           | 
        
        
          | 99 | 
              $schema->storage->txn_begin;  | 
          99 | 
              $schema->storage->txn_begin;  | 
        
        
          | 100 | 
              unauthorized_access_tests('GET', -1, undef); | 
          100 | 
              unauthorized_access_tests('GET', -1, undef); | 
        
        
          | 101 | 
              $schema->storage->txn_rollback;  | 
          101 | 
              $schema->storage->txn_rollback;  | 
        
        
          | 102 | 
           | 
          102 | 
           | 
        
            
              | 103 | 
                  subtest 'access own object tests' => sub { | 
               | 
               | 
            
            
              | 104 | 
                      plan tests => 4;  | 
            
            
              | 105 | 
               | 
            
            
              | 106 | 
                      $schema->storage->txn_begin;  | 
            
            
              | 107 | 
               | 
            
            
              | 108 | 
                      my ( $patron_id, $session_id ) = create_user_and_session({ authorized => 0 }); | 
            
            
              | 109 | 
               | 
            
            
              | 110 | 
                      # Access patron's own data even though they have no borrowers flag  | 
            
            
              | 111 | 
                      my $tx = $t->ua->build_tx(GET => "/api/v1/patrons/" . $patron_id);  | 
            
            
              | 112 | 
                      $tx->req->cookies({ name => 'CGISESSID', value => $session_id }); | 
            
            
              | 113 | 
                      $tx->req->env({ REMOTE_ADDR => '127.0.0.1' }); | 
            
            
              | 114 | 
                      $t->request_ok($tx)  | 
            
            
              | 115 | 
                        ->status_is(200);  | 
            
            
              | 116 | 
               | 
            
            
              | 117 | 
                      my $guarantee = $builder->build_object({ | 
            
            
              | 118 | 
                          class => 'Koha::Patrons',  | 
            
            
              | 119 | 
                          value => { | 
            
            
              | 120 | 
                              guarantorid => $patron_id,  | 
            
            
              | 121 | 
                          }  | 
            
            
              | 122 | 
                      });  | 
            
            
              | 123 | 
               | 
            
            
              | 124 | 
                      # Access guarantee's data even though guarantor has no borrowers flag  | 
            
            
              | 125 | 
                      $tx = $t->ua->build_tx(GET => "/api/v1/patrons/" . $guarantee->id );  | 
            
            
              | 126 | 
                      $tx->req->cookies({ name => 'CGISESSID', value => $session_id }); | 
            
            
              | 127 | 
                      $tx->req->env({ REMOTE_ADDR => '127.0.0.1' }); | 
            
            
              | 128 | 
                      $t->request_ok($tx)  | 
            
            
              | 129 | 
                        ->status_is(200);  | 
            
            
              | 130 | 
               | 
            
            
              | 131 | 
                      $schema->storage->txn_rollback;  | 
            
            
              | 132 | 
                  };  | 
            
            
              | 133 | 
               | 
            
        
          | 134 | 
              subtest 'librarian access tests' => sub { | 
          103 | 
              subtest 'librarian access tests' => sub { | 
        
        
          | 135 | 
                  plan tests => 6;  | 
          104 | 
                  plan tests => 6;  | 
        
        
          | 136 | 
           | 
          105 | 
           | 
        
            
              | 137 | 
              -   | 
               | 
               |