View | Details | Raw Unified | Return to bug 23019
Collapse All | Expand All

(-)a/api/v1/swagger/paths.json (-2 / +2 lines)
Lines 113-120 Link Here
113
  "/import_batch_profiles": {
113
  "/import_batch_profiles": {
114
    "$ref": "paths/import_batch_profiles.json#/~1import_batch_profiles"
114
    "$ref": "paths/import_batch_profiles.json#/~1import_batch_profiles"
115
  },
115
  },
116
  "/import_batch_profiles/{profile_id}": {
116
  "/import_batch_profiles/{import_batch_profile_id}": {
117
    "$ref": "paths/import_batch_profiles.json#/~1import_batch_profiles~1{profile_id}"
117
    "$ref": "paths/import_batch_profiles.json#/~1import_batch_profiles~1{import_batch_profile_id}"
118
  },
118
  },
119
  "/rotas/{rota_id}/stages/{stage_id}/position": {
119
  "/rotas/{rota_id}/stages/{stage_id}/position": {
120
    "$ref": "paths/rotas.json#/~1rotas~1{rota_id}~1stages~1{stage_id}~1position"
120
    "$ref": "paths/rotas.json#/~1rotas~1{rota_id}~1stages~1{stage_id}~1position"
(-)a/api/v1/swagger/paths/import_batch_profiles.json (-6 / +6 lines)
Lines 67-73 Link Here
67
      },
67
      },
68
      "x-koha-authorization": {
68
      "x-koha-authorization": {
69
        "permissions": {
69
        "permissions": {
70
          "catalogue": "1"
70
          "tools": "stage_marc_import"
71
        }
71
        }
72
      }
72
      }
73
    },
73
    },
Lines 182-193 Link Here
182
      },
182
      },
183
      "x-koha-authorization": {
183
      "x-koha-authorization": {
184
        "permissions": {
184
        "permissions": {
185
          "catalogue": "1"
185
          "tools": "stage_marc_import"
186
        }
186
        }
187
      }
187
      }
188
    }
188
    }
189
  },
189
  },
