aboutsummaryrefslogtreecommitdiffstats
path: root/web/nms-public.gathering.org/old/index.html
blob: 8043c7d0f1deb17ffa1dadbc3dc5073ef18aa32e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<html>
  <head>
    <title>snmp</title>
  </head>
  <body>
    <p>tg light &amp; magic. :-)</p>

    <ul>
      <li><a href="nms2/">NMS 2 NG (Ping, Temp, Uplink, Trafikk, Info)</a>
    	<br /><i>Trykk på svitsjene (Work in progress)</i>
	</li>
	<br />
      <li><a href="dhcpkart.pl">DHCP-kart</a>
        <br /><i>Oversikt over DHCP-lease etter switch</i>
      </li>

      <br />

      <li><a href="nettkart-text.pl">Nettkart</a>
        <br /><i>Trafikkoversikt</i>
      </li>

      <br />
<!--

      <li><a href="nettkart-telnet.pl">Nettkart</a>
        <br /><i>Trafikkoversikt /m telnetlink</i>
      </li>

      <br />
-->
<!--  Kun moderat nyttig når vi har disablet alle webinterfacene...
      <li><a href="nettkart-web.pl">Nettkart</a>
        <br /><i>Trafikkoversikt /m weblink</i>
      </li>

      <br />
-->
      <li><a href="portkart.pl">Nettkart, per port</a>
        <br /><i>Trafikkoversikt per port</i>
      </li>

      <br />
      
      <li><a href="uplinkkart.pl">Uplink-kart</a>
        <br /><i>Hvilke switcher har ikke to uplinker</i>
      </li>

      <br />
<!--
      <li><a href="uplinktrafikkart.pl">Uplink-trafikkart</a>
        <br /><i>Hvem burde hatt mer enn to uplinker</i>
      </li>

      <br />
-->
      <li><a href="stromkart.pl">Strømkart</a>
        <br /><i>Hvilke switcher har færre enn fem tilkoblede klienter</i>
      </li>

      <br />
<!--
      <li><a href="apkart.pl">Aksesspunkt-kart</a>
        <br /><i>Hvilke aksesspunkter er plugget i</i>
      </li>

      <br />
-->
      <!--<li><a href="overlay.pl">Overlay-nettkart</a>
        <br /><i>Teh magic 3D!</i>
      </li> 

      <br /> -->

      <li><a href="smanagement.pl">Kommander switcher</a>
        <br /><i>Konfigurer switchene</i>
      </li>

      <br />

      <li><a href="sshow.pl">Utførte og køede kommandoer</a>
        <br /><i>Se og håndter kommandoer som er utført og fortsatt i køen</i>
      </li>

      <br />

      <li><a href="stempmap.pl">Temperaturkart</a>
        <br /><i>Temperaturkart for switchene</i>
      </li>
<!--
      <br />
      <li><a href="mbd-status.pl">MBD-status</a>
        <br /><i>Hva spiller folk mest?</i>
      </li>
-->
      <br />

      <li><a href="ping.html">Ping-kart</a>
        <br /><i>Pinger alle bokser hvert sekund</i>
      </li>

      <br />

      <li><a href="ping2.html">Realtime trafikkart</a>
        <br /><i>Som nettkartet, men oppdateres hele tiden</i>
      </li>

      <br />

      <li><a href="edit.html">Rediger kartet</a>
        <br /><i>Dra rundt på switcher. Wheeee!</i>
      </li>
    </ul>
  </body>
</html>
background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
# == Schema Information
#
# Table name: censor_rules
#
#  id                :integer          not null, primary key
#  info_request_id   :integer
#  user_id           :integer
#  public_body_id    :integer
#  text              :text             not null
#  replacement       :text             not null
#  last_edit_editor  :string(255)      not null
#  last_edit_comment :text             not null
#  created_at        :datetime         not null
#  updated_at        :datetime         not null
#  regexp            :boolean
#

require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')

describe CensorRule, "substituting things" do

    describe 'when using a text rule' do

        before do
            @censor_rule = CensorRule.new
            @censor_rule.text = "goodbye"
            @censor_rule.replacement = "hello"
        end

        it 'should do basic text substitution' do
            body = "I don't know why you say goodbye"
            @censor_rule.apply_to_text!(body)
            body.should == "I don't know why you say hello"
        end

        it 'should keep size same for binary substitution' do
            body = "I don't know why you say goodbye"
            orig_body = body.dup
            @censor_rule.apply_to_binary!(body)
            body.size.should == orig_body.size
            body.should == "I don't know why you say xxxxxxx"
            body.should_not == orig_body # be sure duplicated as expected
        end

    end

    describe "when using a regular expression rule" do

        before do
            @censor_rule = CensorRule.new(:last_edit_editor => 1,
                                          :last_edit_comment => 'comment')
            @censor_rule.text = "--PRIVATE.*--PRIVATE"
            @censor_rule.replacement = "--REMOVED\nHidden private info\n--REMOVED"
            @censor_rule.regexp = true
            @body =
