#!/usr/bin/partner2-test -w
{
   "name" : "Редактирование существующего правила",
   "options" : {
      "mock_bk" : true,
      "read_only" : false
   },
   "testcases" : "",
   "tests" : [
      {
         "request" : {
            "body" : {
               "data" : {
                  "attributes" : {
                     "conditions" : {
                        "query_args" : {
                           "adb_enabled" : [
                              1
                           ]
                        }
                     }
                  },
                  "id" : "21",
                  "type" : "business_rules"
               }
            },
            "method" : "patch",
            "name" : "Редактируем 'query_args.adb_enabled' под $TOKEN - то чего нельзя под обычным партнером",
            "token" : "mocked-context-adblock-partner",
            "url" : "/v1/business_rules/21"
         },
         "response" : {
            "body" : {
               "data" : {
                  "attributes" : {
                     "conditions" : {
                        "query_args" : {
                           "adb_enabled" : [
                              "1"
                           ]
                        }
                     }
                  },
                  "id" : "21",
                  "relationships" : {},
                  "type" : "business_rules"
               },
               "links" : {
                  "self" : "https://127.0.0.1:80/v1/business_rules/21"
               },
               "meta" : {
                  "fields" : [
                     "conditions"
                  ]
               }
            },
            "content_type" : "application/vnd.api+json",
            "status" : "200"
         }
      },
      {
         "request" : {
            "body" : {
               "data" : {
                  "attributes" : {
                     "conditions" : {
                        "headers" : {
                           "content-type" : [
                              "text/plain"
                           ]
                        },
                        "query_args" : {
                           "adb_enabled" : [
                              1
                           ]
                        }
                     }
                  },
                  "id" : "21",
                  "type" : "business_rules"
               }
            },
            "method" : "patch",
            "name" : "Пытамся редактировать 'headers' под $TOKEN - пока что это всем запрещено",
            "token" : "mocked-context-adblock-partner",
            "url" : "/v1/business_rules/21"
         },
         "response" : {
            "body" : {
               "errors" : [
                  {
                     "detail" : "Access denied",
                     "id" : "4",
                     "source" : {
                        "pointer" : "/data/attributes/conditions/headers"
                     },
                     "title" : "Validation error"
                  }
               ]
            },
            "content_type" : "application/vnd.api+json",
            "status" : "400"
         }
      },
      {
         "request" : {
            "body" : {
               "data" : {
                  "attributes" : {
                     "conditions" : {
                        "query_args" : {
                           "adb_enabled" : [
                              1,
                              null
                           ]
                        }
                     }
                  },
                  "id" : "21",
                  "type" : "business_rules"
               }
            },
            "method" : "patch",
            "name" : "Пытаемся при слать в 'adb_enabled' более одного элемента под $TOKEN",
            "token" : "mocked-context-adblock-partner",
            "url" : "/v1/business_rules/21"
         },
         "response" : {
            "body" : {
               "errors" : [
                  {
                     "detail" : "\"adb_enabled\" is not an array of only one value: [\"1\", \"null\"]",
                     "id" : "4",
                     "source" : {
                        "pointer" : "/data/attributes/conditions/query_args"
                     },
                     "title" : "Validation error"
                  }
               ]
            },
            "content_type" : "application/vnd.api+json",
            "status" : "400"
         }
      },
      {
         "request" : {
            "body" : {
               "data" : {
                  "attributes" : {
                     "conditions" : {
                        "query_args" : {
                           "adb_enabled" : [
                              null
                           ]
                        }
                     }
                  },
                  "id" : "21",
                  "type" : "business_rules"
               }
            },
            "method" : "patch",
            "name" : "Пытаемся при слать в 'adb_enabled' что-то отличное от [1] под $TOKEN",
            "token" : "mocked-context-adblock-partner",
            "url" : "/v1/business_rules/21"
         },
         "response" : {
            "body" : {
               "errors" : [
                  {
                     "detail" : "\"adb_enabled\" can not be set to a value over [\"1\"]: [\"null\"]",
                     "id" : "4",
                     "source" : {
                        "pointer" : "/data/attributes/conditions/query_args"
                     },
                     "title" : "Validation error"
                  }
               ]
            },
            "content_type" : "application/vnd.api+json",
            "status" : "400"
         }
      }
   ]
}
