Sha256: 8a5315abf95d3121f54b84379b9869b38f4c02e923e12449aed0c46d6ae5208e

Contents?: true

Size: 1.73 KB

Versions: 1

Compression:

Stored size: 1.73 KB

Contents

require 'spec_helper'

describe OpenVPNStatusWeb::Parser::V1 do
  def status; status_v1; end

  context 'for client list' do
    it 'parses common names' do
      expect(status.client_list.map { |client| client[0] }).to eq(["foo", "bar"])
    end

    it 'parses real addresses' do
      expect(status.client_list.map { |client| client[1] }).to eq(["1.2.3.4:1234", "1.2.3.5:1235"])
    end

    it 'parses received bytes' do
      expect(status.client_list.map { |client| client[2] }).to eq([11811160064, 512])
    end

    it 'parses sent bytes' do
      expect(status.client_list.map { |client| client[3] }).to eq([4194304, 2048])
    end

    it 'parses connected since date' do
      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)])
    end
  end

  context 'for routing table' do
    it 'parses virtual addresses' do
      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"])
    end

    it 'parses common names' do
      expect(status.routing_table.map { |route| route[1] }).to eq(["foo", "bar", "foo", "bar"])
    end

    it 'parses real addresses' do
      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"])
    end

    it 'parses last ref date' do
      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)])
    end
  end

  it 'parses global stats' do
    expect(status.global_stats.size).to eq(1)
    expect(status.global_stats.first).to eq(["Max bcast/mcast queue length", 42])
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
openvpn-status-web-2.0.0 spec/parser/v1_spec.rb