bbva-gnotifier-sp

Project gNotifier

Usage no npm install needed!

<script type="module">
  import bbvaGnotifierSp from 'https://cdn.skypack.dev/bbva-gnotifier-sp';
</script>

README

Build status

  • master

Quality Gate Status Coverage New Coverage

  • develop

Quality Gate Status Coverage New Coverage

  • feature

Quality Gate Status Coverage New Coverage

GNotifier

v1.6.0

Introduction

Backend project for the GNotifier API in BBVA. It uses Firebase in order to send notifications to devices. The user documentation of the product can be reached in this url.

Script usage

In the present project is included a variety of scripts launched via npm. You have to configure your node environment as told in the BBVA documentation.

One script with npm is invoked this way:

npm run <script_name>

Now we list all the availables scripts:

  • install: Install all the dependencies of the project scripts. This step is needed in order to launch the funcional tests.

    npm install
    
  • test: Run unit test inside the repo. You have to setup the Python virtual environment first. The virtual environment is created with the fga-cli.py install all instruction.

    $ source venv/bin/activate
    (venv) $ npm test
    

    Here is an example of the output:

    (venv) ➜  bbva-gnotifier-sp git:(feature/GNOT_PcnZf61m-Listado-de-plantillas-disponibles-para-un-backend) ✗ npm test
    > bbva-gnotifier-sp@1.3.0-alpha.5 test /Users/albertoeyocastro-rial/sngular/wk-gcp/bbva-gnotifier-sp
    > python tests/test.py ~/google-cloud-sdk/platform/google_appengine/
    
    test_get_config_au (tests.test_config.TestConfig) ... ok
    test_get_config_dev (tests.test_config.TestConfig) ... ok
    test_get_config_other (tests.test_config.TestConfig) ... ok
    test_get_config_pro (tests.test_config.TestConfig) ... ok
    test_get_config_testing (tests.test_config.TestConfig) ... ok
    (...)
    test_validate_template_spanish_android_priority_right (tests.src.helper.test_template_helper.TestTemplateHelper) ... ok
    test_validate_template_spanish_android_priority_wrong (tests.src.helper.test_template_helper.TestTemplateHelper) ... ok
    test_validate_template_spanish_notification_no_title (tests.src.helper.test_template_helper.TestTemplateHelper) ... ok
    test_validate_template_test_template (tests.src.helper.test_template_helper.TestTemplateHelper) ... ok
    test_validate_with_apns_ko (tests.src.helper.test_template_helper.TestTemplateHelper) ... ok
    test_validate_with_apns_ok (tests.src.helper.test_template_helper.TestTemplateHelper) ... ok
    
    ----------------------------------------------------------------------
    Ran 228 tests in 4.651s
    
    OK (skipped=3)
    
  • python-install: Run fga-cli.py install all command.

    npm run python-install
    
  • start: Run fga-cli.py run command. Starts in the local environment the application.

    npm run start
    
  • coverage: Calculate the coverage report for the unit tests of the application. It generates a xml file that sonar can understand to show the report. If you include the coverage html after this command, you generate a htmlcov directory in the root of the project where you can find an index.html file with the report in HTML format.

    npm run coverage
    npm run coverage && coverage html # This generate the html view
    
  • sonar: Run the sonar-scanner in your project. The configuration file for sonar is the sonar-projet.properties in the root of the project. Combined with the coverage script, you can see in Sonar all the elements neccessary for the analysis of the repo.

    npm run sonar
    npm run coverage && npm run sonar # This way sonar shows the coverage
    
  • functional-test: This command launch the functional tests for the default environment (dev). First you have to configure the terminal (three environment variables in the moment of this documentation is made). You can see the README.md of the functional tests for more information.

    npm run functional-test
    

    Here is an example:

    (venv) ➜  bbva-gnotifier-sp git:(feature/GNOT_PcnZf61m-Listado-de-plantillas-disponibles-para-un-backend) ✗ npm run functional-test
    
    > bbva-gnotifier-sp@1.3.0-alpha.5 functional-test /Users/albertoeyocastro-rial/sngular/wk-gcp/bbva-gnotifier-sp
    > mocha -u tdd --recursive ./node_modules/bbva-gnotifier-sp-functional-test/test
    
    Warning, FIREBASE_CONFIG environment variable is missing. Initializing firebase-admin will fail
    
    
      All the entities in json format
        - Should return the destination in json
        - Should return the template in json
        - Should return the authorization in json
    
      Testing the bbva-gnotifier-sp endpoints for admin in the dev environment
        /templates endpoints
          # POST /templates
            ✓ Should return 403, the user is not admin (311ms)
            ✓ Should return 400, undefined template (142ms)
            ✓ Should return 400, template empty (132ms)
            ✓ Should return 400, template no name (207ms)
            ✓ Should return 400, template no defaultLanguage (200ms)
    (...)
         /templates endpoints
          # GET /templates
            ✓ Should get a list with no elements for that senderId (229ms)
            ✓ Should get a list of templates filtered with the senderId (382ms)
            ✓ Should get a list of templates filtered with the senderId. Include pageSize (217ms)
            ✓ Should get a list of templates filtered with the senderId. Include pageSize and paginationKey (286ms)
            ✓ Should get a list of templates filtered with the senderId. Last page (209ms)
            ✓ Should get a list of templates filtered with the senderId. Out of range (187ms)
    
      Testing the index file
        - Should write the token in the console
        - Should write the token in the console
        - Should write the token in the console
        - Three elements, ok
        - Array empty, ko
        - Array null, ko
        - Three elements, ko
    
      Testing utils
        ✓ Should get the auth id
    
    
    108 passing (53s)
    10 pending
    

FGA features

This archetype includes the Framework for Google Applications (FGA). You can read its documentation here.

Swagger

You have an already configured swagger ui for you to use at your discretion. If you want to use it, just create a web credential, add the following links to the authorized redirect URIs section:

After that, take the client id of the just created credential and place it in your dev resources under:

swagger:
    client_id: <client_id>

Now you can edit the swagger.yaml placed in the swagger folder.

To open the swagger ui go to the /ws-doc path on your local or developmet environment.

Contact

If you need additional information or have further questions, please do not hesitate to contact us at gcp.team@bbva.com.