1 AT_BANNER([OVSDB -- ovsdb-server rbac])
3 AT_SETUP([ovsdb-server/rbac 2])
4 AT_KEYWORDS([ovsdb server rbac])
5 AT_SKIP_IF([test "$HAVE_OPENSSL" = no])
8 RBAC_PKI="sh $abs_top_srcdir/utilities/ovs-pki.in --dir=$RBAC_PKIDIR/pki --log=$RBAC_PKIDIR/rbac-pki.log"
10 $RBAC_PKI -B 1024 req+sign ovsdb-server switch
11 $RBAC_PKI -B 1024 -u req+sign client-1 switch
12 $RBAC_PKI -B 1024 -u req+sign client-2 switch
21 "key": {"type": "uuid", "refTable": "Connection"},
23 "max": "unlimited"}}},
33 "name": {"type": "string"},
35 "type": {"key": {"type": "string"},
36 "value": {"type": "uuid",
37 "refTable": "RBAC_Permission",
39 "min": 0, "max": "unlimited"}}},
43 "table": {"type": "string"},
44 "authorization": {"type": {"key": "string",
47 "insert_delete": {"type": "boolean"},
48 "update" : {"type": {"key": "string",
50 "max": "unlimited"}}},
54 "name": {"type": "string"}, "value": {"type": "integer"}},
55 "indexes": [["name"]],
59 "creator": {"type": "string"},
60 "name": {"type": "string"},
61 "value": {"type": "integer"}},
62 "indexes": [["name"]],
67 "type": {"key": {"type": "string"},
68 "value": {"type": "string"},
69 "min": 0, "max": "unlimited"}},
70 "name": {"type": "string"},
71 "value": {"type": "integer"}},
72 "indexes": [["name"]],
80 AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore])
82 [[ovsdb-tool transact db \
87 "connections": ["set", [["named-uuid", "x"]]]}},
89 "table": "Connection",
91 "row": {"target": "pssl:0:127.0.0.1",
94 "table": "fixed_colors",
95 "row": {"name": "red",
96 "value": '16711680'}},
99 "row": {"name": "testrole",
100 "permissions": ["map", [["user_colors", ["named-uuid", "y"]],
101 ["other_colors", ["named-uuid", "z"]]]]}},
103 "table": "RBAC_Permission",
105 "row": {"authorization": "creator",
106 "insert_delete": true,
107 "table": "user_colors",
108 "update": ["set", ["name", "value"]]}},
110 "table": "RBAC_Permission",
112 "row": {"authorization": "creator:chassis",
113 "insert_delete": true,
114 "table": "user_colors",
115 "update": ["set", ["name", "value"]]}}
116 ]']], [0], [ignore], [ignore])
118 AT_CHECK([ovsdb-server --log-file --detach --no-chdir --pidfile --remote=db:mydb,Root,connections \
119 --private-key=$RBAC_PKIDIR/ovsdb-server-privkey.pem \
120 --certificate=$RBAC_PKIDIR/ovsdb-server-cert.pem \
121 --ca-cert=$RBAC_PKIDIR/pki/switchca/cacert.pem \
122 db], [0], [ignore], [ignore])
123 PARSE_LISTENING_PORT([ovsdb-server.log], [SSL_PORT])
126 # Attempt to insert a row into the "fixed_colors" table. This should
127 # fail as there are no permissions for role "testrole" for this table.
128 AT_CHECK([ovsdb-client transact ssl:127.0.0.1:$SSL_PORT \
129 --private-key=$RBAC_PKIDIR/client-1-privkey.pem \
130 --certificate=$RBAC_PKIDIR/client-1-cert.pem \
131 --ca-cert=$RBAC_PKIDIR/pki/switchca/cacert.pem \
134 "table": "fixed_colors",
135 "row": {"name": "chartreuse", "value": '8388352'}}
136 ]']], [0], [stdout], [ignore])
138 AT_CHECK([${PERL} $srcdir/uuidfilt.pl stdout], [0], [[[{"details":"RBAC rules for client \"client-1\" role \"testrole\" prohibit row insertion into table \"fixed_colors\".","error":"permission error"}]]
142 # Attempt to insert a row into the "user_colors" table with a client ID that
143 # does not match the value in the column used for authorization. This should
144 # fail the authorization check for insertion.
145 AT_CHECK([ovsdb-client transact ssl:127.0.0.1:$SSL_PORT \
146 --private-key=$RBAC_PKIDIR/client-1-privkey.pem \
147 --certificate=$RBAC_PKIDIR/client-1-cert.pem \
148 --ca-cert=$RBAC_PKIDIR/pki/switchca/cacert.pem \
151 "table": "user_colors",
152 "row": {"creator": "client-2", "name": "chartreuse", "value": '8388352'}}
153 ]']], [0], [stdout], [ignore])
155 AT_CHECK([${PERL} $srcdir/uuidfilt.pl stdout], [0], [[[{"details":"RBAC rules for client \"client-1\" role \"testrole\" prohibit row insertion into table \"user_colors\".","error":"permission error"}]]
159 # Attempt to insert a row into the "user_colors" table. This should
160 # succeed since role "testrole" has permissions for this table that
161 # allow row insertion.
162 AT_CHECK([ovsdb-client transact ssl:127.0.0.1:$SSL_PORT \
163 --private-key=$RBAC_PKIDIR/client-1-privkey.pem \
164 --certificate=$RBAC_PKIDIR/client-1-cert.pem \
165 --ca-cert=$RBAC_PKIDIR/pki/switchca/cacert.pem \
168 "table": "user_colors",
169 "row": {"creator": "client-1", "name": "chartreuse", "value": '8388352'}}
170 ]']], [0], [stdout], [ignore])
172 AT_CHECK([${PERL} $srcdir/uuidfilt.pl stdout], [0], [[[{"uuid":["uuid","<0>"]}]]
176 # Attempt to update a column in the "user_colors" table. This should
177 # succeed since role "testrole" has permissions for this table that
178 # allow update of the "value" column when ID is equal to the value in
179 # the "creator" column.
180 AT_CHECK([ovsdb-client transact ssl:127.0.0.1:$SSL_PORT \
181 --private-key=$RBAC_PKIDIR/client-1-privkey.pem \
182 --certificate=$RBAC_PKIDIR/client-1-cert.pem \
183 --ca-cert=$RBAC_PKIDIR/pki/switchca/cacert.pem \
186 "table": "user_colors",
187 "where": [["name", "==", "chartreuse"]],
188 "row": {"value": '8388353'}}
189 ]']], [0], [stdout], [ignore])
191 AT_CHECK([${PERL} $srcdir/uuidfilt.pl stdout], [0], [[[{"count":1}]]
195 # Attempt to update a column in the "user_colors" table. Same as
196 # previous test, but with a different client ID. This should fail
197 # the RBAC authorization test because "client-2" does not match the
198 # "creator" column for this row.
199 AT_CHECK([ovsdb-client transact ssl:127.0.0.1:$SSL_PORT \
200 --private-key=$RBAC_PKIDIR/client-2-privkey.pem \
201 --certificate=$RBAC_PKIDIR/client-2-cert.pem \
202 --ca-cert=$RBAC_PKIDIR/pki/switchca/cacert.pem \
205 "table": "user_colors",
206 "where": [["name", "==", "chartreuse"]],
207 "row": {"value": '8388354'}}
208 ]']], [0], [stdout], [ignore])
210 AT_CHECK([${PERL} $srcdir/uuidfilt.pl stdout], [0], [[[{"details":"RBAC rules for client \"client-2\" role \"testrole\" prohibit modification of table \"user_colors\".","error":"permission error"}]]
214 # Attempt to mutate a column in the "user_colors" table. This should
215 # succeed since role "testrole" has permissions for this table that
216 # allow update of the "value" column when ID is equal to the value in
217 # the "creator" column.
218 AT_CHECK([ovsdb-client transact ssl:127.0.0.1:$SSL_PORT \
219 --private-key=$RBAC_PKIDIR/client-1-privkey.pem \
220 --certificate=$RBAC_PKIDIR/client-1-cert.pem \
221 --ca-cert=$RBAC_PKIDIR/pki/switchca/cacert.pem \
224 "table": "user_colors",
225 "where": [["name", "==", "chartreuse"]],
226 "mutations": [["value", "+=", '10']]}
227 ]']], [0], [stdout], [ignore])
229 AT_CHECK([${PERL} $srcdir/uuidfilt.pl stdout], [0], [[[{"count":1}]]
233 # Attempt to mutate a column in the "user_colors" table. Same as
234 # previous test, but with a different client ID. This should fail
235 # the RBAC authorization test because "client-2" does not match the
236 # "creator" column for this row.
237 AT_CHECK([ovsdb-client transact ssl:127.0.0.1:$SSL_PORT \
238 --private-key=$RBAC_PKIDIR/client-2-privkey.pem \
239 --certificate=$RBAC_PKIDIR/client-2-cert.pem \
240 --ca-cert=$RBAC_PKIDIR/pki/switchca/cacert.pem \
243 "table": "user_colors",
244 "where": [["name", "==", "chartreuse"]],
245 "mutations": [["value", "+=", '10']]}
246 ]']], [0], [stdout], [ignore])
248 AT_CHECK([${PERL} $srcdir/uuidfilt.pl stdout], [0], [[[{"details":"RBAC rules for client \"client-2\" role \"testrole\" prohibit mutate operation on table \"user_colors\".","error":"permission error"}]]
252 # Attempt to delete a row from the "user_colors" table. This should fail
253 # the RBAC authorization test because "client-2" does not match the
254 # "creator" column for this row.
255 AT_CHECK([ovsdb-client transact ssl:127.0.0.1:$SSL_PORT \
256 --private-key=$RBAC_PKIDIR/client-2-privkey.pem \
257 --certificate=$RBAC_PKIDIR/client-2-cert.pem \
258 --ca-cert=$RBAC_PKIDIR/pki/switchca/cacert.pem \
261 "table": "user_colors",
262 "where": [["name", "==", "chartreuse"]]}
263 ]']], [0], [stdout], [ignore])
265 AT_CHECK([${PERL} $srcdir/uuidfilt.pl stdout], [0], [[[{"details":"RBAC rules for client \"client-2\" role \"testrole\" prohibit row deletion from table \"user_colors\".","error":"permission error"}]]
269 # Attempt to delete a row from the "user_colors" table. This should pass
270 # the RBAC authorization test because "client-1" does matches the
271 # "creator" column for this row.
272 AT_CHECK([ovsdb-client transact ssl:127.0.0.1:$SSL_PORT \
273 --private-key=$RBAC_PKIDIR/client-1-privkey.pem \
274 --certificate=$RBAC_PKIDIR/client-1-cert.pem \
275 --ca-cert=$RBAC_PKIDIR/pki/switchca/cacert.pem \
278 "table": "user_colors",
279 "where": [["name", "==", "chartreuse"]]}
280 ]']], [0], [stdout], [ignore])
282 AT_CHECK([${PERL} $srcdir/uuidfilt.pl stdout], [0], [[[{"count":1}]]
286 # Attempt to insert a row into the "other_colors" table. This should
287 # succeed since role "testrole" has permissions for this table that
288 # allow row insertion.
289 AT_CHECK([ovsdb-client transact ssl:127.0.0.1:$SSL_PORT \
290 --private-key=$RBAC_PKIDIR/client-1-privkey.pem \
291 --certificate=$RBAC_PKIDIR/client-1-cert.pem \
292 --ca-cert=$RBAC_PKIDIR/pki/switchca/cacert.pem \
295 "table": "other_colors",
296 "row": {"creator": ["map",[["chassis", "client-1"]]], "name": "seafoam", "value": '7466680'}}
297 ]']], [0], [stdout], [ignore])
299 AT_CHECK([${PERL} $srcdir/uuidfilt.pl stdout], [0], [[[{"uuid":["uuid","<0>"]}]]
303 # Attempt to update a column in the "user_colors" table. This should
304 # succeed since role "testrole" has permissions for this table that
305 # allow update of the "value" column when ID is equal to the value in
306 # the "creator" column.
307 AT_CHECK([ovsdb-client transact ssl:127.0.0.1:$SSL_PORT \
308 --private-key=$RBAC_PKIDIR/client-1-privkey.pem \
309 --certificate=$RBAC_PKIDIR/client-1-cert.pem \
310 --ca-cert=$RBAC_PKIDIR/pki/switchca/cacert.pem \
313 "table": "other_colors",
314 "where": [["name", "==", "seafoam"]],
315 "row": {"value": '8388353'}}
316 ]']], [0], [stdout], [ignore])
318 AT_CHECK([${PERL} $srcdir/uuidfilt.pl stdout], [0], [[[{"count":1}]]
322 # Attempt to update a column in the "other_colors" table. Same as
323 # previous test, but with a different client ID. This should fail
324 # the RBAC authorization test because "client-2" does not match the
325 # "creator" column for this row.
326 AT_CHECK([ovsdb-client transact ssl:127.0.0.1:$SSL_PORT \
327 --private-key=$RBAC_PKIDIR/client-2-privkey.pem \
328 --certificate=$RBAC_PKIDIR/client-2-cert.pem \
329 --ca-cert=$RBAC_PKIDIR/pki/switchca/cacert.pem \
332 "table": "other_colors",
333 "where": [["name", "==", "seafoam"]],
334 "row": {"value": '8388354'}}
335 ]']], [0], [stdout], [ignore])
337 AT_CHECK([${PERL} $srcdir/uuidfilt.pl stdout], [0], [[[{"details":"RBAC rules for client \"client-2\" role \"testrole\" prohibit modification of table \"other_colors\".","error":"permission error"}]]
341 # Attempt to delete a row from the "other_colors" table. This should fail
342 # the RBAC authorization test because "client-2" does not match the
343 # "creator" column for this row.
344 AT_CHECK([ovsdb-client transact ssl:127.0.0.1:$SSL_PORT \
345 --private-key=$RBAC_PKIDIR/client-2-privkey.pem \
346 --certificate=$RBAC_PKIDIR/client-2-cert.pem \
347 --ca-cert=$RBAC_PKIDIR/pki/switchca/cacert.pem \
350 "table": "other_colors",
351 "where": [["name", "==", "seafoam"]]}
352 ]']], [0], [stdout], [ignore])
354 AT_CHECK([${PERL} $srcdir/uuidfilt.pl stdout], [0], [[[{"details":"RBAC rules for client \"client-2\" role \"testrole\" prohibit row deletion from table \"other_colors\".","error":"permission error"}]]
358 # Attempt to delete a row from the "other_colors" table. This should pass
359 # the RBAC authorization test because "client-1" does matches the
360 # "creator" column for this row.
361 AT_CHECK([ovsdb-client transact ssl:127.0.0.1:$SSL_PORT \
362 --private-key=$RBAC_PKIDIR/client-1-privkey.pem \
363 --certificate=$RBAC_PKIDIR/client-1-cert.pem \
364 --ca-cert=$RBAC_PKIDIR/pki/switchca/cacert.pem \
367 "table": "other_colors",
368 "where": [["name", "==", "seafoam"]]}
369 ]']], [0], [stdout], [ignore])
371 AT_CHECK([${PERL} $srcdir/uuidfilt.pl stdout], [0], [[[{"count":1}]]
374 OVSDB_SERVER_SHUTDOWN