如何在空手道中设置大Cookie标头

时间:2019-06-27 13:38:29

标签: cookies karate

作为我们自动化的一部分,我们需要将非常大的Cookie标头发送到api。

cookie如下 Cookie:_ga = GA1.2.1041556506.1557744563; _gcl_au = 1.1.139136457.1560512273; JabmoSP0id.ffef = d37c42bf-f223-43c6-a73c-fa502e23712d.1560512274.5.1561197329.1560589232.2561e1f4-79fe-4b63-88c6-157c6e8ed125; _gid = GA1.2.1289186220.1561356841; intercom-session-pk0ds0sg = TlZDS2xJQ3BjdldKQ3QzVkt2U1VkUUJ0WmhsVDBpaTY0YThBR0M0Y0dFMWs1azkwUlBlTWpUbWp1ZHN6MUtydS0tZm5CSlZY21a24k16a1k1k1k2k19k1k6k1k6k1k7k7k1k7k1k7k1k7k1k7k1k7k1k7k1k7k1k7k1k7k1k9k1k7k1k6a路线= lj-01;登录=; lang = en; _ga = GA1.4.1041556506.1557744563; _gid = GA1.4.1289186220.1561356841; _pendo_accountId.029f7ddf-6593-4d82-5a65-a6c66fbf2b5c = AnupamaSoftwareAG; _pendo_visitorId.029f7ddf-6593-4d82-5a65-a6c66fbf2b5c = fldf7517754d071b07cb0e77; _pendo_meta.029f7ddf-6593-4d82-5a65-a6c66fbf2b5c = 1358353967; userId = -2; JSESSIONID = CFDB00B95AF1C731356A04B01FF369E3; mp_62107c6714e5356c33d43ef8d8f43cee_mixpanel =%7B%22distinct_id%22%3A%20%22fldf7517754d071b07cb0e77%22%2C%22%24device_id%22%3A%20%2216ab0cfc07a1b8%c%22cf3c3a3c3c3c3c3f3c3c3c3e0c6e0f0e0c3e0e0e0e0e0e0e0e0e0e0%人%20%22%24direct%22%2C%22%24initial_referring_domain%22%3A%20%22%24direct%22%2C%22%24user_id%22%3A%20%22fldf7517754d071b07cb0e77%22%7D; intercom-session-no8pg948 = emh3RjRGVzVmczQrTFdUaUZwWWliRTRBaDNlOEtmQ1VHcjh0NWl5eTZPNXVSdHdMU2VjMW9rRmt3WWZ0Q200Mi0tRitFT0Y1dkp6S2cvdkQ6f24f9b24f9b2f9b2f9b2f9b2f9b2f9b2f9b3e9f9b3c0f0b0f0b0f0b0e0b0f0b人_gat_UA-60405455-1 = 1

如果我分离了cookie(就像我只发送jssionid一样,它就可以工作) 但需要发送完整的cookie

需要系统税发送此Cookie

1 个答案:

答案 0 :(得分:1)

您通常不需要设置cookie,因为空手道将在下一个请求中自动发送服务器返回的所有cookie。阅读文档:https://github.com/intuit/karate#configure-您可以在空手道中以“正确的方式”设置多个cookie,例如:https://github.com/intuit/karate#cookie

您在问题中张贴的内容似乎是由多个Cookie组成的整个标题。对于要测试的服务器,很可能只需要其中一个或两个即可。我建议您向拥有该服务的团队咨询。

如果您知道自己在做什么,则可以像这样手动设置整个cookie标头-但由于上述原因而不建议使用-因为您将需要处理/编码特殊字符等-这很可能是您运行问题。

* header Cookie = '_ga=GA1.2.1041556506.1557744563; _gcl_au=1.1.139136457.1560512273; JabmoSP0id.ffef=d37c42bf-f223-43c6-a73c-fa502e23712d.1560512274.5.1561197329.1560589232.2561e1f4-79fe-4b63-88c6-157c6e8ed125; _gid=GA1.2.1289186220.1561356841;'

请注意,可以从这样的文本文件中读取上方的右侧:

* header Cookie = read('huge-string.txt')