test_name: Test performing account management operations.
marks:
  - usefixtures:
    - server_url
    - token_symbol
    - first_account_pin_number
    - second_account_pin_number
    - first_account_phone_number
    - second_account_phone_number
    - first_account_management_session_id
    - second_account_management_session_id
    - first_account_management_session_id_1
    - second_account_management_session_id_1
    - first_account_new_pin_number
    - second_account_new_pin_number
  - fourth

stages:
  - name: Account management start menu [first account]
    request:
      url: "{server_url}"
      data:
        serviceCode: "*483*46#"
        sessionId: "{first_account_management_session_id}"
        phoneNumber: "{first_account_phone_number}"
        text: ""
      headers:
        content-type: "application/x-www-form-urlencoded"
      method: POST
    response:
      status_code:
        - 200
      headers:
        Content-Type: "text/plain"
      verify_response_with:
        function: ext.validator:validate_response
        extra_kwargs:
          expected_response: "CON Balance 58.00 {token_symbol}\n1. Send\n2. My Account\n3. Help"

  - name: Account management start menu [second account]
    request:
      url: "{server_url}"
      data:
        serviceCode: "*483*46#"
        sessionId: "{second_account_management_session_id}"
        phoneNumber: "{second_account_phone_number}"
        text: ""
      headers:
        content-type: "application/x-www-form-urlencoded"
      method: POST
    response:
      status_code:
        - 200
      headers:
        Content-Length: '56'
        Content-Type: "text/plain"
      verify_response_with:
        function: ext.validator:validate_response
        extra_kwargs:
          expected_response: "CON Salio 42.00 {token_symbol}\n1. Tuma\n2. Akaunti yangu\n3. Usaidizi"

  - name: Account management menu [first account]
    request:
      url: "{server_url}"
      data:
        serviceCode: "*483*46#"
        sessionId: "{first_account_management_session_id}"
        phoneNumber: "{first_account_phone_number}"
        text: "2"
      headers:
        content-type: "application/x-www-form-urlencoded"
      method: POST
    response:
      status_code:
        - 200
      headers:
        Content-Length: '105'
        Content-Type: "text/plain"
      verify_response_with:
        function: ext.validator:validate_response
        extra_kwargs:
          expected_response: "CON My account\n1. My profile\n2. Change language\n3. Check balance\n4. Check statement\n5. Change PIN\n0. Back"

  - name: Account management menu [second account]
    request:
      url: "{server_url}"
      data:
        serviceCode: "*483*46#"
        sessionId: "{second_account_management_session_id}"
        phoneNumber: "{second_account_phone_number}"
        text: "2"
      headers:
        content-type: "application/x-www-form-urlencoded"
      method: POST
    response:
      status_code:
        - 200
      headers:
        Content-Length: '148'
        Content-Type: "text/plain"
      verify_response_with:
        function: ext.validator:validate_response
        extra_kwargs:
          expected_response: "CON Akaunti yangu\n1. Wasifu wangu\n2. Chagua lugha utakayotumia\n3. Angalia salio\n4. Angalia taarifa ya matumizi\n5. Badilisha nambari ya siri\n0. Nyuma"

  - name: Language change [first account]
    request:
      url: "{server_url}"
      data:
        serviceCode: "*483*46#"
        sessionId: "{first_account_management_session_id}"
        phoneNumber: "{first_account_phone_number}"
        text: "2*2"
      headers:
        content-type: "application/x-www-form-urlencoded"
      method: POST
    response:
      status_code:
        - 200
      headers:
        Content-Length: '51'
        Content-Type: "text/plain"
      verify_response_with:
        function: ext.validator:validate_response
        extra_kwargs:
          expected_response: "CON Choose language\n1. English\n2. Kiswahili\n0. Back"

  - name: Language change [second account]
    request:
      url: "{server_url}"
      data:
        serviceCode: "*483*46#"
        sessionId: "{second_account_management_session_id}"
        phoneNumber: "{second_account_phone_number}"
        text: "2*2"
      headers:
        content-type: "application/x-www-form-urlencoded"
      method: POST
    response:
      status_code:
        - 200
      headers:
        Content-Length: '51'
        Content-Type: "text/plain"
      verify_response_with:
        function: ext.validator:validate_response
        extra_kwargs:
          expected_response: "CON Chagua lugha\n1. Kingereza\n2. Kiswahili\n0. Nyuma"

  - name: Select language [first account]
    request:
      url: "{server_url}"
      data:
        serviceCode: "*483*46#"
        sessionId: "{first_account_management_session_id}"
        phoneNumber: "{first_account_phone_number}"
        text: "2*2*2"
      headers:
        content-type: "application/x-www-form-urlencoded"
      method: POST
    response:
      status_code:
        - 200
      headers:
        Content-Length: '36'
        Content-Type: "text/plain"
      verify_response_with:
        function: ext.validator:validate_response
        extra_kwargs:
          expected_response: "END Thank you for using the service."
    delay_after: 5

  - name: Select language [second account]
    request:
      url: "{server_url}"
      data:
        serviceCode: "*483*46#"
        sessionId: "{second_account_management_session_id}"
        phoneNumber: "{second_account_phone_number}"
        text: "2*2*1"
      headers:
        content-type: "application/x-www-form-urlencoded"
      method: POST
    response:
      status_code:
        - 200
      headers:
        Content-Length: '30'
        Content-Type: "text/plain"
      verify_response_with:
        function: ext.validator:validate_response
        extra_kwargs:
          expected_response: "END Asante kwa kutumia huduma."
    delay_after: 5

  - name: Second account management start menu [first account]
    request:
      url: "{server_url}"
      data:
        serviceCode: "*483*46#"
        sessionId: "{first_account_management_session_id_1}"
        phoneNumber: "{first_account_phone_number}"
        text: ""
      headers:
        content-type: "application/x-www-form-urlencoded"
      method: POST
    response:
      status_code:
        - 200
      headers:
        Content-Length: '56'
        Content-Type: "text/plain"
      verify_response_with:
        function: ext.validator:validate_response
        extra_kwargs:
          expected_response: "CON Salio 58.00 {token_symbol}\n1. Tuma\n2. Akaunti yangu\n3. Usaidizi"

  - name: Second account management start menu [second account]
    request:
      url: "{server_url}"
      data:
        serviceCode: "*483*46#"
        sessionId: "{second_account_management_session_id_1}"
        phoneNumber: "{second_account_phone_number}"
        text: ""
      headers:
        content-type: "application/x-www-form-urlencoded"
      method: POST
    response:
      status_code:
        - 200
      headers:
        Content-Length: '51'
        Content-Type: "text/plain"
      verify_response_with:
        function: ext.validator:validate_response
        extra_kwargs:
          expected_response: "CON Balance 42.00 {token_symbol}\n1. Send\n2. My Account\n3. Help"

  - name: Second account management menu [first account]
    request:
      url: "{server_url}"
      data:
        serviceCode: "*483*46#"
        sessionId: "{first_account_management_session_id_1}"
        phoneNumber: "{first_account_phone_number}"
        text: "2"
      headers:
        content-type: "application/x-www-form-urlencoded"
      method: POST
    response:
      status_code:
        - 200
      headers:
        Content-Length: '148'
        Content-Type: "text/plain"
      verify_response_with:
        function: ext.validator:validate_response
        extra_kwargs:
          expected_response: "CON Akaunti yangu\n1. Wasifu wangu\n2. Chagua lugha utakayotumia\n3. Angalia salio\n4. Angalia taarifa ya matumizi\n5. Badilisha nambari ya siri\n0. Nyuma"

  - name: Second account management menu [second account]
    request:
      url: "{server_url}"
      data:
        serviceCode: "*483*46#"
        sessionId: "{second_account_management_session_id_1}"
        phoneNumber: "{second_account_phone_number}"
        text: "2"
      headers:
        content-type: "application/x-www-form-urlencoded"
      method: POST
    response:
      status_code:
        - 200
      headers:
        Content-Length: '105'
        Content-Type: "text/plain"
      verify_response_with:
        function: ext.validator:validate_response
        extra_kwargs:
          expected_response: "CON My account\n1. My profile\n2. Change language\n3. Check balance\n4. Check statement\n5. Change PIN\n0. Back"

  - name: Check balance [first account]
    request:
      url: "{server_url}"
      data:
        serviceCode: "*483*46#"
        sessionId: "{first_account_management_session_id_1}"
        phoneNumber: "{first_account_phone_number}"
        text: "2*3"
      headers:
        content-type: "application/x-www-form-urlencoded"
      method: POST
    response:
      status_code:
        - 200
      headers:
        Content-Length: '49'
        Content-Type: "text/plain"
      verify_response_with:
        function: ext.validator:validate_response
        extra_kwargs:
          expected_response: "CON Tafadhali weka PIN yako kuona salio.\n0. Nyuma"

  - name: Check balance [second account]
    request:
      url: "{server_url}"
      data:
        serviceCode: "*483*46#"
        sessionId: "{second_account_management_session_id_1}"
        phoneNumber: "{second_account_phone_number}"
        text: "2*3"
      headers:
        content-type: "application/x-www-form-urlencoded"
      method: POST
    response:
      status_code:
        - 200
      headers:
        Content-Length: '50'
        Content-Type: "text/plain"
      verify_response_with:
        function: ext.validator:validate_response
        extra_kwargs:
          expected_response: "CON Please enter your PIN to view balances\n0. Back"

  - name: Display balances [first account]
    request:
      url: "{server_url}"
      data:
        serviceCode: "*483*46#"
        sessionId: "{first_account_management_session_id_1}"
        phoneNumber: "{first_account_phone_number}"
        text: "2*3*{first_account_pin_number}"
      headers:
        content-type: "application/x-www-form-urlencoded"
      method: POST
    response:
      status_code:
        - 200
      headers:
        Content-Type: "text/plain"
      verify_response_with:
        function: ext.validator:validate_response
        extra_kwargs:
          expected_response: "CON Salio zako ni zifuatazo:\n  salio: 58.00 {token_symbol}\n  ushuru:  {token_symbol}\n  tuzo:  {token_symbol}\n0. Nyuma"

  - name: Display balances [second account]
    request:
      url: "{server_url}"
      data:
        serviceCode: "*483*46#"
        sessionId: "{second_account_management_session_id_1}"
        phoneNumber: "{second_account_phone_number}"
        text: "2*3*{second_account_pin_number}"
      headers:
        content-type: "application/x-www-form-urlencoded"
      method: POST
    response:
      status_code:
        - 200
      headers:
        Content-Type: "text/plain"
      verify_response_with:
        function: ext.validator:validate_response
        extra_kwargs:
          expected_response: "CON Your balances are as follows:\n  balance: 42.00 {token_symbol}\n  fees:  {token_symbol}\n  rewards:  {token_symbol}\n0. Back"

  - name: Resume account management menu [first account]
    request:
      url: "{server_url}"
      data:
        serviceCode: "*483*46#"
        sessionId: "{first_account_management_session_id_1}"
        phoneNumber: "{first_account_phone_number}"
        text: "2*3*{first_account_pin_number}*0"
      headers:
        content-type: "application/x-www-form-urlencoded"
      method: POST
    response:
      status_code:
        - 200
      headers:
        Content-Length: '148'
        Content-Type: "text/plain"
      verify_response_with:
        function: ext.validator:validate_response
        extra_kwargs:
          expected_response: "CON Akaunti yangu\n1. Wasifu wangu\n2. Chagua lugha utakayotumia\n3. Angalia salio\n4. Angalia taarifa ya matumizi\n5. Badilisha nambari ya siri\n0. Nyuma"

  - name: Resume account management menu [second account]
    request:
      url: "{server_url}"
      data:
        serviceCode: "*483*46#"
        sessionId: "{second_account_management_session_id_1}"
        phoneNumber: "{second_account_phone_number}"
        text: "2*3*{second_account_pin_number}*0"
      headers:
        content-type: "application/x-www-form-urlencoded"
      method: POST
    response:
      status_code:
        - 200
      headers:
        Content-Length: '105'
        Content-Type: "text/plain"
      verify_response_with:
        function: ext.validator:validate_response
        extra_kwargs:
          expected_response: "CON My account\n1. My profile\n2. Change language\n3. Check balance\n4. Check statement\n5. Change PIN\n0. Back"

  - name: Change pin number [first account]
    request:
      url: "{server_url}"
      data:
        serviceCode: "*483*46#"
        sessionId: "{first_account_management_session_id_1}"
        phoneNumber: "{first_account_phone_number}"
        text: "2*3*{first_account_pin_number}*0*5"
      headers:
        content-type: "application/x-www-form-urlencoded"
      method: POST
    response:
      status_code:
        - 200
      headers:
        Content-Length: '34'
        Content-Type: "text/plain"
      verify_response_with:
        function: ext.validator:validate_response
        extra_kwargs:
          expected_response: "CON Weka nambari ya siri.\n0. Nyuma"

  - name: Change pin number [second account]
    request:
      url: "{server_url}"
      data:
        serviceCode: "*483*46#"
        sessionId: "{second_account_management_session_id_1}"
        phoneNumber: "{second_account_phone_number}"
        text: "2*3*{second_account_pin_number}*0*5"
      headers:
        content-type: "application/x-www-form-urlencoded"
      method: POST
    response:
      status_code:
        - 200
      headers:
        Content-Length: '30'
        Content-Type: "text/plain"
      verify_response_with:
        function: ext.validator:validate_response
        extra_kwargs:
          expected_response: "CON Enter current PIN.\n0. Back"

  - name: Enter old pin [first account]
    request:
      url: "{server_url}"
      data:
        serviceCode: "*483*46#"
        sessionId: "{first_account_management_session_id_1}"
        phoneNumber: "{first_account_phone_number}"
        text: "2*3*{first_account_pin_number}*0*5*{first_account_pin_number}"
      headers:
        content-type: "application/x-www-form-urlencoded"
      method: POST
    response:
      status_code:
        - 200
      headers:
        Content-Length: '38'
        Content-Type: "text/plain"
      verify_response_with:
        function: ext.validator:validate_response
        extra_kwargs:
          expected_response: "CON Weka nambari ya siri mpya\n0. Nyuma"

  - name: Enter old pin [second account]
    request:
      url: "{server_url}"
      data:
        serviceCode: "*483*46#"
        sessionId: "{second_account_management_session_id_1}"
        phoneNumber: "{second_account_phone_number}"
        text: "2*3*{second_account_pin_number}*0*5*{second_account_pin_number}"
      headers:
        content-type: "application/x-www-form-urlencoded"
      method: POST
    response:
      status_code:
        - 200
      headers:
        Content-Length: '42'
        Content-Type: "text/plain"
      verify_response_with:
        function: ext.validator:validate_response
        extra_kwargs:
          expected_response: "CON Enter your new four number PIN\n0. Back"

  - name: Enter new pin [first account]
    request:
      url: "{server_url}"
      data:
        serviceCode: "*483*46#"
        sessionId: "{first_account_management_session_id_1}"
        phoneNumber: "{first_account_phone_number}"
        text: "2*3*{first_account_pin_number}*0*5*{first_account_pin_number}*{first_account_new_pin_number}"
      headers:
        content-type: "application/x-www-form-urlencoded"
      method: POST
    response:
      status_code:
        - 200
      headers:
        Content-Length: '43'
        Content-Type: "text/plain"
      verify_response_with:
        function: ext.validator:validate_response
        extra_kwargs:
          expected_response: "CON Weka nambari yako ya siri tena\n0. Nyuma"

  - name: Enter new pin [second account]
    request:
      url: "{server_url}"
      data:
        serviceCode: "*483*46#"
        sessionId: "{second_account_management_session_id_1}"
        phoneNumber: "{second_account_phone_number}"
        text: "2*3*{second_account_pin_number}*0*5*{second_account_pin_number}*{second_account_new_pin_number}"
      headers:
        content-type: "application/x-www-form-urlencoded"
      method: POST
    response:
      status_code:
        - 200
      headers:
        Content-Length: '48'
        Content-Type: "text/plain"
      verify_response_with:
        function: ext.validator:validate_response
        extra_kwargs:
          expected_response: "CON Enter your new four number PIN again\n0. Back"

  - name: Enter new pin confirmation [first account]
    request:
      url: "{server_url}"
      data:
        serviceCode: "*483*46#"
        sessionId: "{first_account_management_session_id_1}"
        phoneNumber: "{first_account_phone_number}"
        text: "2*3*{first_account_pin_number}*0*5*{first_account_pin_number}*{first_account_new_pin_number}*{first_account_new_pin_number}"
      headers:
        content-type: "application/x-www-form-urlencoded"
      method: POST
    response:
      status_code:
        - 200
      headers:
        Content-Length: '91'
        Content-Type: "text/plain"
      verify_response_with:
        function: ext.validator:validate_response
        extra_kwargs:
          expected_response: "CON Ombi lako limetumwa. Utapokea uthibitishaji wa SMS kwa muda mfupi.\n00. Nyuma\n99. Ondoka"

  - name: Enter new pin confirmation [second account]
    request:
      url: "{server_url}"
      data:
        serviceCode: "*483*46#"
        sessionId: "{second_account_management_session_id_1}"
        phoneNumber: "{second_account_phone_number}"
        text: "2*3*{second_account_pin_number}*0*5*{second_account_pin_number}*{second_account_new_pin_number}*{second_account_new_pin_number}"
      headers:
        content-type: "application/x-www-form-urlencoded"
      method: POST
    response:
      status_code:
        - 200
      headers:
        Content-Length: '82'
        Content-Type: "text/plain"
      verify_response_with:
        function: ext.validator:validate_response
        extra_kwargs:
          expected_response: "CON Your request has been sent. You will receive an SMS shortly.\n00. Back\n99. Exit"