GithubHelp home page GithubHelp logo

lambdalizator's People

Contributors

grzegorzpro avatar pdyba avatar redlickigrzegorz avatar songofroland avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

andreistr21

lambdalizator's Issues

Test client & auth

Currently test client is implicitly authorized by fake event json (even if auth flags are set to False). This behaviour should be unified and refined.

Create custom types for mapping-related functions

We use mapping mostly in brokers where one class is responsible for handling multiple different types of requests/events e.g.:

  • LambdaBroker: Mapping[str, Callable[[dict], LambdaResponse]]
  • EventBroker: Mapping[str, List[Callable[[Event], None]]]

The idea is to create a custom type for functions that are compatible with the above brokers or even for the whole mapping itself. Thanks to that we won't have to implement it from scratch everywhere where it is used/needed ๐Ÿ™‚

Improve the quality of tests written for the authz-related code

There are a couple of comments that were not resolved in the past, so, I have gathered all of them in one place:

You should remove this line, because you overwrite full access by non access ๐Ÿ˜‰

Originally posted by @redlickigrzegorz in #47 (comment)

In general, you don't have to mock it. You can check the singleton if all data are inside ๐Ÿ˜‰

Originally posted by @redlickigrzegorz in #47 (comment)

Maybe jwt_standard_claims? This name would say more than the partial payload ๐Ÿ˜‰

Originally posted by @redlickigrzegorz in #47 (comment)

I am not sure if the User should contain these values - it is only a part of the token ๐Ÿค”

Originally posted by @redlickigrzegorz in #47 (comment)

As we already get known, this is not that good value for this key. It would be good to fix that in the upcoming versions.

Originally posted by @redlickigrzegorz in #47 (comment)

The above two tests are wrongly named, you expect missing iss but the name is saying about exp ๐Ÿ˜‰

Originally posted by @redlickigrzegorz in #47 (comment)

I think this formatting could be easily improved manually ๐Ÿ˜‰ Especially that this comment is not needed at all.

Originally posted by @redlickigrzegorz in #47 (comment)

That's the thought standing behind my previous comment, we shouldn't create tests that can pass for different reasons. The environment should be prepared the way which represents the edge case which we want to test ๐Ÿ˜‰

Here, no matter if you have "deny": {ALL: ALL} or just "deny": {} this test will pass, so we can modify the code and this check won't point potential problems.

Originally posted by @redlickigrzegorz in #47 (comment)

This test does not confirm inheritance ๐Ÿ˜• You should pass the Authorization header which does not have access to the handler method and thanks to inheritance it will get it anyway because it is declared in the guest authorization.

Originally posted by @redlickigrzegorz in #47 (comment)

Accessing request.json_body when no Content-Type header crashes whole app

[ERROR]	2020-09-29T12:05:35.279Z
Content-Type header is missing or wrong: ""
Traceback: Traceback (most recent call last):
  File "/var/task/lambdas/handlers.py", line 14, in handle_http
    logger.info(f"Request body: {api.request.json_body}")
  File "/var/task/lbz/communication.py", line 86, in json_body
    raise BadRequestError(
lbz.exceptions.BadRequestError: Content-Type header is missing or wrong: "

Empty CORS_ORIGIN env variable causes IndexError

By default, CORS_ORIGIN is equal to the empty list: /lbz/_cfg.py#L9.

But the only place that uses this configuration value assumes that there is always at least one item present:
/lbz/resource.py#L155

    def __init__(
        ...
        self._resp_headers = {
            ALLOW_ORIGIN_HEADER: self._get_allowed_origins(origins or CORS_ORIGIN.value),
            ...
        }

    def _get_allowed_origins(self, origins: List[str]) -> str:
        ...
        return origins[0]

The same code before v0.5.16 put a single element on this list, that's why this line "worked" without errors before:
/lbz/resource.py#L162

    def __init__(
        ...
        self._resp_headers = {
            ALLOW_ORIGIN_HEADER: self._get_allowed_origins(
                origins or env.get("CORS_ORIGIN", "").split(",")
            ),
            ...
        }

This problem shows also incompleteness of the unit tests - they need to be improved during fixing this bug ๐Ÿ˜‰

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.