This file is indexed.

/usr/share/pcsd/test/test_pcs.rb is in pcs 0.9.149-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
require 'test/unit'
require 'fileutils'
require 'json'
require 'rexml/document'

require 'pcs.rb'

class TestGetNodesAttributes < Test::Unit::TestCase
  def test_empty
    cib = '
<cib>
  <configuration>
    <nodes>
      <node uname="node1">
        <instance_attributes/>
      </node>
      <node uname="node2"/>
      <node uname="node3">
        <instance_attributes/>
      </node>
    </nodes>
  </configuration>
</cib>'
    cib_dom = REXML::Document.new(cib)
    assert_equal({}, get_node_attributes(nil, cib_dom))
  end

  def test_bad_path
    cib = '
<cib>
  <configuration>
    <nodes>
      <node uname="node1">
        <instance_attributes/>
        <nvpair name="test1" value="test2"/>
      </node>
      <node uname="node2"/>
      <node uname="node3">
        <instance_attributes/>
      </node>
    </nodes>
  </configuration>
  <nvpair name="test" value="testval"/>
</cib>
'
    cib_dom = REXML::Document.new(cib)
    assert_equal({}, get_node_attributes(nil, cib_dom))
  end

  def test_attributes
    cib = '
<cib>
  <configuration>
    <nodes>
      <node id="1" uname="node1">
        <instance_attributes id="nodes-1"/>
      </node>
      <node id="2" uname="node2">
        <instance_attributes id="nodes-2">
          <nvpair id="nodes-2-test" name="test" value="44"/>
        </instance_attributes>
      </node>
      <node id="3" uname="node3">
        <instance_attributes id="nodes-3">
          <nvpair id="nodes-3-test" name="test" value="testval2"/>
          <nvpair id="nodes-3-test2" name="test2" value="1"/>
          <nvpair id="nodes-3-test321" name="test321" value="321"/>
        </instance_attributes>
      </node>
    </nodes>
  </configuration>
</cib>
'
    cib_dom = REXML::Document.new(cib)
    expected = {}
    expected['node2'] = JSON.parse(
      '[
        {
          "id": "nodes-2-test",
          "key": "test",
          "value": "44"
        }
      ]', {:symbolize_names => true})
    expected['node3'] = JSON.parse(
      '[
        {
          "id": "nodes-3-test",
          "key": "test",
          "value": "testval2"
        },
        {
          "id": "nodes-3-test2",
          "key": "test2",
          "value": "1"
        },
        {
          "id": "nodes-3-test321",
          "key": "test321",
          "value": "321"
        }
      ]', {:symbolize_names => true})
    assert_equal(expected, get_node_attributes(nil, cib_dom))
  end
end

class TestGetFenceLevels < Test::Unit::TestCase
  def test_empty
    cib = '
<cib>
  <configuration>
    <fencing-topology/>
  </configuration>
</cib>'
    cib_dom = REXML::Document.new(cib)
    assert_equal({}, get_fence_levels(nil, cib_dom))
  end

  def test_bad_path
    cib = '
<cib>
  <configuration>
    <fencing-topology/>
    <fencing-level devices="node2-stonith" id="fl-node3-33" index="33" target="node3"/>
  </configuration>
  <fencing-level devices="node1-stonith" id="fl-node1-1" index="1" target="node1"/>
</cib>'
    cib_dom = REXML::Document.new(cib)
    assert_equal({}, get_fence_levels(nil, cib_dom))
  end

  def test_levels
    cib = '
<cib>
  <configuration>
    <fencing-topology>
      <fencing-level devices="node1-stonith" id="fl-node1-1" index="1" target="node1"/>
      <fencing-level devices="node2-stonith" id="fl-node1-2" index="2" target="node1"/>
      <fencing-level devices="node1-stonith" id="fl-node3-121" index="121" target="node3"/>
      <fencing-level devices="node3-stonith" id="fl-node3-312" index="312" target="node3"/>
      <fencing-level devices="node2-stonith" id="fl-node3-33" index="33" target="node3"/>
    </fencing-topology>
  </configuration>
</cib>'
    cib_dom = REXML::Document.new(cib)
    expected_json = '
{
  "node1": [
    {
      "level": "1",
      "devices": "node1-stonith"
    },
    {
      "level": "2",
      "devices": "node2-stonith"
    }
  ],
  "node3": [
    {
      "level": "33",
      "devices": "node2-stonith"
    },
    {
      "level": "121",
      "devices": "node1-stonith"
    },
    {
      "level": "312",
      "devices": "node3-stonith"
    }
  ]
}
'
    assert_equal(JSON.parse(expected_json), get_fence_levels(nil, cib_dom))
  end
end

class TestGetAcls < Test::Unit::TestCase
  def test_empty
    cib = '
<cib>
  <configuration>
    <acls/>
  </configuration>
</cib>'
    cib_dom = REXML::Document.new(cib)
    expected = {"group"=>{}, "role"=>{}, "target"=>{}, "user"=>{}}
    assert_equal(expected, get_acls(nil, cib_dom))
  end

  def test_bad_path
    cib = '
<cib>
  <configuration>
    <acls/>
    <acl_role id="test">
      <acl_permission id="test1" kind="read" reference="test-ref"/>
    </acl_role>
    <acl_target id="target_id">
      <role id="test"/>
    </acl_target>
  </configuration>
</cib>'
    cib_dom = REXML::Document.new(cib)
    expected = {"group"=>{}, "role"=>{}, "target"=>{}, "user"=>{}}
    assert_equal(expected, get_acls(nil, cib_dom))
  end

  def test_acls
    cib = '
<cib>
  <configuration>
    <acls>
      <acl_role description="testing" id="test">
        <acl_permission id="test-read" kind="read" xpath="/*"/>
        <acl_permission id="test-write" kind="write" reference="test-read"/>
      </acl_role>
      <acl_target id="test2">
        <role id="test"/>
      </acl_target>
      <acl_group id="testgroup">
        <role id="test"/>
      </acl_group>
    </acls>
  </configuration>
</cib>'
    cib_dom = REXML::Document.new(cib)
    expected_json = '
{
  "role": {
    "test": {
      "description": "testing",
      "permissions": [
        "read xpath /* (test-read)",
        "write id test-read (test-write)"
      ]
    }
  },
  "group": {
    "testgroup": [
      "test"
    ]
  },
  "user": {
    "test2": [
      "test"
    ]
  },
  "target": {
    "test2": [
      "test"
    ]
  }
}
    '
    assert_equal(JSON.parse(expected_json), get_acls(nil, cib_dom))
  end
end