Commit f2af4a10 authored by garciadeblas's avatar garciadeblas
Browse files

Enable pylint, black and flake8 in tox.ini



Change-Id: I5e252eb4802b79497a3fdfea63488668d8a8c692
Signed-off-by: default avatargarciadeblas <gerardo.garciadeblas@telefonica.com>
parent 838e4fb6
Loading
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -13,7 +13,5 @@
# See the License for the specific language governing permissions and
# limitations under the License.

set -e
echo "Launching tox"
tox --parallel=auto
TOX_PARALLEL_NO_SPINNER=1 tox --parallel=auto
+14 −37
Original line number Diff line number Diff line
@@ -399,48 +399,25 @@ class CommonVimWimSdn(BaseTopic):
        if content.get("vim_type"):
            if content["vim_type"] == "openstack":
                compute = {
                    "ram": {
                        "total": None,
                        "used": None
                    },
                    "vcpus": {
                        "total": None,
                        "used": None
                    },
                    "instances": {
                        "total": None,
                        "used": None
                    }
                    "ram": {"total": None, "used": None},
                    "vcpus": {"total": None, "used": None},
                    "instances": {"total": None, "used": None},
                }
                storage = {
                    "volumes": {
                        "total": None,
                        "used": None
                    },
                    "snapshots": {
                        "total": None,
                        "used": None
                    },
                    "storage": {
                        "total": None,
                        "used": None
                    }
                    "volumes": {"total": None, "used": None},
                    "snapshots": {"total": None, "used": None},
                    "storage": {"total": None, "used": None},
                }
                network = {
                    "networks": {
                        "total": None,
                        "used": None
                    },
                    "subnets": {
                        "total": None,
                        "used": None
                    },
                    "floating_ips": {
                        "total": None,
                        "used": None
                    "networks": {"total": None, "used": None},
                    "subnets": {"total": None, "used": None},
                    "floating_ips": {"total": None, "used": None},
                }
                content["resources"] = {
                    "compute": compute,
                    "storage": storage,
                    "network": network,
                }
                content["resources"] = {"compute": compute, "storage": storage, "network": network}

        return "{}:0".format(content["_id"])

+8 −7
Original line number Diff line number Diff line
@@ -449,9 +449,11 @@ class Authenticator:
                elif auth_list[0].lower() == "basic":
                    user_passwd64 = auth_list[-1]
            if not token:
                if cherrypy.session.get("Authorization"):
                if cherrypy.session.get("Authorization"):  # pylint: disable=E1101
                    # 2. Try using session before request a new token. If not, basic authentication will generate
                    token = cherrypy.session.get("Authorization")
                    token = cherrypy.session.get(  # pylint: disable=E1101
                        "Authorization"
                    )
                    if token == "logout":
                        token = None  # force Unauthorized response to insert user password again
                elif user_passwd64 and cherrypy.request.config.get(
@@ -466,10 +468,10 @@ class Authenticator:
                    except Exception:
                        pass
                    outdata = self.new_token(
                        None, {"username": user, "password": passwd}
                        None, {"username": user, "password": passwd}, None
                    )
                    token = outdata["_id"]
                    cherrypy.session["Authorization"] = token
                    cherrypy.session["Authorization"] = token  # pylint: disable=E1101

            if not token:
                raise AuthException(
@@ -508,8 +510,8 @@ class Authenticator:
            return token_info
        except AuthException as e:
            if not isinstance(e, AuthExceptionUnauthorized):
                if cherrypy.session.get("Authorization"):
                    del cherrypy.session["Authorization"]
                if cherrypy.session.get("Authorization"):  # pylint: disable=E1101
                    del cherrypy.session["Authorization"]  # pylint: disable=E1101
                cherrypy.response.headers[
                    "WWW-Authenticate"
                ] = 'Bearer realm="{}"'.format(e)
@@ -775,7 +777,6 @@ class Authenticator:
        :param outdata: user token information
        """
        user_content = None
        detail = {}
        present_time = time()
        user = outdata["username"]
        if self.config["authentication"].get("pwd_expiry_check"):
+1 −0
Original line number Diff line number Diff line
@@ -204,6 +204,7 @@ class Authconn:
        :param filter_q: dictionary to filter user list by name (username is also admited) and/or _id
        :return: returns a list of users.
        """
        return list()  # Default return value so that the method get_user passes pylint

    def get_user(self, _id, fail=True):
        """
+9 −4
Original line number Diff line number Diff line
@@ -33,7 +33,11 @@ __date__ = "$06-jun-2019 11:16:08$"
import logging
import re

from osm_nbi.authconn import Authconn, AuthException, AuthconnConflictException  # , AuthconnOperationException
from osm_nbi.authconn import (
    Authconn,
    AuthException,
    AuthconnConflictException,
)  # , AuthconnOperationException
from osm_common.dbbase import DbException
from osm_nbi.base_topic import BaseTopic
from osm_nbi.validation import is_valid_uuid
@@ -380,11 +384,12 @@ class AuthconnInternal(Authconn):
        )
        if old_pwd:
            salt = user_data["_admin"]["salt"]
            shadow_password = sha256(old_pwd.encode('utf-8') + salt.encode('utf-8')).hexdigest()
            shadow_password = sha256(
                old_pwd.encode("utf-8") + salt.encode("utf-8")
            ).hexdigest()
            if shadow_password != user_data["password"]:
                raise AuthconnConflictException(
                    "Incorrect password",
                    http_code=HTTPStatus.CONFLICT
                    "Incorrect password", http_code=HTTPStatus.CONFLICT
                )
        BaseTopic.format_on_edit(user_data, user_info)
        # User Name
Loading