<commit_before>Feature: Creating or Editing a child using the API

  Background:
    Given devices exist
      | imei  | blacklisted | user_name|
      | 10001 | false       | tim  |
    Given a registration worker "tim" with a password "<PASSWORD>"
    And I login as tim with password <PASSWORD> and imei 10001

  Scenario: Create Child using API
    When I send a POST request to "/api/children" with JSON:
      """
      {
        "child": {
          "created_at": "2011-03-28 13:23:12UTC",
          "name" : "bob",
          "posted_from" : "Mobile"
        }
      }
      """

    Then the JSON at "name" should be "bob"
    And the JSON at "created_at" should be "2011-03-28 13:23:12UTC"
    And the JSON at "posted_from" should be "Mobile"
    And the JSON at "created_organisation" should be "UNICEF"
    And the JSON at "created_by" should be "tim"
    And the JSON at "created_by_full_name" should be "tim"
    And the JSON at "_id" should be a string
    And the JSON at "_rev" should be a string
    And the JSON at "short_id" should be a string
    And the JSON at "histories" should be an array
    And the JSON at "photo_keys" should be an array
    And the JSON at "current_photo_key" should be a string

  Scenario: Edit Child using API
    Given the following children exist in the system:
      | name | _id | created_at  	    	| posted_at		|
      | Tom  | 1   | 2011-06-22 02:07:51UTC	| 2011-06-22 02:07:51UTC|

    When I send a PUT request to "/api/children/1" with JSON:
      """
      {
        "child" : {
          "name" : "Jorge"
        }
      }
      """
    Then the JSON at "name" should be "Jorge"

    And I send a GET request to "/api/children/1"
    Then the JSON at "name" should be "Jorge"<commit_msg>Jaya|Added api cuke for children list access by unauthorized user<commit_after>Feature: Creating or Editing a child using the API

  Background:
    Given devices exist
      | imei  | blacklisted | user_name|
      | 10001 | false       | tim  |
    Given a registration worker "tim" with a password "<PASSWORD>"
    And I login as tim with password <PASSWORD> and imei 10001

  Scenario: Create Child using API
    When I send a POST request to "/api/children" with JSON:
      """
      {
        "child": {
          "created_at": "2011-03-28 13:23:12UTC",
          "name" : "bob",
          "posted_from" : "Mobile"
        }
      }
      """

    Then the JSON at "name" should be "bob"
    And the JSON at "created_at" should be "2011-03-28 13:23:12UTC"
    And the JSON at "posted_from" should be "Mobile"
    And the JSON at "created_organisation" should be "UNICEF"
    And the JSON at "created_by" should be "tim"
    And the JSON at "created_by_full_name" should be "tim"
    And the JSON at "_id" should be a string
    And the JSON at "_rev" should be a string
    And the JSON at "short_id" should be a string
    And the JSON at "histories" should be an array
    And the JSON at "photo_keys" should be an array
    And the JSON at "current_photo_key" should be a string

  Scenario: Edit Child using API
    Given the following children exist in the system:
      | name | _id | created_at  	    	| posted_at		|
      | Tom  | 1   | 2011-06-22 02:07:51UTC	| 2011-06-22 02:07:51UTC|

    When I send a PUT request to "/api/children/1" with JSON:
      """
      {
        "child" : {
          "name" : "Jorge"
        }
      }
      """
    Then the JSON at "name" should be "Jorge"

    And I send a GET request to "/api/children/1"
    Then the JSON at "name" should be "Jorge"

  Scenario: Edit Child using API

    Given a senior official "richi" with a password "<PASSWORD>"
    And I login as richi with password <PASSWORD> and imei 10001
    And the following children exist in the system:
      | name | _id | created_at  	    	| posted_at		|
      | Raju  | 1   | 2011-06-22 02:07:51UTC	| 2011-06-22 02:07:51UTC|

    When I send a GET request to "/api/children"
    Then I should receive HTTP 403
{'fraction_non_alphanumeric': 0.08784293984394664, 'fraction_numerical': 0.04404731940599044, 'mean_word_length': 2.3338926174496644, 'pattern_counts': {'":': 4, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3220215', 'n_tokens_mistral': 1393, 'n_tokens_neox': 1242, 'n_words': 515}