Code Monkey home page Code Monkey logo

scanapi's Issues

Considering any variable that has at least one upper case letter as env var

Problem

If we define a var containing an upper case letter, like:

vars:
    apiKey: abc123

and we try to use it later as ${apiKey} it will raise the error:

ERROR:scanapi.evaluators.string_evaluator:'apiKey' environment variable not set or badly c

Possible Solution

To check if there is any lower case in the word here:

https://github.com/camilamaia/scanapi/blob/master/scanapi/evaluators/string_evaluator.py#L48

if any(letter.islower() for letter in variable_name):
  continue

Validate mandatory keys for API spec

Description

We need to ensure that API spec has some mandatories keys in order to work properly.

The first mandatory key that need to be checked is the key api. The specification should start with it.
https://github.com/scanapi/scanapi/blob/master/scanapi/__init__.py#L68

Under the key endpoints, we need to ensure each entry has at least a name and a requests key
https://github.com/scanapi/scanapi/blob/master/scanapi/tree/endpoint_node.py#L79

Under the key requests, we need to ensure each entry has at least a name and a path key.
https://github.com/scanapi/scanapi/blob/master/scanapi/tree/request_node.py#L106

This is an example of a minimal possible structure:

api:
  endpoints:
    - name: scanapi-demo
      requests:
        - name: health
          path: http://demo.scanapi.dev/api/health/

If any of this mandatories keys is missing, an error should be raised.

Implement Query Params

Similar to headers implementation

api:
  base_url: ${BASE_URL}
  headers:
    Authorization: ${BEARER_TOKEN}
  params:
    per_page: 10

Make html report pretty

πŸ’„

  • Show only path_url in the titles
  • Add response and request headers
  • Add request headers and body
  • Add response headers, metada and body
  • Add cURL
  • Add response time

Improve Error Message for Invalid Python code error

Current, when there is an error when executing a command inside the python code tag ${{ }}, this is the message:

ERROR:scanapi.evaluators.string_evaluator:Invalid Python code defined in the API spec: Expecting value: line 1 column 1 (char 0)

We should improve it to show precisely which error happened.

Stop using eval to evaluate python code on API specification

Currently we are evaluating python code from API specification ${{ code }} using eval:

sequence, match.group(), str(eval(code))

We must use a safer and more elegant solution. I am out of ideas here.

  • Templates (like jinja) don't work because we need to evaluate dynamically the python code while the requests are being made. The python code might depend on the last request response, for example.
  • ast.literal_eval does not support access to external variables

No module named 'scanapi.tree'

Error when running scanapi v0.0.15

    from scanapi.tree.api_tree import APITree
ModuleNotFoundError: No module named 'scanapi.tree'

Add Factory Boy

factory_boy is a fixtures replacement based on thoughtbot’s factory_bot

As a fixtures replacement tool, it aims to replace static, hard to maintain fixtures with easy-to-use factories for complex object.

Instead of building an exhaustive test setup with every possible combination of corner cases, factory_boy allows you to use objects customized for the current test, while only declaring the test-specific fields:

Create ScanAPI spec from an OpenAPI specification

Create ScanAPI spec from an OpenAPI specification

Create a command that converts an OpenAPI specification file into a ScanAPI specification file.
OpenAPI Specification: https://swagger.io/specification/

For that, we need to create a new Click command called convert in the __main__.py file.

With the arguments:

  • input file path (required)
  • output file path (required)

And with the options:

  • -f, --from, input_format. (default should be openapi, required)
  • -t, --to, output_format. (default should be scanapi, required)

Example:

$ scanapi convert -f openapi -t scanapi OPENAPI_PATH SCANAPI_PATH 

Related issue: ADR 6: How to integrate feature that converts OpenAPI file to ScanAPI file

Alert if CHANGELOG.md was not updated

Description

When a PR is opened and the CHANGELOG.md was not modified, send an alert to remember to update it.

Possible to be implemented with:

Or, alternatively, to create a CircleCI check that fails when it is not updated.

Update CONTRIBUTING.md

Description

Update CONTRIBUTING.md with:

  • Instructions of how to create a release PR
  • Instructions of how to deploy on docker hub with version tag

Create Expected Assertions for Requests

A assertions.yaml with some assertions for each request.

for example, posts_list_all must have:

  • x Length?
  • this Structure?
  • which type of data for each field?

Tasks:

  • define a format for it
  • implement how to run the assertions

in the future, we can create alerts when the assertions fails

Allow PATCH HTTP Method

Hi, I see that HTTP requests PATCH method are not implemented, for any particular reason?

Thank you.
Congratulations on the project, it is a great idea. πŸ‘Œ

Hide tokens and authorization info in the generated report

Description

Add the possibility to hide tokens and authorization info in the generated report to avoid expose sensitive information via configuration file (usually .scanapi.yaml).

Change the sensitive information value to <sensitive_information>

Configuration Options:

  • report
    -- hide-response or hide-request
    --- headers or body or url
    ---- list of keys to hide

Example:

report:
  hide-response:
    headers:
      - Authorization
      - api-key
  hide-response:
    body:
      - api-key

The logic is implemented inside the hide_sensitive_info method

Example of how this should be rendered in the reports:

image

  • header for request
  • header for response
  • body for request
  • body for response
  • url for request
  • url for response

Refactor on evaluation process

Implement Cases

...
          requests:
                  - name: list_all # posts_list_all
                    method: get
                    case: when user is not authenticated
                    ...
                  - name: list_all # posts_list_all
                    method: get
                    case: when user is authenticated
                    ...

Hide sensitive info from headers is not working

Description

After the refactor on the reporter templates, hide sensitive info from headers is not working. It shows the real data instead of "<sensitive information>"

How to reproduce

Create a config file .scanapi.yaml with the content:

docs:
  hide:
    headers:
      - Authorization

Run scanapi with this config file and set an Authorization header inside the api specification:

api:
  base_url: ${BASE_URL}
  headers:
    Authorization: token123

The word token123 will appear in the report, instead of "<sensitive information>"

Make console report pretty

To make console report prettier. And to add response time to it.

This is how it looks like now:

ScanAPI Report: Console
=======================

GET http://demo.scanapi.dev/api/health/ - 200
GET http://demo.scanapi.dev/api/languages/ - 200
GET http://demo.scanapi.dev/api/devs/ - 200
GET http://demo.scanapi.dev/api/devs/?newOpportunities=True - 200
GET http://demo.scanapi.dev/api/devs/?newOpportunities=False - 200
POST http://demo.scanapi.dev/api/devs/ - 201
GET http://demo.scanapi.dev/api/devs/129e8cb2-d19c-51ad-9921-cea329bed7fa - 404
GET http://demo.scanapi.dev/api/devs/129e8cb2-d19c-41ad-9921-cea329bed7f0 - 200
DELETE http://demo.scanapi.dev/api/devs/129e8cb2-d19c-41ad-9921-cea329bed7f0 - 200
GET http://demo.scanapi.dev/api/devs/129e8cb2-d19c-41ad-9921-cea329bed7f0/languages - 200

Maybe to add some different colours to each HTTP method?

πŸ’„

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.