|
|
@@ -975,8 +975,21 @@ def cmd_import(options): |
|
|
|
inp = inp.strip() |
|
|
|
jobj, endpos = jd.raw_decode(inp) |
|
|
|
|
|
|
|
if options.sign: |
|
|
|
cbr = _makeuuid(jobj['created_by_ref']) |
|
|
|
if cbr != persona.uuid: |
|
|
|
# new owner |
|
|
|
jobj['created_by_ref'] = persona.uuid |
|
|
|
|
|
|
|
# drop old parts |
|
|
|
jobj.pop('uuid', None) |
|
|
|
jobj.pop('modified', None) |
|
|
|
|
|
|
|
obj = MDBase.create_obj(jobj) |
|
|
|
|
|
|
|
if options.sign: |
|
|
|
obj = persona.sign(obj) |
|
|
|
|
|
|
|
objstr.loadobj(obj) |
|
|
|
|
|
|
|
inp = inp[endpos:] |
|
|
@@ -1042,6 +1055,8 @@ def main(): |
|
|
|
parser_dump.set_defaults(func=cmd_dump) |
|
|
|
|
|
|
|
parser_import = subparsers.add_parser('import', help='import objects encoded as json') |
|
|
|
parser_import.add_argument('--sign', action='store_true', |
|
|
|
help='import as new identity, and sign objects (if created_by_ref is different, new uuid is created)') |
|
|
|
parser_import.set_defaults(func=cmd_import) |
|
|
|
|
|
|
|
parser_drop = subparsers.add_parser('drop', help='drop the object specified by UUID') |
|
|
@@ -1590,8 +1605,11 @@ class _TestCases(unittest.TestCase): |
|
|
|
|
|
|
|
# with the correct output |
|
|
|
self.maxDiff = None |
|
|
|
outnre = cmd.get('stdout_nre') |
|
|
|
outre = cmd.get('stdout_re') |
|
|
|
if outre: |
|
|
|
if outnre: |
|
|
|
self.assertNotRegex(stdout.getvalue(), outnre) |
|
|
|
elif outre: |
|
|
|
self.assertRegex(stdout.getvalue(), outre) |
|
|
|
else: |
|
|
|
self.assertEqual(stdout.getvalue(), cmd.get('stdout', '')) |
|
|
|