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

(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/UsageStatisticsDataProvidersFormAdd.vue (-6 / +2 lines)
Lines 47-57 Link Here
47
                                    >{{ $__("Searching...") }}
47
                                    >{{ $__("Searching...") }}
48
                                </template>
48
                                </template>
49
                                <template v-else v-slot:no-options
49
                                <template v-else v-slot:no-options
50
                                    >{{
50
                                    >{{ $__("No results found") }}
51
                                        $__(
52
                                            "Type at least two characters to search"
53
                                        )
54
                                    }}
55
                                </template>
51
                                </template>
56
                                <template #search="{ attributes, events }">
52
                                <template #search="{ attributes, events }">
57
                                    <input
53
                                    <input
Lines 505-511 export default { Link Here
505
                    api_key_required && this.required_fields.push("API")
501
                    api_key_required && this.required_fields.push("API")
506
                    requestor_id_required &&
502
                    requestor_id_required &&
507
                        this.required_fields.push("Requestor")
503
                        this.required_fields.push("Requestor")
508
                    this.sushi_service = sushi_service
504
                    this.sushi_service = sushi_service || {}
509
                },
505
                },
510
                error => {}
506
                error => {}
511
            )
507
            )
(-)a/t/db_dependent/api/v1/erm_counter_registries.t (+167 lines)
Line 0 Link Here
1
#!/usr/bin/env perl
2
3
# Copyright 2023 PTFS Europe
4
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20
use Modern::Perl;
21
22
use Test::More tests => 1;
23
use Test::Mojo;
24
25
use t::lib::TestBuilder;
26
use t::lib::Mocks;
27
28
use JSON qw(encode_json);
29
30
use Koha::ERM::EUsage::CounterFiles;
31
use Koha::Database;
32
33
my $builder = t::lib::TestBuilder->new;
34
35
my $t = Test::Mojo->new('Koha::REST::V1');
36
t::lib::Mocks::mock_preference( 'RESTBasicAuth', 1 );
37
38
subtest 'get() tests' => sub {
39
    plan tests => 5;
40
41
    my $expected_response = [
42
        {
43
            "abbrev" => "EBSCO",
44
            "address" => "EBSCO Information Services\n10 Estes Street\nIpswich, MA 01938",
45
            "address_country" => {
46
                "code" => "US",
47
                "name" => "United States of America"
48
            },
49
            "contact" => {
50
                "email" => 'chadmovalli@ebsco.com',
51
                "form_url" => "",
52
                "person" => "Chad Movalli",
53
                "phone" => ""
54
            },
55
            "content_provider_name" => "EBSCO",
56
            "host_types" => [
57
                {
58
                    "name" => "Aggregated_Full_Content"
59
                }
60
            ],
61
            "id" => "b2b2736c-2cb9-48ec-91f4-870336acfb1c",
62
            "name" => "EBSCO Information Services",
63
            "reports" => [
64
                {
65
                    "counter_release" => "5",
66
                    "report_id" => "TR_J4",
67
                    "report_name" => "Title Report - Journal Report 4"
68
                },
69
                {
70
                    "counter_release" => "5",
71
                    "report_id" => "DR_D2",
72
                    "report_name" => "Database Report - Report 2"
73
                },
74
                {
75
                    "counter_release" => "5",
76
                    "report_id" => "TR_J3",
77
                    "report_name" => "Title Report - Journal Report 3"
78
                },
79
                {
80
                    "counter_release" => "5",
81
                    "report_id" => "DR_D1",
82
                    "report_name" => "Database Report - Report 1"
83
                },
84
                {
85
                    "counter_release" => "5",
86
                    "report_id" => "TR_J2",
87
                    "report_name" => "Title Report - Journal Report 2"
88
                },
89
                {
90
                    "counter_release" => "5",
91
                    "report_id" => "PR",
92
                    "report_name" => "Platform Master Report"
93
                },
94
                {
95
                    "counter_release" => "5",
96
                    "report_id" => "TR_B2",
97
                    "report_name" => "Title Report - Book Report 2"
98
                },
99
                {
100
                    "counter_release" => "5",
101
                    "report_id" => "TR_B3",
102
                    "report_name" => "Title Report - Book Report 3"
103
                },
104
                {
105
                    "counter_release" => "5",
106
                    "report_id" => "TR",
107
                    "report_name" => "Title Master Report"
108
                },
109
                {
110
                    "counter_release" => "5",
111
                    "report_id" => "TR_B1",
112
                    "report_name" => "Title Report - Book Report 1"
113
                },
114
                {
115
                    "counter_release" => "5",
116
                    "report_id" => "PR_P1",
117
                    "report_name" => "Platform Report - Report 1"
118
                },
119
                {
120
                    "counter_release" => "5",
121
                    "report_id" => "TR_J1",
122
                    "report_name" => "Title Report - Journal Report 1"
123
                },
124
                {
125
                    "counter_release" => "5",
126
                    "report_id" => "DR",
127
                    "report_name" => "Database Master Report"
128
                }
129
            ],
130
            "sushi_services" => [
131
                {
132
                    "counter_release" => "5",
133
                    "url" => "https:\/\/registry.projectcounter.org\/api\/v1\/sushi-service\/b94bc981-fa16-4bf6-ba5f-6c113f7ffa0b\/"
134
                }
135
            ],
136
            "website" => "https:\/\/www.ebsco.com\/"
137
        }
138
    ];
139
140
    my $librarian = $builder->build_object(
141
        {
142
            class => 'Koha::Patrons',
143
            value => { flags => 2**28 }
144
        }
145
    );
146
    my $password = 'thePassword123';
147
    $librarian->set_password( { password => $password, skip_validation => 1 } );
148
    my $userid = $librarian->userid;
149
150
    my $patron = $builder->build_object(
151
        {
152
            class => 'Koha::Patrons',
153
            value => { flags => 0 }
154
        }
155
    );
156
157
    $patron->set_password( { password => $password, skip_validation => 1 } );
158
    my $unauth_userid = $patron->userid;
159
160
    # Unauthorized access
161
    $t->get_ok("//$unauth_userid:$password@/api/v1/erm/counter_registry")->status_is(403);
162
163
    # Authorised access test
164
    my $q                = encode_json( { "name" => "EBSCO Information Services" } );
165
    my $counter_registry = $t->get_ok("//$userid:$password@/api/v1/erm/counter_registry?q=$q")->status_is(200)->tx->res->json;
166
    is_deeply( $counter_registry, $expected_response );
167
};
(-)a/t/db_dependent/api/v1/erm_sushi_services.t (-1 / +104 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/env perl
2
3
# Copyright 2023 PTFS Europe
4
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20
use Modern::Perl;
21
22
use Test::More tests => 1;
23
use Test::Mojo;
24
25
use t::lib::TestBuilder;
26
use t::lib::Mocks;
27
28
use JSON qw(encode_json);
29
30
use Koha::ERM::EUsage::CounterFiles;
31
use Koha::Database;
32
33
my $builder = t::lib::TestBuilder->new;
34
35
my $t = Test::Mojo->new('Koha::REST::V1');
36
t::lib::Mocks::mock_preference( 'RESTBasicAuth', 1 );
37
38
subtest 'get() tests' => sub {
39
    plan tests => 5;
40
41
    my $service_url = "https://registry.projectcounter.org/api/v1/sushi-service/b94bc981-fa16-4bf6-ba5f-6c113f7ffa0b/";
42
    my $expected_response = {
43
        "api_key_info"=> "",
44
        "api_key_required"=> 0,
45
        "contact"=> {
46
            "email"=> 'chadmovalli@ebsco.com',
47
            "form_url"=> "",
48
            "person"=> "Chad Movalli",
49
            "phone"=> ""
50
        },
51
        "counter_release"=> "5",
52
        "credentials_auto_expire"=> 0,
53
        "credentials_auto_expire_info"=> "",
54
        "customer_id_info"=> "This is your EBSCOhost Customer ID",
55
        "customizations_in_place"=> 0,
56
        "customizations_info"=> "",
57
        "data_host"=> "https:\/\/registry.projectcounter.org\/api\/v1\/usage-data-host\/72a35413-6fcd-44f2-8bce-0c7b2373e33f\/",
58
        "id"=> "b94bc981-fa16-4bf6-ba5f-6c113f7ffa0b",
59
        "ip_address_authorization"=> 0,
60
        "ip_address_authorization_info"=> "",
61
        "notification_count"=> 1,
62
        "notifications_url"=> "https:\/\/registry.projectcounter.org\/api\/v1\/sushi-service\/b94bc981-fa16-4bf6-ba5f-6c113f7ffa0b\/notification\/",
63
        "platform_attr_required"=> 0,
64
        "platform_specific_info"=> "",
65
        "request_volume_limits_applied"=> 0,
66
        "request_volume_limits_info"=> "",
67
        "requestor_id_info"=> "Customers generate their Requestor ID in EBSCOAdmin on the SUSHI Authentication tab within the COUNTER R5 Reports section.",
68
        "requestor_id_required"=> 1,
69
        "url"=> "https:\/\/sushi.ebscohost.com\/R5"
70
    };
71
72
    my $librarian = $builder->build_object(
73
        {
74
            class => 'Koha::Patrons',
75
            value => { flags => 2**28 }
76
        }
77
    );
78
    my $password = 'thePassword123';
79
    $librarian->set_password( { password => $password, skip_validation => 1 } );
80
    my $userid = $librarian->userid;
81
82
    my $patron = $builder->build_object(
83
        {
84
            class => 'Koha::Patrons',
85
            value => { flags => 0 }
86
        }
87
    );
88
89
    $patron->set_password( { password => $password, skip_validation => 1 } );
90
    my $unauth_userid = $patron->userid;
91
92
    # Unauthorized access
93
    $t->get_ok("//$unauth_userid:$password@/api/v1/erm/sushi_service")->status_is(403);
94
95
    # Authorised access test
96
    my $q = encode_json(
97
        {
98
            "url" => $service_url
99
        }
100
    );
101
    my $sushi_service = $t->get_ok("//$userid:$password@/api/v1/erm/sushi_service?q=$q")->status_is(200)
102
        ->tx->res->json;
103
    is_deeply( $sushi_service, $expected_response );
104
};

Return to bug 35218