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 from __future__
import with_statement
29 ###--------------------------------------------------------------------------
36 import subprocess
as SUB
41 ###--------------------------------------------------------------------------
42 ### Running the pixie.
44 class PixieTestCase (U
.TestCase
):
46 pix
= "pixie-py%d.%d%s" %
(SYS
.version_info
[0],
48 T
.DEBUGP
and "dbg" or "")
49 me
.token
= C
.rand
.block(8).hex()
50 try: OS
.mkdir(OS
.path
.join("build", pix
), int("700", 8))
52 if SYS
.exc_info()[1].errno
== E
.EEXIST
: pass
54 me
.sock
= OS
.path
.join("build", pix
, "sock")
55 OS
.environ
["CATACOMB_PIXIE_SOCKET"] = me
.sock
56 with
open(OS
.path
.join("build", pix
, "log"), "a") as logf
:
57 SUB
.check_call(["pixie", "-dr", "-s" + me
.sock
,
58 "-c", "echo 'pp.%%t.%s'" % me
.token
], stderr
= logf
)
60 SUB
.check_call(["pixie", "-s" + me
.sock
, "-C", "quit"])
62 ###--------------------------------------------------------------------------
63 class TestPixie (PixieTestCase
):
66 px
= C
.Pixie(socket
= me
.sock
)
68 pp
= T
.bin("super secret")
69 pp1
= T
.bin("pp.test1.%s" % me
.token
)
70 pp2
= T
.bin("pp.test2.%s" % me
.token
)
72 me
.assertEqual(px
.read("test1"), pp
)
73 me
.assertEqual(px
.read("test1", C
.PMODE_READ
), pp
)
74 me
.assertEqual(px
.read("test1", C
.PMODE_VERIFY
), pp1
)
75 me
.assertEqual(px
.read("test1", C
.PMODE_READ
), pp1
)
77 me
.assertEqual(px
.read("test1", C
.PMODE_READ
), pp
)
78 me
.assertEqual(px
.read("test2"), pp2
)
80 me
.assertEqual(px
.read("test1"), pp1
)
83 me
.assertEqual(C
.ppread("test1"), pp
)
85 me
.assertEqual(px
.read("test1"), pp1
)
88 ###----- That's all, folks --------------------------------------------------
90 if __name__
== "__main__": U
.main()