ark::catalog::TestCatalogApiGateway

Defined in header “ark/catalog/api_gateway/testing/helpers.hh”.


This class will spawn a test instance of a catalog API gateway.

Methods

  • TestCatalogApiGateway(const std::filesystem::path & sqlite_path, const core::Url & metric_endpoint, const core::Url & logs_endpoint)
    Constructor. Initializes the gateway with defaults, using a SQLite database at the given path. Immediately starts a background thread that polls.

  • TestCatalogApiGateway(const TestCatalogApiGatewayConfig & config)
    Constructor. Initializes the gateway with defaults, using the given configuration. Immediately starts a background thread that polls.

  • ~TestCatalogApiGateway()
    Destructor. Closes down the site gracefully.

  • comms::NetworkAddress address()
    Returns the address the server is running at.

  • core::Url url()
    Returns the URL that the server is running at.

  • CatalogApiGateway & gateway()
    Returns a reference to the gateway that we are using.

  • const std::string & authenticated_user_token()
    Returns the JWT token that can be used to make authenticated requests.

  • const std::string & authenticated_admin_token()
    Returns the JWT token that can be used to make authenticated requests in an admin setting.

  • const std::string & s2s_token()
    Returns the JWT token that can be used to make S2S requests.

  • CatalogApiBase user_client()
    Returns an API client suitable for use with this gateway, for standard user level work.

  • CatalogApiBase admin_client()
    Returns an API client suitable for use with this gateway, for administrator-level work.

  • CatalogApiBase unauthenticated_client()
    Returns an API client suitable for use with this gateway, for non-authenticated work.

  • CatalogApiBase s2s_client()
    Returns an API client suitable for use with this gateway, for service-to-service communications.

  • const std::string & client_id()
    Returns the client ID for authentication.

  • void register_standard_users()
    Called to register users into standard groups. This will place the test user into the TBD organization, for tests that require that.

  • void register_robot(const core::Guid & organization_id, const std::string & serial_number)
    Registers a new robot with the given serial number in the specified organization. The client ID will be the client ID that can be used for authentication (ie, via the s2s_client).

  • std::string register_ingest_job(const core::Guid & organization_id)
    Registers a new ingest job in the given organization ID. This ingest job will have a token associated with it, which can be used to test various auth APIs.

  • core::Guid register_private_organization(const std::string & username)
    Called to register a private organization (with the ID returned). The test user is added to this organization. If you leave the username empty, just generates an organization and doesn’t add any user to it.

  • std::string create_new_user(const std::string & username)
    Creates a new user, returning its token.

  • std::string generate_new_s2s_token(const std::string & client_id, const std::string & scope)
    Generates a new S2S token for the specified client identifier.