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

hivesolutions / appier-extras / #621924187

20 May 2024 06:47PM UTC coverage: 48.328%. First build
#621924187

Pull #45

travis-ci

Pull Request #45: Support for FIDO2 authentication

34 of 93 new or added lines in 6 files covered. (36.56%)

3150 of 6518 relevant lines covered (48.33%)

0.97 hits per line

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

45.0
/src/appier_extras/utils/serialization.py
1
#!/usr/bin/python
2
# -*- coding: utf-8 -*-
3

4
# Hive Appier Framework
5
# Copyright (c) 2008-2024 Hive Solutions Lda.
6
#
7
# This file is part of Hive Appier Framework.
8
#
9
# Hive Appier Framework is free software: you can redistribute it and/or modify
10
# it under the terms of the Apache License as published by the Apache
11
# Foundation, either version 2.0 of the License, or (at your option) any
12
# later version.
13
#
14
# Hive Appier Framework is distributed in the hope that it will be useful,
15
# but WITHOUT ANY WARRANTY; without even the implied warranty of
16
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
# Apache License for more details.
18
#
19
# You should have received a copy of the Apache License along with
20
# Hive Appier Framework. If not, see <http://www.apache.org/licenses/>.
21

22
__author__ = "João Magalhães <joamag@hive.pt>"
2✔
23
""" The author(s) of the module """
24

25
__copyright__ = "Copyright (c) 2008-2024 Hive Solutions Lda."
2✔
26
""" The copyright for the module """
27

28
__license__ = "Apache License, Version 2.0"
2✔
29
""" The license for the module """
30

31
import json
2✔
32
import base64
2✔
33

34
import appier
2✔
35

36

37
class BytesEncoder(json.JSONEncoder):
2✔
38
    """
39
    Custom JSON encoder that makes sure that bytes
40
    are properly encoded as Base64 strings.
41
    """
42

43
    def default(self, obj):
2✔
NEW
44
        if isinstance(obj, appier.legacy.BYTES):
×
NEW
45
            return base64.b64encode(obj).decode("utf-8")
×
NEW
46
        return json.JSONEncoder.default(self, obj)
×
47

48

49
def bytes_decoder(map):
2✔
NEW
50
    for key, value in map.items():
×
NEW
51
        if isinstance(value, str):
×
NEW
52
            try:
×
NEW
53
                decoded_value = base64.b64decode(value)
×
NEW
54
                map[key] = decoded_value
×
NEW
55
            except (ValueError, TypeError):
×
NEW
56
                pass
×
NEW
57
    return map
×
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