[
  {
    "comment": "declare default parameters for get_network_keys test part",
    "include": "_defaults",
    "params": {
      "network": "_required",
      "rootEmail": "root@example.com",
      "networkKeysVar": "networkKeys",
      "networkKeysPassword": "Passw0rd!"
    }
  },

  {
    "comment": "request network keys",
    "request": { "uri": "me/networks/<<network>>/actions/keys" }
  },

  {
    "comment": "await and get network keys request in email inbox",
    "before": "await_url debug/inbox/email/<<rootEmail>>?type=request&action=password&target=network 3m 5s len(await_json) > 0",
    "request": { "uri": "debug/inbox/email/<<rootEmail>>?type=request&action=password&target=network" },
    "response": {
      "store": "emailInbox",
      "check": [
        {"condition": "'{{json.[0].ctx.message.messageType}}' == 'request'"},
        {"condition": "'{{json.[0].ctx.message.action}}' == 'password'"},
        {"condition": "'{{json.[0].ctx.message.target}}' == 'network'"}
      ]
    }
  },

  {
    "comment": "approve key request",
    "request": {
      "uri": "auth/approve/{{emailInbox.[0].ctx.confirmationToken}}",
      "method": "post"
    }
  },

  {
    "comment": "await and get key request confirmation from email inbox",
    "before": "await_url debug/inbox/email/<<rootEmail>>?type=confirmation&action=password&target=network 3m 5s len(await_json) > 0",
    "request": { "uri": "debug/inbox/email/<<rootEmail>>?type=confirmation&action=password&target=network" },
    "response": {
      "store": "emailInbox",
      "check": [
        {"condition": "'{{json.[0].ctx.message.messageType}}' == 'confirmation'"},
        {"condition": "'{{json.[0].ctx.message.action}}' == 'password'"},
        {"condition": "'{{json.[0].ctx.message.target}}' == 'network'"}
      ]
    }
  },

  {
    "comment": "use confirmation token in email to retrieve network keys",
    "request": {
      "uri": "me/networks/<<network>>/actions/keys/{{emailInbox.[0].ctx.message.requestId}}",
      "entity": { "name": "password", "value": "<<networkKeysPassword>>" }
    },
    "response": {
      "store": "<<networkKeysVar>>",
      "check": [
        {"condition": "json.getData().length >= 1"}
      ]
    }
  }
]