我有这个curl命令发送带身份验证的api请求。我正在使用空中编写测试,我需要在测试中发送api请求。卷曲命令
curl https://example.com/api/v2/tests.json \
-v -u [email protected]:Abcd1234
我有如下测试,但我需要添加身份验证。我该怎么做?
describe 'Test to GET' do
it 'should get the existing data'do
get "https://example.com/api/v2/tests.json","[email protected]":"Abcd1234"
expect_status(200)
end
end
-u
选项向客户端发送基本身份验证头。
Airborne的README
顶部显示了如何发送auth标头:
describe 'Test to GET' do
it 'should get the existing data' do
get "https://example.com/api/v2/tests.json",
{ 'x-auth-token' => 'my_token' }
expect_status(200)
end
end
如何从user
获取令牌:password
对我将作为家庭作业离开(例如,你可能只是记录curl
请求。)
您也可以通过Airborne config全局设置auth标头。