Skip to content

Commit

Permalink
Add spec to ensure that Client.logout is callable
Browse files Browse the repository at this point in the history
This is to protect against that method being deleted again.
  • Loading branch information
svdasein committed Apr 3, 2021
1 parent e80fe7a commit b8c0adb
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion spec/zabbixapi/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,30 @@
end
end

describe '.logout' do
subject { client_mock.logout() }
before do
allow_any_instance_of(ZabbixApi::Client).to receive(:api_version).and_return('5.2.2')
allow_any_instance_of(ZabbixApi::Client).to receive(:api_request).with(
method: 'user.login',
params: {
user: nil,
password: nil
}
)
allow_any_instance_of(ZabbixApi::Client).to receive(:api_request).with(
method: 'user.logout'
)
end
it 'revokes auth using api request' do
expect_any_instance_of(ZabbixApi::Client).to receive(:api_request).with(
method: 'user.logout',
params: []
)
subject
end
end

describe '.initialize' do
subject { client_mock }

Expand All @@ -92,6 +116,10 @@
password: nil
}
)
allow_any_instance_of(ZabbixApi::Client).to receive(:api_request).with(
method: 'user.logout',
params: {}
)
end

context 'when proxy is provided and no_proxy flag is false' do
Expand Down Expand Up @@ -228,7 +256,7 @@
end
end

context 'when method is not `apiinfo.version` or `user.login`' do
context 'when method is not `apiinfo.version` or `user.login` or `user.logout`' do
let(:method) { 'fakemethod' }
let(:message) do
{
Expand Down

0 comments on commit b8c0adb

Please sign in to comment.