Markdown Scanner Accounts configuration file

March 9, 2016 ยท View on GitHub

To enable automated testing for predefined service accounts with Markdown Scanner you can confirm an accounts.json file as part of your documentation repo.

Inside the accounts.json file, you can define the parameters for various OAuth2 compatible accounts that will be used to generate access tokens for check-service functionality.

The format of the file is as follows:

{
  "checkServiceEnabledBranches": ["master", "release"],
  "accounts": [
    {
      "name": "AccountFriendlyName",
      "oauthMode": "RefreshToken",
      "enabled": true,
      "clientId": "",
      "clientSecret": "",
      "tokenService": "http://login.live.com/oauth2_token.srf",
      "redirectUri": "appuri://redirect_from_auth",
      "refreshToken": "cached-refresh-token",
      "serviceUrl": "https://api.onedrive.com/v1.0",
      "scopes": ["scope1", "scope2"]

    }
  ]
}

You can define as many account objects within the accounts array as you need. Each enabled account is processed sequentially when running the check-service method. You can also specify a specific account to run using the --account <name> command line parameter.

Types of Accounts

OAuth 2 Refresh Token Accounts

In this scenario, a refresh token generated by an application is stored along with the information about the application that generated the refresh token.

These details are used to call the OAuth2 token service specified and redeem the cached refresh token for a new access token. This method works great for services where the refresh token does not expire.

The following account fields are used for refresh token accounts:

Field NameTypeDescription
namestringFriendly name of the account
oauthModestringSet to RefreshToken
enabledbooleanDetermines if the account is enabled for running automatically with check-service method.
clientIdstringClient ID for the application that generated the refresh token
clientSecretstringOptional value. Client secret for the application that generated the refresh token.
tokenServicestringThe token service endpoint used to redeem the refresh token
redirectUristringThe refresh URI for the application that generated the refresh token.
refreshTokenstringThe cached value of a refresh token.
serviceUrlstringThe base URL for the service that should be tested for this account.

OAuth 2 Username and Password Account

In this scenario, an access token is generated using the password grant flow which redeems a username and password for an OAuth access token for the service.

Field NameTypeDescription
namestringFriendly name of the account
oauthModestringSet to UserPassword
enabledbooleanDetermines if the account is enabled for running automatically with check-service method.
clientIdstringClient ID for the application that generated the refresh token
tokenServicestringSpecify the AAD authority URL. Usually https://login.microsoftonline.com/common.
serviceUrlstringThe base URL for the service that should be tested for this account.
usernamestringThe username to use when requesting access.
passwordstringThe user's password to use when requesting access.

Other Account parameters

The following additional parameters are valid for all account types, but are optional.

Field NameTypeDescription
additionalHeadersArray of StringsAn array of string values that are appended to all request headers verbatim.
typestringSpecify the type of the account, if your documentation has some methods that are only valid for certain account types
scopesArray of StringsSpecify the scopes provided by this account configuration, so only tests that require these scopes are executed.