Naviga ID
Docs HomeInfomakerNaviga
  • Introduction
  • Release notes
  • Architecture
    • Authorization schema
  • Integrations
    • Customer Integration
      • Microsoft Azure
      • Google G Suite
      • Custom Identity Provider
      • Moving to a New Identity Provider
    • Service Integration
      • IMSG and headers
  • Services
    • Admin API
      • Routes
        • Health
        • Organizations
        • Permissions
        • Roles
        • Units
        • Services
        • Subjects
        • Organization applications
        • Internal applications
    • IMSG
      • Routes
        • Imsg-service
      • Environment variables
  • Shared modules
    • Http Test Server
      • HttpTestServer
    • Service Authorization Lib
      • Authorize
      • Errors
      • ExpressMiddleware
      • TokenUtils
      • Hapi plugin
      • ServiceAuthorizationError
      • AccessDenied
      • Unauthorized
      • ConfigError
  • Client Credentials
    • Managing Applications
    • Internal Naviga ID Docs
  • Access Token
    • Fetching and using Access Tokens
    • Validate Access Tokens
  • Local development
    • Local HTTPS support
  • Post Mortem
    • Broken backwards compatibility in access token service for client credentials, 20th Dec 2021
Powered by GitBook
On this page
  • HttpTestServer{#HttpTestServer}
  • HttpTestServer{#HttpTestServer}
  • start()
  • stop()
  • getServerHost() {#getServerHost}⇒ string
  • waitForCall(endpoint, [params]) {#waitForCall}⇒ Promise.<Object>
  • onHttpCall(request, response) {#onHttpCall}⇒ Promise.<Object> | void

Was this helpful?

Export as PDF
  1. Shared modules
  2. Http Test Server

HttpTestServer

HttpTestServer{#HttpTestServer}

HttpTestServer{#HttpTestServer}

Http server to help the systemtest visualize http calls.

new HttpTestServer(params)

Param
Type
Description

params

Object

Required - The params object containing properties passed to the constructor

params.port

number

Required - Port number to start the Http server on

params.enableHealthEndpointAt

string

Required - Url string with the endpoint to the healthcheck

start()

Start the http server.

Listening on specified port.

stop()

Stop the Http server.

Checks if there are any http calls left to respond to or endpoints waiting for calls, responds to these endpoints and then stops the server.

Throws errror if there are leftover calls not handled before shutdown.

getServerHost() {#getServerHost}⇒ string

Gets the server host.

Returns: string - networkInterfaceAddress - A string with the address for the eth0 network

waitForCall(endpoint, [params]) {#waitForCall}⇒ Promise.<Object>

Gets an endpoint to handle. Checks if an endpoint is waiting for an answer and resolves an answer to it.

Or puts the endpoint on a queue to be handled when a request for that endpoints comes in.

Returns: Promise.<Object> - Promise object represents the object with resolve, reject and params to resolve the incoming http call

Param
Type
Default
Description

endpoint

string

Required - Url string with the endpoint to either resolve or put on a queue

params

Object

{}

Object with params to the request. Example: treatContentTypeAs: 'application/json'

onHttpCall(request, response) {#onHttpCall}⇒ Promise.<Object> | void

Handles all incoming Http calls

Either puts the request on queue to be handled or responds with data.

Returns: Promise.<Object> | void - Promise object represents an object with the data from the request or, returns void and puts the request in queue.

Param
Type
Description

request

Object

Required - Request object with the incoming http call

response

Object

Required - Response object to respond to the incoming http call

PreviousHttp Test ServerNextService Authorization Lib

Last updated 3 years ago

Was this helpful?