• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

openSUSE / cavil / 20925214435

12 Jan 2026 03:36PM UTC coverage: 94.96% (+0.04%) from 94.92%
20925214435

push

github

kraih
Add API key management UI

100 of 102 new or added lines in 8 files covered. (98.04%)

7555 of 7956 relevant lines covered (94.96%)

4844.7 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

90.0
/lib/Cavil/Controller/APIKeys.pm
1
# Copyright (C) 2024 SUSE LLC
2
#
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
7
#
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
# GNU General Public License for more details.
12
#
13
# You should have received a copy of the GNU General Public License along
14
# with this program; if not, see <http://www.gnu.org/licenses/>.
15

16
package Cavil::Controller::APIKeys;
17
use Mojo::Base 'Mojolicious::Controller', -signatures;
547✔
18

19
sub create ($self) {
1✔
20
  my $validation = $self->validation;
1✔
21
  $validation->optional('description');
1✔
22
  $validation->required('expires')->like(qr/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}$/);
1✔
23
  return $self->reply->json_validation_error if $validation->has_error;
1✔
24

25
  my $owner   = $self->users->id_for_login($self->current_user);
1✔
26
  my $api_key = $self->api_keys->create(
1✔
27
    owner       => $owner,
28
    description => $validation->param('description'),
29
    expires     => $validation->param('expires')
30
  );
31

32
  $self->render(json => {created => $api_key->{id}});
1✔
33
}
34

NEW
35
sub list ($self) {
×
NEW
36
  $self->render('api_keys/list');
×
37
}
38

39
sub list_meta ($self) {
2✔
40
  my $owner_id = $self->users->id_for_login($self->current_user);
2✔
41
  my $keys     = $self->api_keys->list($owner_id);
2✔
42
  $self->render(json => {keys => $keys});
2✔
43
}
44

45
sub remove ($self) {
2✔
46
  my $api_key_id = $self->param('id');
2✔
47
  my $owner_id   = $self->users->id_for_login($self->current_user);
2✔
48
  my $removed    = $self->api_keys->remove($api_key_id, $owner_id);
2✔
49
  $self->render(json => {removed => $removed});
2✔
50
}
51

52
1;
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc