コード例 #1
0
 def test_full(self):
     nss.nss_init_nodb()
     try:
         doc = PSKCDocument(os.path.join(basename, "full.xml"))
         assert [(t.id, t.options) for t in doc.getKeyPackages()] == [
             (
                 u"KID1",
                 {
                     "ipatokenotpkey": u"GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ",
                     "ipatokennotafter": u"20060531000000Z",
                     "ipatokennotbefore": u"20060501000000Z",
                     "ipatokenserial": u"SerialNo-IssueNo",
                     "ipatokentotpclockoffset": 60000,
                     "ipatokenotpalgorithm": u"sha1",
                     "ipatokenvendor": u"iana.dummy",
                     "description": u"FriendlyName",
                     "ipatokentotptimestep": 200,
                     "ipatokenhotpcounter": 0,
                     "ipatokenmodel": u"Model",
                     "ipatokenotpdigits": 8,
                     "type": u"hotp",
                 },
             )
         ]
     finally:
         nss.nss_shutdown()
コード例 #2
0
 def test_figure5(self):
     doc = PSKCDocument(os.path.join(basename, "pskc-figure5.xml"))
     assert doc.keyname is None
     try:
         [(t.id, t.options) for t in doc.getKeyPackages()]
     except ValidationError: # PIN Policy is not supported.
         pass
     else:
         assert False
コード例 #3
0
 def test_mini(self):
     try:
         doc = PSKCDocument(os.path.join(basename, "pskc-mini.xml"))
         for t in doc.getKeyPackages():
             t._PSKCKeyPackage__process()
     except ValidationError: # Unsupported token type.
         pass
     else:
         assert False
コード例 #4
0
 def test_figure7(self):
     doc = PSKCDocument(os.path.join(basename, "pskc-figure7.xml"))
     assert doc.keyname == 'My Password 1'
     doc.setKey(b'qwerty')
     assert [(t.id, t.options) for t in doc.getKeyPackages()] == \
         [(u'123456', {
             'ipatokenotpkey': u'GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ',
             'ipatokenvendor': u'TokenVendorAcme',
             'ipatokenserial': u'987654321',
             'ipatokenotpdigits': 8,
             'type': u'hotp'})]
コード例 #5
0
 def test_mini(self):
     nss.nss_init_nodb()
     try:
         doc = PSKCDocument(os.path.join(basename, "pskc-mini.xml"))
         [(t.id, t.options) for t in doc.getKeyPackages()]
     except ValidationError: # Unsupported token type.
         pass
     else:
         assert False
     finally:
         nss.nss_shutdown()
コード例 #6
0
 def test_figure6(self):
     doc = PSKCDocument(os.path.join(basename, "pskc-figure6.xml"))
     assert doc.keyname == 'Pre-shared-key'
     doc.setKey('12345678901234567890123456789012'.decode('hex'))
     assert [(t.id, t.options) for t in doc.getKeyPackages()] == \
         [(u'12345678', {
             'ipatokenotpkey': u'GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ',
             'ipatokenvendor': u'Manufacturer',
             'ipatokenserial': u'987654321',
             'ipatokenhotpcounter': 0,
             'ipatokenotpdigits': 8,
             'type': u'hotp'})]
コード例 #7
0
 def test_figure3(self):
     doc = PSKCDocument(os.path.join(basename, "pskc-figure3.xml"))
     assert doc.keyname is None
     assert [(t.id, t.options) for t in doc.getKeyPackages()] == \
         [(u'12345678', {
             'ipatokenotpkey': u'GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ',
             'ipatokenvendor': u'Manufacturer',
             'ipatokenserial': u'987654321',
             'ipatokenhotpcounter': 0,
             'ipatokenotpdigits': 8,
             'type': u'hotp',
             })]
コード例 #8
0
 def test_mini(self):
     nss.nss_init_nodb()
     try:
         doc = PSKCDocument(os.path.join(basename, "pskc-mini.xml"))
         for t in doc.getKeyPackages():
             t._PSKCKeyPackage__process()
     except ValidationError:  # Unsupported token type.
         pass
     else:
         assert False
     finally:
         nss.nss_shutdown()
コード例 #9
0
 def test_figure3(self):
     doc = PSKCDocument(os.path.join(basename, "pskc-figure3.xml"))
     assert doc.keyname is None
     assert [(t.id, t.options) for t in doc.getKeyPackages()] == \
         [(u'12345678', {
             'ipatokenotpkey': u'GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ',
             'ipatokenvendor': u'Manufacturer',
             'ipatokenserial': u'987654321',
             'ipatokenhotpcounter': 0,
             'ipatokenotpdigits': 8,
             'type': u'hotp',
             })]
コード例 #10
0
 def test_figure6(self):
     doc = PSKCDocument(os.path.join(basename, "pskc-figure6.xml"))
     assert doc.keyname == 'Pre-shared-key'
     doc.setKey(codecs.decode('12345678901234567890123456789012', 'hex'))
     assert [(t.id, t.options) for t in doc.getKeyPackages()] == \
         [(u'12345678', {
             'ipatokenotpkey': u'GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ',
             'ipatokenvendor': u'Manufacturer',
             'ipatokenserial': u'987654321',
             'ipatokenhotpcounter': 0,
             'ipatokenotpdigits': 8,
             'type': u'hotp'})]
コード例 #11
0
 def test_figure7(self):
     nss.nss_init_nodb()
     try:
         doc = PSKCDocument(os.path.join(basename, "pskc-figure7.xml"))
         assert doc.keyname == 'My Password 1'
         doc.setKey('qwerty')
         assert [(t.id, t.options) for t in doc.getKeyPackages()] == \
             [(u'123456', {
                 'ipatokenotpkey': u'GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ',
                 'ipatokenvendor': u'TokenVendorAcme',
                 'ipatokenserial': u'987654321',
                 'ipatokenotpdigits': 8,
                 'type': u'hotp'})]
     finally:
         nss.nss_shutdown()
コード例 #12
0
 def test_figure8(self):
     try:
         PSKCDocument(os.path.join(basename, "pskc-figure8.xml"))
     except NotImplementedError:  # X.509 is not supported.
         pass
     else:
         assert False
コード例 #13
0
 def test_figure3(self):
     doc = PSKCDocument(os.path.join(basename, "pskc-figure3.xml"))
     assert doc.keyname is None
     assert [(t.id, t.options) for t in doc.getKeyPackages()] == [
         (
             u"12345678",
             {
                 "ipatokenotpkey": u"GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ",
                 "ipatokenvendor": u"Manufacturer",
                 "ipatokenserial": u"987654321",
                 "ipatokenhotpcounter": 0,
                 "ipatokenotpdigits": 8,
                 "type": u"hotp",
             },
         )
     ]
コード例 #14
0
 def test_invalid(self):
     try:
         PSKCDocument(os.path.join(basename, "pskc-invalid.xml"))
     except ValueError:  # File is invalid.
         pass
     else:
         assert False
コード例 #15
0
 def test_full(self):
     doc = PSKCDocument(os.path.join(basename, "full.xml"))
     assert [(t.id, t.options) for t in doc.getKeyPackages()] == \
         [(u'KID1', {
             'ipatokenotpkey': u'GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ',
             'ipatokennotafter': u'20060531000000Z',
             'ipatokennotbefore': u'20060501000000Z',
             'ipatokenserial': u'SerialNo-IssueNo',
             'ipatokentotpclockoffset': 60000,
             'ipatokenotpalgorithm': u'sha1',
             'ipatokenvendor': u'iana.dummy',
             'description': u'FriendlyName',
             'ipatokentotptimestep': 200,
             'ipatokenhotpcounter': 0,
             'ipatokenmodel': u'Model',
             'ipatokenotpdigits': 8,
             'type': u'hotp',
         })]
コード例 #16
0
 def test_full(self):
     doc = PSKCDocument(os.path.join(basename, "full.xml"))
     assert [(t.id, t.options) for t in doc.getKeyPackages()] == \
         [(u'KID1', {
             'ipatokenotpkey': u'GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ',
             'ipatokennotafter': u'20060531000000Z',
             'ipatokennotbefore': u'20060501000000Z',
             'ipatokenserial': u'SerialNo-IssueNo',
             'ipatokentotpclockoffset': 60000,
             'ipatokenotpalgorithm': u'sha1',
             'ipatokenvendor': u'iana.dummy',
             'description': u'FriendlyName',
             'ipatokentotptimestep': 200,
             'ipatokenhotpcounter': 0,
             'ipatokenmodel': u'Model',
             'ipatokenotpdigits': 8,
             'type': u'hotp',
         })]
コード例 #17
0
 def test_invalid(self):
     nss.nss_init_nodb()
     try:
         PSKCDocument(os.path.join(basename, "pskc-invalid.xml"))
     except ValueError:  # File is invalid.
         pass
     else:
         assert False
     finally:
         nss.nss_shutdown()
コード例 #18
0
 def test_figure8(self):
     nss.nss_init_nodb()
     try:
         PSKCDocument(os.path.join(basename, "pskc-figure8.xml"))
     except NotImplementedError:  # X.509 is not supported.
         pass
     else:
         assert False
     finally:
         nss.nss_shutdown()
コード例 #19
0
 def test_figure7(self):
     nss.nss_init_nodb()
     try:
         doc = PSKCDocument(os.path.join(basename, "pskc-figure7.xml"))
         assert doc.keyname == "My Password 1"
         doc.setKey("qwerty")
         assert [(t.id, t.options) for t in doc.getKeyPackages()] == [
             (
                 u"123456",
                 {
                     "ipatokenotpkey": u"GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ",
                     "ipatokenvendor": u"TokenVendorAcme",
                     "ipatokenserial": u"987654321",
                     "ipatokenotpdigits": 8,
                     "type": u"hotp",
                 },
             )
         ]
     finally:
         nss.nss_shutdown()
コード例 #20
0
 def test_figure6(self):
     nss.nss_init_nodb()
     try:
         doc = PSKCDocument(os.path.join(basename, "pskc-figure6.xml"))
         assert doc.keyname == "Pre-shared-key"
         doc.setKey("12345678901234567890123456789012".decode("hex"))
         assert [(t.id, t.options) for t in doc.getKeyPackages()] == [
             (
                 u"12345678",
                 {
                     "ipatokenotpkey": u"GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ",
                     "ipatokenvendor": u"Manufacturer",
                     "ipatokenserial": u"987654321",
                     "ipatokenhotpcounter": 0,
                     "ipatokenotpdigits": 8,
                     "type": u"hotp",
                 },
             )
         ]
     finally:
         nss.nss_shutdown()