1
0
mirror of https://github.com/cmur2/openvpn-status-web.git synced 2024-11-05 04:56:17 +01:00
openvpn-status-web/spec/parser/v1_spec.rb

51 lines
1.7 KiB
Ruby
Raw Normal View History

2013-05-03 21:38:10 +02:00
require 'spec_helper'
describe OpenVPNStatusWeb::Parser::V1 do
def status; status_v1; end
2013-05-03 22:23:45 +02:00
context 'for client list' do
it 'parses common names' do
2018-11-02 10:12:54 +01:00
expect(status.client_list.map { |client| client[0] }).to eq(["foo", "bar"])
2013-05-03 22:23:45 +02:00
end
it 'parses real addresses' do
2018-11-02 10:12:54 +01:00
expect(status.client_list.map { |client| client[1] }).to eq(["1.2.3.4:1234", "1.2.3.5:1235"])
2013-05-03 22:23:45 +02:00
end
2018-11-02 10:12:54 +01:00
2013-05-03 22:23:45 +02:00
it 'parses received bytes' do
2018-11-02 10:12:54 +01:00
expect(status.client_list.map { |client| client[2] }).to eq([11811160064, 512])
2013-05-03 22:23:45 +02:00
end
it 'parses sent bytes' do
2018-11-02 10:12:54 +01:00
expect(status.client_list.map { |client| client[3] }).to eq([4194304, 2048])
2013-05-03 22:23:45 +02:00
end
it 'parses connected since date' do
2018-11-02 10:12:54 +01:00
expect(status.client_list.map { |client| client[4] }).to eq([DateTime.new(2012,1,1,23,42,0), DateTime.new(2012,1,1,23,42,0)])
2013-05-03 22:23:45 +02:00
end
2013-05-03 21:38:10 +02:00
end
2013-05-03 22:23:45 +02:00
context 'for routing table' do
it 'parses virtual addresses' do
2018-11-02 10:12:54 +01:00
expect(status.routing_table.map { |route| route[0] }).to eq(["192.168.0.0/24", "192.168.66.2", "192.168.66.3", "2001:db8:0:0::1000"])
2013-05-03 22:23:45 +02:00
end
it 'parses common names' do
2018-11-02 10:12:54 +01:00
expect(status.routing_table.map { |route| route[1] }).to eq(["foo", "bar", "foo", "bar"])
2013-05-03 22:23:45 +02:00
end
it 'parses real addresses' do
2018-11-02 10:12:54 +01:00
expect(status.routing_table.map { |route| route[2] }).to eq(["1.2.3.4:1234", "1.2.3.5:1235", "1.2.3.4:1234", "1.2.3.5:1235"])
2013-05-03 22:23:45 +02:00
end
it 'parses last ref date' do
2018-11-02 10:12:54 +01:00
expect(status.routing_table.map { |route| route[3] }).to eq([DateTime.new(2012,1,1,23,42,0), DateTime.new(2012,1,1,23,42,0), DateTime.new(2012,1,1,23,42,0), DateTime.new(2012,1,1,23,42,0)])
2013-05-03 22:23:45 +02:00
end
2013-05-03 21:38:10 +02:00
end
it 'parses global stats' do
2018-11-02 10:12:54 +01:00
expect(status.global_stats.size).to eq(1)
expect(status.global_stats.first).to eq(["Max bcast/mcast queue length", 42])
2013-05-03 21:38:10 +02:00
end
end