~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/archiveuploader/tests/nascentuploadfile.txt

  • Committer: Launchpad Patch Queue Manager
  • Date: 2011-12-22 04:45:35 UTC
  • mfrom: (14565.2.24 apocalyptic-pieces)
  • Revision ID: launchpad@pqm.canonical.com-20111222044535-jbjyzq3hzwiy7g20
[rs=sinzui][no-qa] Move javascript and scripts to lp. Dismantle
 mailnotification.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
= NascentUploadFiles =
 
1
NascentUploadFiles
 
2
==================
2
3
 
3
4
Files related with an Soyuz upload are modelled as:
4
5
 
22
23
    >>> from lp.archiveuploader.tests import datadir, getPolicy
23
24
 
24
25
 
25
 
== NascentUploadFile base class ==
 
26
NascentUploadFile base class
 
27
----------------------------
26
28
 
27
29
(This base class has many checks in it that are not yet documented here.)
28
30
 
29
 
=== Forbidden character check ===
 
31
Forbidden character check
 
32
.........................
30
33
Some characters are forbidden in filenames as per Debian packaging policy, and
31
34
this check is performed by the checkNameIsTaintFree() method.  It raises an
32
35
UploadError if there is an invalid character found.
55
58
    >>> upload_file.checkNameIsTaintFree()
56
59
 
57
60
 
58
 
== ChangesFile  ==
 
61
ChangesFile
 
62
-----------
59
63
 
60
64
A changesfile contains manifest of what is included (ou should be
61
65
considered) for the upload in question.
159
163
    >>> os.unlink(copyp)
160
164
 
161
165
 
162
 
=== CustomUploadFile identification ===
 
166
CustomUploadFile identification
 
167
...............................
163
168
 
164
169
A custom upload is essentially a tarball, so it matches the is_source
165
170
regexp, even though it isn't actually a source file:
212
217
uploads.
213
218
 
214
219
 
215
 
=== ChangesFile Parsing Addresses ===
 
220
ChangesFile Parsing Addresses
 
221
.............................
216
222
 
217
223
Address parsing is implemented by the SignableTagFile class, which
218
224
is base for ChangesFile and DSCFile.
264
270
    >>> addr['person'].creation_comment
265
271
    u'when the some-source_6.6.6 package was uploaded to hoary/RELEASE'
266
272
 
267
 
If the email address is registered but not associated with a person it will be 
268
 
associated with a new Person. This involves updating the email address, something 
269
 
for which the uploader must have explicit permissions (bug 589073).
 
273
If the email address is registered but not associated with a person it will be
 
274
associated with a new Person. This involves updating the email address,
 
275
something for which the uploader must have explicit permissions (bug 589073).
270
276
 
271
277
    >>> sig_file.policy.create_people
272
278
    True
280
286
    ...          "fo", "secr1t")
281
287
    >>> person = getUtility(IPersonSet).createPersonWithoutEmail("fo",
282
288
    ...          rationale=PersonCreationRationale.UNKNOWN)
283
 
        >>> person.account = acct
 
289
    >>> person.account = acct
284
290
 
285
 
    Commit the changes so the emailaddress will have to be updated later 
 
291
    Commit the changes so the emailaddress will have to be updated later
286
292
    rather than inserted.
287
293
 
288
294
    >>> commit()
335
341
    <Person ...>
336
342
 
337
343
 
338
 
=== Signature Traces ===
 
344
Signature Traces
 
345
................
339
346
 
340
347
Changes file can be optionally GPG-signed, so ChangesFile has
341
348
infrastructure to record this information for later checks with policy
353
360
    u'1024D/5D147547'
354
361
 
355
362
 
356
 
== DSCFile ==
 
363
DSCFile
 
364
-------
357
365
 
358
366
DSCFile class models the operations and checks needed for processing
359
367
and storing a DSC file in the LP system.
430
438
 
431
439
    >>> errors = ed_broken_dsc.verify()
432
440
    >>> [str(err) for err in errors]
433
 
    ['File ed_0.2-20.dsc mentioned in the changes has a checksum mismatch. de8b206f8fc57bd931f6226feac6644a != e31eeb0b6b3b87e1ea79378df864ffff']
 
