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

telefonicaid / fiware-pep-steelskin / 11256688872

09 Oct 2024 02:06PM CUT coverage: 78.988% (-3.8%) from 82.787%
11256688872

Pull #544

github

web-flow
Merge 8bdd7b564 into 2c45e28dd
Pull Request #544: Task/add access matches (about users, headers, path. .. ) to access Logger

266 of 378 branches covered (70.37%)

Branch coverage included in aggregate %.

19 of 57 new or added lines in 4 files covered. (33.33%)

20 existing lines in 2 files now uncovered.

764 of 926 relevant lines covered (82.51%)

50.04 hits per line

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

93.75
/lib/plugins/urlTablePlugin.js
1
/*
2
 * Copyright 2014 Telefonica Investigación y Desarrollo, S.A.U
3
 *
4
 * This file is part of fiware-pep-steelskin
5
 *
6
 * fiware-pep-steelskin is free software: you can redistribute it and/or
7
 * modify it under the terms of the GNU Affero General Public License as
8
 * published by the Free Software Foundation, either version 3 of the License,
9
 * or (at your option) any later version.
10
 *
11
 * fiware-pep-steelskin is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14
 * See the GNU Affero General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU Affero General Public
17
 * License along with fiware-pep-steelskin.
18
 * If not, seehttp://www.gnu.org/licenses/.
19
 *
20
 * For those usages not covered by the GNU Affero General Public License
21
 * please contact with::[iot_support@tid.es]
22
 */
23

24
'use strict';
25

26
var errors = require('../errors');
1✔
27

28
/**
29
 * Generates a middleware that extracts the action from the request's URL and method using the table passed as a
30
 * parameter. Each row in the table should contain three elements:
31
 * - Method
32
 * - Regular expression to match the URL
33
 * - Name of the action
34
 *
35
 * If URL matches the regular expression and the request has the indicated method, the designated action is included
36
 * in the request object 'action' attribute.
37
 *
38
 * @param {Array} operations        Array of operations to map URLs to actions.
39
 * @return {Function}               Middleware that extracts the action from the URL and method.
40
 */
41
function extractAction(operations) {
1✔
42
    return function(req, res, callback) {
1✔
43
        const logger = req.logger;
10✔
44
        logger.debug('Extracting action from URL [%s] and method [%s]', req.url, req.method);
10✔
45

46
        for (var i = 0; i < operations.length; i++) {
10✔
47
            if (req.method === operations[i][0] &&
58✔
48
                req.path.match(operations[i][1])) {
49
                req.action = operations[i][2];
10✔
50
                callback(null, req, res);
10✔
51
                return;
10✔
52
            }
53
        }
54

55
        callback(new errors.ActionNotFound(), req, res);
×
56
    };
57
}
58

59
exports.extractAction = extractAction;
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

© 2025 Coveralls, Inc