@monitorapex/api-test-utils

1.0.0 • Public • Published

Introduction

Provides authentication and Oracle DB utilities for API testing.

Installation

npm install --save-dev api-test-utils

Config

This library expects config data in a specific format in order to work. In order for the appropriate config to be used, the NODE_ENV environmental variable should be set on the machine in question. If nothing is set, then azure-dev is used by default.

{
  "azure-dev": {
    "apiUrl": "http://dev/your.app.url",
    "authUrl": "http://dev/your.oauth.token.url",
    "db": {
      "user": "myuser",
      "password": "mypass",
      "connectString": "dev.myconnect.string"
    }
  },
  "azure-ci": {
    "apiUrl": "http://ci/your.app.url",
    "authUrl": "http://ci/your.oauth.token.url",
    "db": {
      "user": "myuser",
      "password": "mypass",
      "connectString": "ci.myconnect.string"
    }
  },
}

Usage

Initializing

// To get started get your config...
const envData = require('./config/env.json');

//...and pass your config into apiUtils require
const apiUtils = require('api-test-utils')(envData);

Get an access token

const accessToken = await apiUtils.getAccessToken();

Perform queries/DML

const oracle = apiUtils.Oracle();

oracle.query('UPDATE table SET.....');

// If you need to await the result you can
await oracle.query('UPDATE table SET....');

Access the env config

const config = apiUtils.Config();

config.getValue('apiKey');

Changelog

  • 1.3.2 - Remove caching of access token accross tests.

Readme

Keywords

none

Package Sidebar

Install

npm i @monitorapex/api-test-utils

Weekly Downloads

0

Version

1.0.0

License

UNLICENSED

Unpacked Size

4.74 kB

Total Files

7

Last publish

Collaborators

  • drumbeg
  • dlawton