441
    ['File ed_0.2-20.dsc mentioned in the changes has a checksum mismatch.
 
442
    de8b206f8fc57bd931f6226feac6644a != e31eeb0b6b3b87e1ea79378df864ffff']
434
443
 
435
444
It also verifies the file size when the checksum matches.
436
445
 
442
451
 
443
452
    >>> errors = ed_broken_dsc.verify()
444
453
    >>> [str(err) for err in errors]
445
 
    ['File ed_0.2-20.dsc mentioned in the changes has a size mismatch. 578 != 500']
446
 
 
447
 
 
448
 
=== Sub-DSC files or DSCUploadedFiles ===
 
454
    ['File ed_0.2-20.dsc mentioned in the changes has a size mismatch.
 
455
    578 != 500']
 
456
 
 
457
 
 
458
Sub-DSC files or DSCUploadedFiles
 
459
.................................
449
460
 
450
461
Sub-DSCFiles are DSCUploadedFile objects.
451
462
 
467
478
    ...     modified_insecure_policy, DevNullLogger())
468
479
    >>> errors = ed_broken_dsc_file.verify()
469
480
    >>> [str(err) for err in errors]
470
 
    ['File ed_0.2-20.diff.gz mentioned in the changes has a checksum mismatch. 8343836094fb01ee9b9a1067b23365f1 != f9e1e5f13725f581919e9bfd6227ffff']
471
 
 
472
 
 
473
 
=== Sub-DSC file lookup ===
474
 
 
475
 
 
476
 
== SourceUploadFile ==
477
 
 
478
 
 
479
 
== DebBinaryUploadFile ==
480
 
 
481
 
DebBinaryUploadFile models a binary .deb file. 
482
 
 
483
 
   >>> from lp.archiveuploader.nascentuploadfile import (
484
 
   ...    DebBinaryUploadFile)
485
 
   >>> ed_deb_path = datadir('ed_0.2-20_i386.deb')
486
 
   >>> ed_binary_deb = DebBinaryUploadFile(ed_deb_path,
487
 
   ...                     'e31eeb0b6b3b87e1ea79378df864ffff',
488
 
   ...                     15, 'main/editors', 'important', 'foo', '1.2',
489
 
   ...                     ed_binary_changes, modified_insecure_policy,
490
 
   ...                     DevNullLogger())
 
481
    ['File ed_0.2-20.diff.gz mentioned in the changes has a checksum mismatch.
 
482
    8343836094fb01ee9b9a1067b23365f1 != f9e1e5f13725f581919e9bfd6227ffff']
 
483
 
 
484
 
 
485
DebBinaryUploadFile
 
486
-------------------
 
487
 
 
488
DebBinaryUploadFile models a binary .deb file.
 
489
 
 
490
    >>> from lp.archiveuploader.nascentuploadfile import (
 
491
    ...    DebBinaryUploadFile)
 
492
    >>> ed_deb_path = datadir('ed_0.2-20_i386.deb')
 
493
    >>> ed_binary_deb = DebBinaryUploadFile(
 
494
    ...     ed_deb_path, 'e31eeb0b6b3b87e1ea79378df864ffff', 15,
 
495
    ...     'main/editors', 'important', 'foo', '1.2', ed_binary_changes,
 
496
    ...     modified_insecure_policy, DevNullLogger())
491
497
 
492
498
Like the other files it can be verified:
493
499
 
494
 
   >>> list(ed_binary_deb.verify())
495
 
   []
 
500
    >>> list(ed_binary_deb.verify())
 
501
    []
496
502
 
497
503
Verification checks that the specified section matches the section in the
498
504
changes file:
499
505
 
500
 
   >>> ed_binary_deb = DebBinaryUploadFile(ed_deb_path,
501
 
   ...                     'e31eeb0b6b3b87e1ea79378df864ffff',
502
 
   ...                     15, 'main/net', 'important', 'foo', '1.2',
503
 
   ...                     ed_binary_changes, modified_insecure_policy,
504
 
   ...                     DevNullLogger())
505
 
   >>> list(ed_binary_deb.verify())
506
 
   [UploadError('ed_0.2-20_i386.deb control file lists section as 
507
 
                main/editors but changes file has main/net.',)]
 
506
    >>> ed_binary_deb = DebBinaryUploadFile(
 
507
    ...     ed_deb_path, 'e31eeb0b6b3b87e1ea79378df864ffff', 15, 'main/net',
 
508
    ...     'important', 'foo', '1.2', ed_binary_changes,
 
509
    ...     modified_insecure_policy, DevNullLogger())
 
510
    >>> list(ed_binary_deb.verify())
 
511
    [UploadError('ed_0.2-20_i386.deb
 
512
    control file lists section as main/editors but changes file has
 
513
    main/net.',)]
508
514
 
509
515
It also checks the priority against the changes file:
510
516
 
511
 
   >>> ed_binary_deb = DebBinaryUploadFile(ed_deb_path,
512
 
   ...                     'e31eeb0b6b3b87e1ea79378df864ffff',
513
 
   ...                     15, 'main/editors', 'extra', 'foo', '1.2',
514
 
   ...                     ed_binary_changes, modified_insecure_policy,
515
 
   ...                     DevNullLogger())
516
 
   >>> list(ed_binary_deb.verify())
517
 
   [UploadError('ed_0.2-20_i386.deb control file lists priority as important 
518
 
                 but changes file has extra.',)]
519
 
 
520
 
The timestamp of the files in the .deb are tested against the policy for being 
521
 
too new:
522
 
 
523
 
   >>> from lp.archiveuploader.uploadpolicy import ArchiveUploadType
524
 
   >>> old_only_policy = getPolicy(
525
 
   ...     name='insecure', distro='ubuntu', distroseries='hoary')
526
 
   >>> old_only_policy.accepted_type = ArchiveUploadType.BINARY_ONLY
527
 
   >>> old_only_policy.future_time_grace = -5 * 365 * 24 * 60 * 60
528
 
 
529
 
   >>> ed_binary_deb = DebBinaryUploadFile(ed_deb_path,
530
 
   ...                     'e31eeb0b6b3b87e1ea79378df864ffff',
531
 
   ...                     15, 'main/editors', 'important', 'foo', '1.2',
532
 
   ...                     ed_binary_changes, old_only_policy,
533
 
   ...                     DevNullLogger())
534
 
   >>> list(ed_binary_deb.verifyDebTimestamp())
535
 
   [UploadError('ed_0.2-20_i386.deb: has 26 file(s) with a time stamp too 
536
 
        far into the future (e.g. control [Thu Jan  3 19:29:01 2008]).',)]
 
517
    >>> ed_binary_deb = DebBinaryUploadFile(
 
518
    ...     ed_deb_path, 'e31eeb0b6b3b87e1ea79378df864ffff', 15,
 
519
    ...     'main/editors', 'extra', 'foo', '1.2', ed_binary_changes,
 
520
    ...     modified_insecure_policy, DevNullLogger())
 
521
    >>> list(ed_binary_deb.verify())
 
522
    [UploadError('ed_0.2-20_i386.deb
 
523
    control file lists priority as important but changes file has extra.',)]
 
524
 
 
525
The timestamp of the files in the .deb are tested against the policy for
 
526
being too new:
 
527
 
 
528
    >>> from lp.archiveuploader.uploadpolicy import ArchiveUploadType
 
529
    >>> old_only_policy = getPolicy(
 
530
    ...     name='insecure', distro='ubuntu', distroseries='hoary')
 
531
    >>> old_only_policy.accepted_type = ArchiveUploadType.BINARY_ONLY
 
532
    >>> old_only_policy.future_time_grace = -5 * 365 * 24 * 60 * 60
 
533
 
 
534
    >>> ed_binary_deb = DebBinaryUploadFile(
 
535
    ...     ed_deb_path, 'e31eeb0b6b3b87e1ea79378df864ffff', 15,
 
536
    ...     'main/editors', 'important', 'foo', '1.2', ed_binary_changes,
 
537
    ...     old_only_policy, DevNullLogger())
 
538
    >>> list(ed_binary_deb.verifyDebTimestamp())
 
539
    [UploadError('ed_0.2-20_i386.deb:
 
540
    has 26 file(s) with a time stamp too far into the future
 
541
    (e.g. control [Thu Jan  3 19:29:01 2008]).',)]
537
542
 
538
543
... as well as for being too old:
539
544
 
540
 
   >>> new_only_policy = getPolicy(
541
 
   ...     name='insecure', distro='ubuntu', distroseries='hoary')
542
 
   >>> new_only_policy.accepted_type = ArchiveUploadType.BINARY_ONLY
543
 
   >>> new_only_policy.earliest_year = 2010
544
 
   >>> ed_binary_deb = DebBinaryUploadFile(ed_deb_path,
545
 
   ...                     'e31eeb0b6b3b87e1ea79378df864ffff',
546
 
   ...                     15, 'main/editors', 'important', 'foo', '1.2',
547
 
   ...                     ed_binary_changes, new_only_policy,
548
 
   ...                     DevNullLogger())
549
 
   >>> list(ed_binary_deb.verify())
550
 
   [UploadError('ed_0.2-20_i386.deb: has 26 file(s) with a time stamp too
551
 
                 far in the past (e.g. control [Thu Jan  3 19:29:01 2008]).',)]
552
 
 
553
 
 
554
 
== UDebBinaryUploadFile ==
555
 
 
556
 
 
557
 
== CustomUploadFile ==
558
 
 
559
 
 
 
545
    >>> new_only_policy = getPolicy(
 
546
    ...     name='insecure', distro='ubuntu', distroseries='hoary')
 
547
    >>> new_only_policy.accepted_type = ArchiveUploadType.BINARY_ONLY
 
548
    >>> new_only_policy.earliest_year = 2010
 
549
    >>> ed_binary_deb = DebBinaryUploadFile(
 
550
    ...     ed_deb_path, 'e31eeb0b6b3b87e1ea79378df864ffff', 15,
 
551
    ...     'main/editors', 'important', 'foo', '1.2', ed_binary_changes,
 
552
    ...     new_only_policy, DevNullLogger())
 
553
    >>> list(ed_binary_deb.verify())
 
554
    [UploadError('ed_0.2-20_i386.deb:
 
555
    has 26 file(s) with a time stamp too far in the past
 
556
    (e.g. control [Thu Jan  3 19:29:01 2008]).',)]