3 ### Testing (some) passsword management functionality
5 ### (c) 2019 Straylight/Edgeware
8 ###----- Licensing notice ---------------------------------------------------
10 ### This file is part of the Python interface to Catacomb.
12 ### Catacomb/Python is free software: you can redistribute it and/or
13 ### modify it under the terms of the GNU General Public License as
14 ### published by the Free Software Foundation; either version 2 of the
15 ### License, or (at your option) any later version.
17 ### Catacomb/Python is distributed in the hope that it will be useful, but
18 ### WITHOUT ANY WARRANTY; without even the implied warranty of
19 ### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 ### General Public License for more details.
22 ### You should have received a copy of the GNU General Public License
23 ### along with Catacomb/Python. If not, write to the Free Software
24 ### Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
27 ###--------------------------------------------------------------------------
34 ###--------------------------------------------------------------------------
35 class TestShare (U
.TestCase
):
37 def check_share(me
, splitcls
, splitargs
, joincls
, joinargs
, secret
):
39 split
= splitcls(3, secret
, *splitargs
)
40 me
.assertEqual(split
.threshold
, 3)
41 shares
= [split
.get(i
) for i
in T
.range(5)]
43 join
= joincls(3, *joinargs
)
44 me
.assertEqual(join
.threshold
, 3)
45 me
.assertFalse(join
.addedp(1))
46 me
.assertEqual(join
.remain
, 3)
47 join
.add(1, shares
[1])
48 me
.assertTrue(join
.addedp(1))
49 me
.assertEqual(join
.remain
, 2)
50 me
.assertRaises(ValueError, join
.combine
)
51 join
.add(0, shares
[0])
52 join
.add(3, shares
[3])
53 me
.assertEqual(join
.remain
, 0)
54 me
.assertEqual(join
.combine(), secret
)
57 rng
= T
.detrand("share")
59 me
.check_share(C
.ShareSplit
, [p
, rng
], C
.ShareJoin
, [p
], rng
.range(p
))
62 rng
= T
.detrand("gfshare")
63 me
.check_share(C
.GFShareSplit
, [rng
], C
.GFShareJoin
, [123],
66 ###----- That's all, folks --------------------------------------------------
68 if __name__
== "__main__": U
.main()