Cross Reference: /pkg/src/tests/api/t_action.py
t_action.py revision 3234
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
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
305 N/A # The contents of this file are subject to the terms of the 305 N/A # Common Development and Distribution License (the "License"). 305 N/A # You may not use this file except in compliance with the License. 305 N/A # See the License for the specific language governing permissions 305 N/A # and limitations under the License. 305 N/A # When distributing Covered Code, include this CDDL HEADER in each 305 N/A # If applicable, add the following below this CDDL HEADER, with the 305 N/A # fields enclosed by brackets "[]" replaced with your own identifying 305 N/A # information: Portions Copyright [yyyy] [name of copyright owner] 3158 N/A # Copyright (c) 2008, 2015, Oracle and /or its affiliates. All rights reserved. 2026 N/A "set name=foo value=f'o'o" ,
2026 N/A "set name=foo value='f\"o \"o'" ,
2026 N/A "set name=foo value='b\"a \"r' value='f\"o \"o'" ,
2026 N/A "set name=foo value=\"f'o 'o\"" ,
2026 N/A "set name=foo value=\"b'a 'r\" value=\"f'o 'o\"" ,
2026 N/A "set name=foo value='f\"o \\' \"o'" ,
2026 N/A "set name=foo value='b\"a \\' \"r' value='f\"o \\' \"o'" ,
2026 N/A "set name=foo value='\"foo\"'" ,
2026 N/A "set name=foo value='\"bar\"'value='\"foo\"'" ,
2026 N/A "set name=foo value=\"'foo'\"" ,
2026 N/A "set name=foo value=\"'bar'\" value=\"'foo'\"" ,
2026 N/A "set name=foo value='\"fo\\\'o\"'" ,
2026 N/A "set name=foo value='\"ba\\\'r\"' value='\"fo\\\'o\"'" ,
2026 N/A "set name=foo value=\"'fo\\\"o'\"" ,
2026 N/A "set name=foo value=\"'ba\\\"r'\" value=\"'fo\\\"o'\"" ,
2026 N/A 'set name=foo value=ab value="" value=c' ,
2026 N/A "file 12345 name=\"foo bar\" attr=\"bar baz\" path=/tmp /foo " ,
2026 N/A "file 12345 name=\"foo bar\" attr=\"bar baz\" path=/tmp /foo " ,
2026 N/A "file 12345 name=foo value=\"bar baz quux\" path=/tmp /foo " ,
2026 N/A "file 12345 name=\"foo bar baz\" value=quux path=/tmp /foo " ,
2026 N/A "driver alias=pci1234,56 alias=pci4567,89 class=scsi name=lsimega" ,
2026 N/A "signature 12345 algorithm=foo" ,
591 N/A Incorrect attribute value. 591 N/A Incorrect attribute list. 2639 N/A # For convenience, we allow set actions to be expressed as 2639 N/A # "<name>=<value>", rather than "name=<name> value=<value>", but 2639 N/A # we always convert to the latter. Verify that both forms are 591 N/A # Make sure that unescaped double quotes are parsed properly 591 N/A # inside a single-quoted value. 591 N/A # Make sure that escaped single quotes are parsed properly 591 N/A # inside a single-quoted value. 591 N/A # Unescaped, unpaired quotes are allowed in the middle of values 591 N/A # without further quoting 591 N/A # They can even be paired. Note this is not like shell quoting. 591 N/A # An unquoted value can end in an escaped backslash 591 N/A # An action with multiple identical attribute names should 591 N/A # result in an attribute with a list value. 1384 N/A # An action with an empty value. 1384 N/A # An action with an empty value as part of a list. 1618 N/A # An action with its key attribute and extra attributes that 1618 N/A # are not used by the package system. 1618 N/A 'Distribution License 1.0 (CDDL)" custom="foo" ' 1618 N/A 'and Distribution License 1.0 (CDDL)' )
2233 N/A # Really long actions with lots of backslash-escaped quotes 2233 N/A a =
action .
fromstr (r
'set name=pkg.description value="Sphinx is a tool that makes it easy to create intelligent \"and beautiful documentation f\"or Python projects (or \"other documents consisting of\" multiple reStructuredText so\"urces), written by Georg Bran\"dl. It was originally created\" to translate the new Python \"documentation, but has now be\"en cleaned up in the hope tha\"t it will be useful to many o\"ther projects. Sphinx uses re\"StructuredText as its markup \"language, and many of its str\"engths come from the power an\"d straightforwardness of reSt\"ructuredText and its parsing \"and translating suite, the Do\"cutils. Although it is still \"under constant development, t\"he following features are alr\"eady present, work fine and c\"an be seen \"in action\" \"in the Python docs: * Output \"formats: HTML (including Wind\"ows HTML Help) and LaTeX, for\" printable PDF versions * Ext\"ensive cross-references: sema\"ntic markup and automatic lin\"ks for functions, classes, gl\"ossary terms and similar piec\"es of information * Hierarchi\"cal structure: easy definitio\"n of a document tree, with au\"tomatic links to siblings, pa\"rents and children * Automati\"c indices: general index as w\"ell as a module index * Code \"handling: automatic highlight\"ing using the Pygments highli\"ghter * Various extensions ar\"e available, e.g. for automat\"ic testing of snippets and in\"clusion of appropriately formatted docstrings."' )
2457 N/A # Make sure that the hash member of the action object properly 2457 N/A # contains the value of the "hash" named attribute. 1618 N/A """Test license action attributes.""" 1618 N/A # Verify license attributes for must-accept / must-display 1618 N/A 'Distribution License 1.0 (CDDL)" custom="foo" ' 1618 N/A 'Distribution License 1.0 (CDDL)" must-accept=true ' 1618 N/A 'Distribution License 1.0 (CDDL)" must-accept=True ' 1618 N/A 'Distribution License 1.0 (CDDL)" must-accept=True ' )
1938 N/A """Test that actions convert to strings properly. This means 1938 N/A that we can feed the resulting string back into fromstr() and 1938 N/A get an identical action back.""" 2457 N/A # The one place that invariant doesn't hold is when you specify 2457 N/A # the payload hash as the named attribute "hash", in which case 2457 N/A # the resulting re-stringification emits the payload hash as a 2457 N/A # positional attribute again ... 2457 N/A # ... unless of course the hash can't be represented that way. 2685 N/A "hash=\"one with spaces\"" :
"one with spaces" ,
2685 N/A "hash='one with \" character'" :
'one with " character' ,
2685 N/A "hash=\"'= !@$%^\)(*\"" :
"'= !@$%^\)(*" ,
2685 N/A """hash="\\"'= \\ " """:""" "'= \\ " "" ,
2026 N/A "signature 54321 algorithm=baz" )
2026 N/A # action.sig_str should return an identical string each 2026 N/A # time it's called. Also, parsing the result of 2026 N/A # sig_str so produce the same action. 2026 N/A # If s2 is None, then s was a different signature 2026 N/A # action, so there is no output to parse. 2026 N/A # Test that using an unknown sig_version triggers the 2026 N/A # Test that the sig_str of a signature action other than the 2026 N/A "signature 98765 algorithm=foobar" )
1234 N/A # If the action isn't malformed, something is wrong. 1234 N/A # If the action isn't invalid, something is wrong. 2639 N/A # Nothing but the action type or type is malformed. 591 N/A # Bad quoting: missing close quote 591 N/A # Bad quoting: quote in key 1234 N/A # Attribute value is invalid. 1234 N/A # Missing required attribute 'type'. 1234 N/A # Missing key attribute 'fmri'. 2476 N/A # Mutiple fmri values only allowed for require-any deps. 2254 N/A # 'path' attribute specified multiple times 1659 N/A # 'data' used as an attribute key 1234 N/A # Missing required attribute 'path'. 1234 N/A # Missing required attribute 'name'. 873 N/A "driver alias=pci1234,56 alias=pci4567,89 class=scsi" )
1973 N/A # Verify malformed actions > 255 characters don't cause corrupt 1973 N/A # exception action strings. 1973 N/A self .
assertMalformed (
"""legacy arch=i386 category=GNOME2,application,JDSosol desc="XScreenSaver is two things: it is both a large collection of screen savers (distributed in the "hacks" packages) and it is also the framework for blanking and locking the screen (this package)." hotline="Please contact your local service provider" name="XScreenSaver is two things: it is both a large collection of screen savers (distributed in the "hacks" packages) and it is also the framework for blanking and locking the screen (this package)." pkg=SUNWxscreensaver vendor="XScreenSaver Community" version=5.11,REV=110.0.4.2010.07.08.22.18""" )
1973 N/A self .
assertMalformed (
"""legacy arch=i386 category=GNOME2,application,JDSosol desc="XScreenSaver is two things: it is both a large collection of screen savers (distributed in the "hacks" packages) and it is also the framework for blanking and locking the screen (this package)." hotline="Please contact your local service provider" name="XScreenSaver is two things: it is both a large collection of screen savers (distributed in the "hacks" packages) and it is also the framework for blanking and locking the screen (this package)." pkg=SUNWxscreensaver-l10n vendor="XScreenSaver Community" version=5.11,REV=110.0.4.2010.07.08.22.18""" )
2026 N/A # Missing required attribute 'algorithm'. 2026 N/A "signature 12345 pkg.cert=bar" )
2457 N/A # The payload hash can't be specified as both a named and a 2457 N/A # positional attribute if they're not identical. 1755 N/A """Verify that action validate() works as expected; currently 1755 N/A only used during publication or action execution failure.""" 2476 N/A # Verify predicate and target attributes of FMRIs must be valid. 2476 N/A "depend type=require-any fmri=foo fmri=bar fmri=invalid@abc" ,
2476 N/A # Predicate is missing for conditional dependency. 2476 N/A "depend type=conditional fmri=foo" ,
2476 N/A # Predicate value is invalid. 2476 N/A "depend type=conditional predicate=-invalid fmri=foo" ,
2476 N/A # Predicate isn't valid for dependency type. 2476 N/A "depend type=require predicate=1invalid fmri=foo" ,
2476 N/A # root-image attribute is only valid for origin dependencies. 2476 N/A "depend type=require fmri=foo root-image=true" ,
2476 N/A # Multiple values for predicate are not allowed. 3138 N/A "depend type=conditional predicate=foo predicate=bar fmri=baz" ,
3138 N/A # Multiple values for ignore-check are not allowed. 3138 N/A "depend type=require fmri=foo ignore-check=true ignore-check=false" ):
2476 N/A # Verify multiple values for file attributes are rejected. 2476 N/A for attr in (
"pkg.size" ,
"pkg.csize" ,
"chash" ,
"preserve" ,
2476 N/A "overlay" ,
"elfhash" ,
"original_name" ,
"facet.doc" ,
2476 N/A # Verify invalid values are not allowed for mode attribute on 1755 N/A "mode=44755" ,
"mode=44" ,
"mode=999" ,
"mode=0898" ):
2476 N/A # Verify multiple values aren't allowed for legacy action 2476 N/A for attr in (
"category" ,
"desc" ,
"hotline" ,
"name" ,
"vendor" ,
2476 N/A # Verify multiple values aren't allowed for gid of group. 2476 N/A # Verify only numeric value is allowed for gid of group. 2476 N/A # Verify multiple values are not allowed for must-accept and 2476 N/A # must-display attributes of license actions. 3158 N/A nact =
"license license=copyright {attr}=true " \
2476 N/A # Ensure link and hardlink attributes are validated properly. 2453 N/A # Action with mediator without mediator properties is 2453 N/A # Action with multiple mediator values is invalid. 2453 N/A "mediator=vi mediator=vim " \
2453 N/A # Action with mediator properties without mediator 2453 N/A "mediator-implementation" :
"svr4" ,
2453 N/A "mediator-priority" :
"site" ,
2453 N/A # Action with multiple values for any property is 2453 N/A # mediator-priority alone isn't 2453 N/A # valid, so test multiple value 2453 N/A # Verify invalid mediator names are rejected. 3158 N/A "mediator=\"{1}\" mediator-implementation=vim" \
2453 N/A # Verify invalid mediator-versions are rejected. 3158 N/A "mediator=vim mediator-version={1}" \
2476 N/A # Verify invalid mediator-implementations are rejected. 3158 N/A "mediator=vim mediator-implementation={1}" \
2476 N/A # Verify multiple targets are not allowed. 2476 N/A # Verify multiple values are not allowed for set actions such as 2476 N/A # pkg.description, pkg.obsolete, pkg.renamed, and pkg.summary. 2476 N/A for attr in (
"pkg.description" ,
"pkg.obsolete" ,
"pkg.renamed" ,
3197 N/A "pkg.summary" ,
"pkg.depend.explicit-install" ):
2476 N/A # Verify signature action attribute 'value' is required during 2476 N/A # Verify multiple values aren't allowed for user attributes. 2476 N/A for attr in (
"password" ,
"group" ,
"gcos-field" ,
"home-dir" ,
2476 N/A for attr in (
"uid" ,
"lastchg" ,
"min" ,
"max" ,
"warn" ,
"inactive" ,
2476 N/A # Verify only numeric values are allowed for user attributes 2476 N/A for attr in (
"uid" ,
"lastchg" ,
"min" ,
"max" ,
"warn" ,
"inactive" ,
3160 N/A "set name=pkg.additional-update-on-uninstall " 3160 N/A "set name=pkg.additional-update-on-uninstall " 3160 N/A # Unknown actuator (should pass) 3160 N/A "set name=pkg.additional-update-on-update value=A@1" )