1
0
mirror of https://github.com/cmur2/openvpn-status-web.git synced 2024-12-22 22:54:24 +01:00
openvpn-status-web/spec/parser/v1_spec.rb

64 lines
1.9 KiB
Ruby
Raw Normal View History

2020-03-07 01:30:57 +01:00
# frozen_string_literal: true
require_relative '../spec_helper'
2013-05-03 21:38:10 +02:00
describe OpenVPNStatusWeb::Parser::V1 do
2020-03-02 01:57:58 +01:00
def status
status_v1
end
2013-05-03 21:38:10 +02:00
2013-05-03 22:23:45 +02:00
context 'for client list' do
it 'parses common names' do
2020-03-02 01:57:58 +01:00
expect(status.client_list.map { |client| client[0] }).to eq(%w[foo bar])
2013-05-03 22:23:45 +02:00
end
it 'parses real addresses' do
2020-03-02 01:57:58 +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
2020-03-02 01:57:58 +01:00
expect(status.client_list.map { |client| client[2] }).to eq([11_811_160_064, 512])
2013-05-03 22:23:45 +02:00
end
it 'parses sent bytes' do
2020-03-02 01:57:58 +01:00
expect(status.client_list.map { |client| client[3] }).to eq([4_194_304, 2048])
2013-05-03 22:23:45 +02:00
end
it 'parses connected since date' do
2020-03-02 01:57:58 +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
2020-03-02 01:57:58 +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
2020-03-02 01:57:58 +01:00
expect(status.routing_table.map { |route| route[1] }).to eq(%w[foo bar foo bar])
2013-05-03 22:23:45 +02:00
end
it 'parses real addresses' do
2020-03-02 01:57:58 +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
2020-03-02 01:57:58 +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)
2020-03-02 01:57:58 +01:00
expect(status.global_stats.first).to eq(['Max bcast/mcast queue length', 42])
2013-05-03 21:38:10 +02:00
end
end