<<BODY
Some public information
--PRIVATE
Some private information
--PRIVATE
BODY
        end

        it "replaces the regexp with the replacement text when applied to text" do
            @censor_rule.apply_to_text!(@body)
            @body.should ==
<<BODY
Some public information
--REMOVED
Hidden private info
--REMOVED
BODY
        end

        it "replaces the regexp with the same number of 'x' characters as the text replaced
            when applied to binary" do
            @censor_rule.apply_to_binary!(@body)
            @body.should ==
<<BODY
Some public information
xxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxx
BODY
        end

    end

end

describe 'when validating rules' do

    it 'should be invalid without text' do
        censor_rule = CensorRule.new
        censor_rule.valid?.should == false
        censor_rule.errors[:text].should == ["can't be blank"]
    end

    describe 'when validating a regexp rule' do

        before do
            @censor_rule = CensorRule.new(:regexp => true,
                                          :text => '*')
        end

        it 'should try to create a regexp from the text' do
            Regexp.should_receive(:new).with('*', Regexp::MULTILINE)
            @censor_rule.valid?
        end

        describe 'if a regexp error is produced' do

            it 'should add an error message to the text field with the regexp error message' do
                Regexp.stub!(:new).and_raise(RegexpError.new("very bad regexp"))
                @censor_rule.valid?.should == false
                @censor_rule.errors[:text].should == ["very bad regexp"]
            end

        end

        describe 'if no regexp error is produced' do

            it 'should not add any error message to the text field' do
                Regexp.stub!(:new)
                @censor_rule.valid?
                @censor_rule.errors[:text].should == []
            end

        end

    end

    describe 'when the allow_global flag has been set' do

        before do
            @censor_rule = CensorRule.new(:text => 'some text')
            @censor_rule.allow_global = true
        end

        it 'should allow a global censor rule (without user_id, request_id or public_body_id)' do
            @censor_rule.valid?.should == true
        end

    end

    describe 'when the allow_global flag has not been set' do

        before do
            @censor_rule = CensorRule.new(:text => '/./')
        end

        it 'should not allow a global text censor rule (without user_id, request_id or public_body_id)' do
            @censor_rule.valid?.should == false

            expected_error = ["Rule must apply to an info request, a user or a body"]
            @censor_rule.errors[:user].should == expected_error
            @censor_rule.errors[:info_request].should == expected_error
            @censor_rule.errors[:public_body].should == expected_error
        end

        it 'should not allow a global regex censor rule (without user_id, request_id or public_body_id)' do
            @censor_rule.regexp = true
            @censor_rule.valid?.should == false

            expected_error = ["Rule must apply to an info request, a user or a body"]
            @censor_rule.errors[:user].should == expected_error
            @censor_rule.errors[:info_request].should == expected_error
            @censor_rule.errors[:public_body].should == expected_error
        end

    end

end

describe 'when handling global rules' do

    describe 'an instance without user_id, request_id or public_body_id' do

        before do
            @global_rule = CensorRule.new
        end

        it 'should return a value of true from is_global?' do
           @global_rule.is_global?.should == true
        end

    end

    describe 'the scope CensorRule.global.all' do

        before do
            @global_rule = CensorRule.create!(:allow_global => true,
                                              :text => 'hide me',
                                              :replacement => 'nothing to see here',
                                              :last_edit_editor => 1,
                                              :last_edit_comment => 'comment')
            @user_rule = CensorRule.create!(:user_id => 1,
                                            :text => 'hide me',
                                            :replacement => 'nothing to see here',
                                            :last_edit_editor => 1,
                                            :last_edit_comment => 'comment')
        end

        it 'should include an instance without user_id, request_id or public_body_id' do
            CensorRule.global.all.include?(@global_rule).should == true
        end

        it 'should not include a request with user_id' do
            CensorRule.global.all.include?(@user_rule).should == false
        end

        after do
            @global_rule.destroy if @global_rule
            @user_rule.destroy if @user_rule
        end
    end

end