190
  "/import_batch_profiles/{profile_id}": {
190
  "/import_batch_profiles/{import_batch_profile_id}": {
191
    "put": {
191
    "put": {
192
      "x-mojo-to": "ImportBatchProfiles#edit",
192
      "x-mojo-to": "ImportBatchProfiles#edit",
193
      "operationId": "editImportBatchProfiles",
193
      "operationId": "editImportBatchProfiles",
Lines 196-202 Link Here
196
      ],
196
      ],
197
      "parameters": [
197
      "parameters": [
198
        {
198
        {
199
          "$ref": "../parameters.json#/profile_id_pp"
199
          "$ref": "../parameters.json#/import_batch_profile_id_pp"
200
        },
200
        },
201
        {
201
        {
202
          "name": "body",
202
          "name": "body",
Lines 302-308 Link Here
302
      },
302
      },
303
      "x-koha-authorization": {
303
      "x-koha-authorization": {
304
        "permissions": {
304
        "permissions": {
305
          "catalogue": "1"
305
          "tools": "stage_marc_import"
306
        }
306
        }
307
      }
307
      }
308
    },
308
    },
Lines 311-317 Link Here
311
      "operationId": "deleteImportBatchProfiles",
311
      "operationId": "deleteImportBatchProfiles",
312
      "tags": ["ImportBatchProfiles"],
312
      "tags": ["ImportBatchProfiles"],
313
      "parameters": [{
313
      "parameters": [{
314
          "$ref": "../parameters.json#/profile_id_pp"
314
          "$ref": "../parameters.json#/import_batch_profile_id_pp"
315
        }
315
        }
316
      ],
316
      ],
317
      "produces": ["application/json"],
317
      "produces": ["application/json"],
(-)a/t/db_dependent/api/v1/import_batch_profiles.t (-6 / +68 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 4;
20
use Test::More tests => 5;
21
use Test::Mojo;
21
use Test::Mojo;
22
use t::lib::TestBuilder;
22
use t::lib::TestBuilder;
23
use t::lib::Mocks;
23
use t::lib::Mocks;
Lines 27-37 use Koha::ImportBatchProfiles; Link Here
27
27
28
my $schema  = Koha::Database->new->schema;
28
my $schema  = Koha::Database->new->schema;
29
my $builder = t::lib::TestBuilder->new();
29
my $builder = t::lib::TestBuilder->new();
30
my $dbh = C4::Context->dbh;
30
31
31
t::lib::Mocks::mock_preference( 'RESTBasicAuth', 1 );
32
t::lib::Mocks::mock_preference( 'RESTBasicAuth', 1 );
32
33
33
my $t = Test::Mojo->new('Koha::REST::V1');
34
my $t = Test::Mojo->new('Koha::REST::V1');
34
35
36
subtest 'unauth access' => sub {
37
    plan tests => 4;
38
39
    $schema->storage->txn_begin;
40
41
    # Patron without specific flag
42
    my $patron1 = $builder->build_object(
43
        {
44
            class => 'Koha::Patrons',
45
            value => {
46
                flags => 4
47
            }
48
        }
49
    );
50
51
    # Patron with correct flag, but without specific permission
52
    my $patron2 = $builder->build_object(
53
        {
54
            class => 'Koha::Patrons',
55
            value => {
56
                flags => 4096
57
            }
58
        }
59
    );
60
61
    my $uid = $patron1->userid;
62
    my $pwd = $patron1->password;
63
    $t->get_ok("//$uid:$pwd@/api/v1/import_batch_profiles?_order_by=+name")
64
      ->status_is(403);
65
66
    $uid = $patron1->userid;
67
    $pwd = $patron1->password;
68
    $t->get_ok("//$uid:$pwd@/api/v1/import_batch_profiles?_order_by=+name")
69
      ->status_is(403);
70
71
    $schema->storage->txn_rollback;
72
};
73
35
subtest 'list profiles' => sub {
74
subtest 'list profiles' => sub {
36
    plan tests => 4;
75
    plan tests => 4;
37
76
Lines 46-56 subtest 'list profiles' => sub { Link Here
46
        {
85
        {
47
            class => 'Koha::Patrons',
86
            class => 'Koha::Patrons',
48
            value => {
87
            value => {
49
                flags => 1
88
                flags => 4096
50
            }
89
            }
51
        }
90
        }
52
    );
91
    );
53
92
93
    my $sth = $dbh->prepare("INSERT INTO user_permissions (borrowernumber, module_bit, code)
94
                        SELECT ?, bit, ?
95
                        FROM userflags
96
                        WHERE flag = ?");
97
    $sth->execute($patron->borrowernumber, 'stage_marc_import', 'tools');
98
54
    my $pwd = 'thePassword123';
99
    my $pwd = 'thePassword123';
55
    $patron->set_password( { password => $pwd, skip_validation => 1 } );
100
    $patron->set_password( { password => $pwd, skip_validation => 1 } );
56
101
Lines 77-87 subtest 'add profile' => sub { Link Here
77
        {
122
        {
78
            class => 'Koha::Patrons',
123
            class => 'Koha::Patrons',
79
            value => {
124
            value => {
80
                flags => 1
125
                flags => 4096
81
            }
126
            }
82
        }
127
        }
83
    );
128
    );
84
129
130
    my $sth = $dbh->prepare("INSERT INTO user_permissions (borrowernumber, module_bit, code)
131
                        SELECT ?, bit, ?
132
                        FROM userflags
133
                        WHERE flag = ?");
134
    $sth->execute($patron->borrowernumber, 'stage_marc_import', 'tools');
135
85
    my $pwd = 'thePassword123';
136
    my $pwd = 'thePassword123';
86
    $patron->set_password( { password => $pwd, skip_validation => 1 } );
137
    $patron->set_password( { password => $pwd, skip_validation => 1 } );
87
138
Lines 112-122 subtest 'edit profile' => sub { Link Here
112
        {
163
        {
113
            class => 'Koha::Patrons',
164
            class => 'Koha::Patrons',
114
            value => {
165
            value => {
115
                flags => 1
166
                flags => 4096
116
            }
167
            }
117
        }
168
        }
118
    );
169
    );
119
170
171
    my $sth = $dbh->prepare("INSERT INTO user_permissions (borrowernumber, module_bit, code)
172
                        SELECT ?, bit, ?
173
                        FROM userflags
174
                        WHERE flag = ?");
175
    $sth->execute($patron->borrowernumber, 'stage_marc_import', 'tools');
176
120
    my $pwd = 'thePassword123';
177
    my $pwd = 'thePassword123';
121
    $patron->set_password( { password => $pwd, skip_validation => 1 } );
178
    $patron->set_password( { password => $pwd, skip_validation => 1 } );
122
179
Lines 153-163 subtest 'delete profile' => sub { Link Here
153
        {
210
        {
154
            class => 'Koha::Patrons',
211
            class => 'Koha::Patrons',
155
            value => {
212
            value => {
156
                flags => 1
213
                flags => 4096
157
            }
214
            }
158
        }
215
        }
159
    );
216
    );
160
217
218
    my $sth = $dbh->prepare("INSERT INTO user_permissions (borrowernumber, module_bit, code)
219
                        SELECT ?, bit, ?
220
                        FROM userflags
221
                        WHERE flag = ?");
222
    $sth->execute($patron->borrowernumber, 'stage_marc_import', 'tools');
223
161
    my $pwd = 'thePassword123';
224
    my $pwd = 'thePassword123';
162
    $patron->set_password( { password => $pwd, skip_validation => 1 } );
225
    $patron->set_password( { password => $pwd, skip_validation => 1 } );
163
226
164
- 

Return to bug 23019