code
stringlengths
26
870k
docstring
stringlengths
1
65.6k
func_name
stringlengths
1
194
language
stringclasses
1 value
repo
stringlengths
8
68
path
stringlengths
5
194
url
stringlengths
46
254
license
stringclasses
4 values
def test_backspace(self): """ When L{HistoricRecvLine} receives a BACKSPACE keystroke it deletes the character immediately before the cursor. """ kR = lambda ch: self.p.keystrokeReceived(ch, None) for ch in iterbytes(b'xyz'): kR(ch) self.assertEqual(self.p.currentLineBuffer(), (b'xyz', b'')) kR(self.pt.BACKSPACE) self.assertEqual(self.p.currentLineBuffer(), (b'xy', b'')) kR(self.pt.LEFT_ARROW) kR(self.pt.BACKSPACE) self.assertEqual(self.p.currentLineBuffer(), (b'', b'y')) kR(self.pt.BACKSPACE) self.assertEqual(self.p.currentLineBuffer(), (b'', b'y'))
When L{HistoricRecvLine} receives a BACKSPACE keystroke it deletes the character immediately before the cursor.
test_backspace
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_recvline.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_recvline.py
MIT
def test_delete(self): """ When L{HistoricRecvLine} receives a DELETE keystroke, it delets the character immediately after the cursor. """ kR = lambda ch: self.p.keystrokeReceived(ch, None) for ch in iterbytes(b'xyz'): kR(ch) self.assertEqual(self.p.currentLineBuffer(), (b'xyz', b'')) kR(self.pt.DELETE) self.assertEqual(self.p.currentLineBuffer(), (b'xyz', b'')) kR(self.pt.LEFT_ARROW) kR(self.pt.DELETE) self.assertEqual(self.p.currentLineBuffer(), (b'xy', b'')) kR(self.pt.LEFT_ARROW) kR(self.pt.DELETE) self.assertEqual(self.p.currentLineBuffer(), (b'x', b'')) kR(self.pt.LEFT_ARROW) kR(self.pt.DELETE) self.assertEqual(self.p.currentLineBuffer(), (b'', b'')) kR(self.pt.DELETE) self.assertEqual(self.p.currentLineBuffer(), (b'', b''))
When L{HistoricRecvLine} receives a DELETE keystroke, it delets the character immediately after the cursor.
test_delete
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_recvline.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_recvline.py
MIT
def test_insert(self): """ When not in INSERT mode, L{HistoricRecvLine} inserts the typed character at the cursor before the next character. """ kR = lambda ch: self.p.keystrokeReceived(ch, None) for ch in iterbytes(b'xyz'): kR(ch) kR(self.pt.LEFT_ARROW) kR(b'A') self.assertEqual(self.p.currentLineBuffer(), (b'xyA', b'z')) kR(self.pt.LEFT_ARROW) kR(b'B') self.assertEqual(self.p.currentLineBuffer(), (b'xyB', b'Az'))
When not in INSERT mode, L{HistoricRecvLine} inserts the typed character at the cursor before the next character.
test_insert
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_recvline.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_recvline.py
MIT
def test_typeover(self): """ When in INSERT mode and upon receiving a keystroke with a printable character, L{HistoricRecvLine} replaces the character at the cursor with the typed character rather than inserting before. Ah, the ironies of INSERT mode. """ kR = lambda ch: self.p.keystrokeReceived(ch, None) for ch in iterbytes(b'xyz'): kR(ch) kR(self.pt.INSERT) kR(self.pt.LEFT_ARROW) kR(b'A') self.assertEqual(self.p.currentLineBuffer(), (b'xyA', b'')) kR(self.pt.LEFT_ARROW) kR(b'B') self.assertEqual(self.p.currentLineBuffer(), (b'xyB', b''))
When in INSERT mode and upon receiving a keystroke with a printable character, L{HistoricRecvLine} replaces the character at the cursor with the typed character rather than inserting before. Ah, the ironies of INSERT mode.
test_typeover
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_recvline.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_recvline.py
MIT
def test_unprintableCharacters(self): """ When L{HistoricRecvLine} receives a keystroke for an unprintable function key with no assigned behavior, the line buffer is unmodified. """ kR = lambda ch: self.p.keystrokeReceived(ch, None) pt = self.pt for ch in (pt.F1, pt.F2, pt.F3, pt.F4, pt.F5, pt.F6, pt.F7, pt.F8, pt.F9, pt.F10, pt.F11, pt.F12, pt.PGUP, pt.PGDN): kR(ch) self.assertEqual(self.p.currentLineBuffer(), (b'', b''))
When L{HistoricRecvLine} receives a keystroke for an unprintable function key with no assigned behavior, the line buffer is unmodified.
test_unprintableCharacters
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_recvline.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_recvline.py
MIT
def test_DownArrowToPartialLineInHistory(self): """ Pressing down arrow to visit an entry that was added to the history by pressing the up arrow instead of return does not raise a L{TypeError}. @see: U{http://twistedmatrix.com/trac/ticket/9031} @return: A L{defer.Deferred} that fires when C{b"done"} is echoed back. """ return self._trivialTest( b"first line\n" + b"partial line" + up + down + b"\ndone", [b">>> first line", b"first line", b">>> partial line", b"partial line", b">>> done"])
Pressing down arrow to visit an entry that was added to the history by pressing the up arrow instead of return does not raise a L{TypeError}. @see: U{http://twistedmatrix.com/trac/ticket/9031} @return: A L{defer.Deferred} that fires when C{b"done"} is echoed back.
test_DownArrowToPartialLineInHistory
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_recvline.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_recvline.py
MIT
def test_invalidSequence(self): """ Initializing a L{recvline.TransportSequence} with no args raises an assertion. """ self.assertRaises(AssertionError, recvline.TransportSequence)
Initializing a L{recvline.TransportSequence} with no args raises an assertion.
test_invalidSequence
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_recvline.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_recvline.py
MIT
def test_size(self): """ The L{keys.Key.size} method returns the size of key object in bits. """ self.assertEqual(keys.Key(self.rsaObj).size(), 2048) self.assertEqual(keys.Key(self.dsaObj).size(), 1024) self.assertEqual(keys.Key(self.ecObj).size(), 256) self.assertEqual(keys.Key(self.ecObj384).size(), 384) self.assertEqual(keys.Key(self.ecObj521).size(), 521)
The L{keys.Key.size} method returns the size of key object in bits.
test_size
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
MIT
def test__guessStringType(self): """ Test that the _guessStringType method guesses string types correctly. """ self.assertEqual( keys.Key._guessStringType(keydata.publicRSA_openssh), 'public_openssh') self.assertEqual( keys.Key._guessStringType(keydata.publicDSA_openssh), 'public_openssh') self.assertEqual( keys.Key._guessStringType(keydata.publicECDSA_openssh), 'public_openssh') self.assertEqual( keys.Key._guessStringType(keydata.privateRSA_openssh), 'private_openssh') self.assertEqual( keys.Key._guessStringType(keydata.privateRSA_openssh_new), 'private_openssh') self.assertEqual( keys.Key._guessStringType(keydata.privateDSA_openssh), 'private_openssh') self.assertEqual( keys.Key._guessStringType(keydata.privateDSA_openssh_new), 'private_openssh') self.assertEqual( keys.Key._guessStringType(keydata.privateECDSA_openssh), 'private_openssh') self.assertEqual( keys.Key._guessStringType(keydata.privateECDSA_openssh_new), 'private_openssh') self.assertEqual( keys.Key._guessStringType(keydata.publicRSA_lsh), 'public_lsh') self.assertEqual( keys.Key._guessStringType(keydata.publicDSA_lsh), 'public_lsh') self.assertEqual( keys.Key._guessStringType(keydata.privateRSA_lsh), 'private_lsh') self.assertEqual( keys.Key._guessStringType(keydata.privateDSA_lsh), 'private_lsh') self.assertEqual( keys.Key._guessStringType(keydata.privateRSA_agentv3), 'agentv3') self.assertEqual( keys.Key._guessStringType(keydata.privateDSA_agentv3), 'agentv3') self.assertEqual( keys.Key._guessStringType( b'\x00\x00\x00\x07ssh-rsa\x00\x00\x00\x01\x01'), 'blob') self.assertEqual( keys.Key._guessStringType( b'\x00\x00\x00\x07ssh-dss\x00\x00\x00\x01\x01'), 'blob') self.assertEqual(keys.Key._guessStringType(b'not a key'), None)
Test that the _guessStringType method guesses string types correctly.
test__guessStringType
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
MIT
def test_public(self): """ The L{keys.Key.public} method returns a public key for both public and private keys. """ # NB: This assumes that the private and public keys correspond # to each other. privateRSAKey = keys.Key.fromString(keydata.privateRSA_openssh) publicRSAKey = keys.Key.fromString(keydata.publicRSA_openssh) self.assertEqual(privateRSAKey.public(), publicRSAKey.public()) privateDSAKey = keys.Key.fromString(keydata.privateDSA_openssh) publicDSAKey = keys.Key.fromString(keydata.publicDSA_openssh) self.assertEqual(privateDSAKey.public(), publicDSAKey.public()) privateECDSAKey = keys.Key.fromString(keydata.privateECDSA_openssh) publicECDSAKey = keys.Key.fromString(keydata.publicECDSA_openssh) self.assertEqual(privateECDSAKey.public(), publicECDSAKey.public())
The L{keys.Key.public} method returns a public key for both public and private keys.
test_public
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
MIT
def test_isPublic(self): """ The L{keys.Key.isPublic} method returns True for public keys otherwise False. """ rsaKey = keys.Key.fromString(keydata.privateRSA_openssh) dsaKey = keys.Key.fromString(keydata.privateDSA_openssh) ecdsaKey = keys.Key.fromString(keydata.privateECDSA_openssh) self.assertTrue(rsaKey.public().isPublic()) self.assertFalse(rsaKey.isPublic()) self.assertTrue(dsaKey.public().isPublic()) self.assertFalse(dsaKey.isPublic()) self.assertTrue(ecdsaKey.public().isPublic()) self.assertFalse(ecdsaKey.isPublic())
The L{keys.Key.isPublic} method returns True for public keys otherwise False.
test_isPublic
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
MIT
def test_fromOpenSSH(self): """ Test that keys are correctly generated from OpenSSH strings. """ self._testPublicPrivateFromString(keydata.publicECDSA_openssh, keydata.privateECDSA_openssh, 'EC', keydata.ECDatanistp256) self._testPublicPrivateFromString(keydata.publicRSA_openssh, keydata.privateRSA_openssh, 'RSA', keydata.RSAData) self.assertEqual(keys.Key.fromString( keydata.privateRSA_openssh_encrypted, passphrase=b'encrypted'), keys.Key.fromString(keydata.privateRSA_openssh)) self.assertEqual(keys.Key.fromString( keydata.privateRSA_openssh_alternate), keys.Key.fromString(keydata.privateRSA_openssh)) self._testPublicPrivateFromString(keydata.publicDSA_openssh, keydata.privateDSA_openssh, 'DSA', keydata.DSAData)
Test that keys are correctly generated from OpenSSH strings.
test_fromOpenSSH
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
MIT
def test_fromOpenSSHErrors(self): """ Tests for invalid key types. """ badKey = b"""-----BEGIN FOO PRIVATE KEY----- MIGkAgEBBDAtAi7I8j73WCX20qUM5hhHwHuFzYWYYILs2Sh8UZ+awNkARZ/Fu2LU LLl5RtOQpbWgBwYFK4EEACKhZANiAATU17sA9P5FRwSknKcFsjjsk0+E3CeXPYX0 Tk/M0HK3PpWQWgrO8JdRHP9eFE9O/23P8BumwFt7F/AvPlCzVd35VfraFT0o4cCW G0RqpQ+np31aKmeJshkcYALEchnU+tQ= -----END EC PRIVATE KEY-----""" self.assertRaises(keys.BadKeyError, keys.Key._fromString_PRIVATE_OPENSSH, badKey, None)
Tests for invalid key types.
test_fromOpenSSHErrors
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
MIT
def test_fromOpenSSH_with_whitespace(self): """ If key strings have trailing whitespace, it should be ignored. """ # from bug #3391, since our test key data doesn't have # an issue with appended newlines privateDSAData = b"""-----BEGIN DSA PRIVATE KEY----- MIIBuwIBAAKBgQDylESNuc61jq2yatCzZbenlr9llG+p9LhIpOLUbXhhHcwC6hrh EZIdCKqTO0USLrGoP5uS9UHAUoeN62Z0KXXWTwOWGEQn/syyPzNJtnBorHpNUT9D Qzwl1yUa53NNgEctpo4NoEFOx8PuU6iFLyvgHCjNn2MsuGuzkZm7sI9ZpQIVAJiR 9dPc08KLdpJyRxz8T74b4FQRAoGAGBc4Z5Y6R/HZi7AYM/iNOM8su6hrk8ypkBwR a3Dbhzk97fuV3SF1SDrcQu4zF7c4CtH609N5nfZs2SUjLLGPWln83Ysb8qhh55Em AcHXuROrHS/sDsnqu8FQp86MaudrqMExCOYyVPE7jaBWW+/JWFbKCxmgOCSdViUJ esJpBFsCgYEA7+jtVvSt9yrwsS/YU1QGP5wRAiDYB+T5cK4HytzAqJKRdC5qS4zf C7R0eKcDHHLMYO39aPnCwXjscisnInEhYGNblTDyPyiyNxAOXuC8x7luTmwzMbNJ /ow0IqSj0VF72VJN9uSoPpFd4lLT0zN8v42RWja0M8ohWNf+YNJluPgCFE0PT4Vm SUrCyZXsNh6VXwjs3gKQ -----END DSA PRIVATE KEY-----""" self.assertEqual(keys.Key.fromString(privateDSAData), keys.Key.fromString(privateDSAData + b'\n'))
If key strings have trailing whitespace, it should be ignored.
test_fromOpenSSH_with_whitespace
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
MIT
def test_fromNewerOpenSSH(self): """ Newer versions of OpenSSH generate encrypted keys which have a longer IV than the older versions. These newer keys are also loaded. """ key = keys.Key.fromString(keydata.privateRSA_openssh_encrypted_aes, passphrase=b'testxp') self.assertEqual(key.type(), 'RSA') key2 = keys.Key.fromString( keydata.privateRSA_openssh_encrypted_aes + b'\n', passphrase=b'testxp') self.assertEqual(key, key2)
Newer versions of OpenSSH generate encrypted keys which have a longer IV than the older versions. These newer keys are also loaded.
test_fromNewerOpenSSH
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
MIT
def test_fromOpenSSH_v1_format(self): """ OpenSSH 6.5 introduced a newer "openssh-key-v1" private key format (made the default in OpenSSH 7.8). Loading keys in this format produces identical results to loading the same keys in the old PEM-based format. """ for old, new in ( (keydata.privateRSA_openssh, keydata.privateRSA_openssh_new), (keydata.privateDSA_openssh, keydata.privateDSA_openssh_new), (keydata.privateECDSA_openssh, keydata.privateECDSA_openssh_new), (keydata.privateECDSA_openssh384, keydata.privateECDSA_openssh384_new), (keydata.privateECDSA_openssh521, keydata.privateECDSA_openssh521_new)): self.assertEqual( keys.Key.fromString(new), keys.Key.fromString(old)) self.assertEqual( keys.Key.fromString( keydata.privateRSA_openssh_encrypted_new, passphrase=b'encrypted'), keys.Key.fromString( keydata.privateRSA_openssh_encrypted, passphrase=b'encrypted'))
OpenSSH 6.5 introduced a newer "openssh-key-v1" private key format (made the default in OpenSSH 7.8). Loading keys in this format produces identical results to loading the same keys in the old PEM-based format.
test_fromOpenSSH_v1_format
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
MIT
def test_fromOpenSSH_windows_line_endings(self): """ Test that keys are correctly generated from OpenSSH strings with Windows line endings. """ privateDSAData = b"""-----BEGIN DSA PRIVATE KEY----- MIIBuwIBAAKBgQDylESNuc61jq2yatCzZbenlr9llG+p9LhIpOLUbXhhHcwC6hrh EZIdCKqTO0USLrGoP5uS9UHAUoeN62Z0KXXWTwOWGEQn/syyPzNJtnBorHpNUT9D Qzwl1yUa53NNgEctpo4NoEFOx8PuU6iFLyvgHCjNn2MsuGuzkZm7sI9ZpQIVAJiR 9dPc08KLdpJyRxz8T74b4FQRAoGAGBc4Z5Y6R/HZi7AYM/iNOM8su6hrk8ypkBwR a3Dbhzk97fuV3SF1SDrcQu4zF7c4CtH609N5nfZs2SUjLLGPWln83Ysb8qhh55Em AcHXuROrHS/sDsnqu8FQp86MaudrqMExCOYyVPE7jaBWW+/JWFbKCxmgOCSdViUJ esJpBFsCgYEA7+jtVvSt9yrwsS/YU1QGP5wRAiDYB+T5cK4HytzAqJKRdC5qS4zf C7R0eKcDHHLMYO39aPnCwXjscisnInEhYGNblTDyPyiyNxAOXuC8x7luTmwzMbNJ /ow0IqSj0VF72VJN9uSoPpFd4lLT0zN8v42RWja0M8ohWNf+YNJluPgCFE0PT4Vm SUrCyZXsNh6VXwjs3gKQ -----END DSA PRIVATE KEY-----""" self.assertEqual( keys.Key.fromString(privateDSAData), keys.Key.fromString(privateDSAData.replace(b'\n', b'\r\n')))
Test that keys are correctly generated from OpenSSH strings with Windows line endings.
test_fromOpenSSH_windows_line_endings
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
MIT
def test_fromLSHPublicUnsupportedType(self): """ C{BadKeyError} exception is raised when public key has an unknown type. """ sexp = sexpy.pack([[b'public-key', [b'bad-key', [b'p', b'2']]]]) self.assertRaises( keys.BadKeyError, keys.Key.fromString, data=b'{' + base64.encodestring(sexp) + b'}', )
C{BadKeyError} exception is raised when public key has an unknown type.
test_fromLSHPublicUnsupportedType
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
MIT
def test_fromLSHPrivateUnsupportedType(self): """ C{BadKeyError} exception is raised when private key has an unknown type. """ sexp = sexpy.pack([[b'private-key', [b'bad-key', [b'p', b'2']]]]) self.assertRaises( keys.BadKeyError, keys.Key.fromString, sexp, )
C{BadKeyError} exception is raised when private key has an unknown type.
test_fromLSHPrivateUnsupportedType
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
MIT
def test_fromLSHRSA(self): """ RSA public and private keys can be generated from a LSH strings. """ self._testPublicPrivateFromString( keydata.publicRSA_lsh, keydata.privateRSA_lsh, 'RSA', keydata.RSAData, )
RSA public and private keys can be generated from a LSH strings.
test_fromLSHRSA
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
MIT
def test_fromLSHDSA(self): """ DSA public and private key can be generated from LSHs. """ self._testPublicPrivateFromString( keydata.publicDSA_lsh, keydata.privateDSA_lsh, 'DSA', keydata.DSAData, )
DSA public and private key can be generated from LSHs.
test_fromLSHDSA
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
MIT
def test_fromAgentv3(self): """ Test that keys are correctly generated from Agent v3 strings. """ self._testPrivateFromString(keydata.privateRSA_agentv3, 'RSA', keydata.RSAData) self._testPrivateFromString(keydata.privateDSA_agentv3, 'DSA', keydata.DSAData) self.assertRaises(keys.BadKeyError, keys.Key.fromString, b'\x00\x00\x00\x07ssh-foo'+ b'\x00\x00\x00\x01\x01'*5)
Test that keys are correctly generated from Agent v3 strings.
test_fromAgentv3
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
MIT
def test_fromStringErrors(self): """ keys.Key.fromString should raise BadKeyError when the key is invalid. """ self.assertRaises(keys.BadKeyError, keys.Key.fromString, b'') # no key data with a bad key type self.assertRaises(keys.BadKeyError, keys.Key.fromString, b'', 'bad_type') # trying to decrypt a key which doesn't support encryption self.assertRaises(keys.BadKeyError, keys.Key.fromString, keydata.publicRSA_lsh, passphrase = b'unencrypted') # trying to decrypt a key with the wrong passphrase self.assertRaises(keys.EncryptedKeyError, keys.Key.fromString, keys.Key(self.rsaObj).toString('openssh', b'encrypted')) # key with no key data self.assertRaises(keys.BadKeyError, keys.Key.fromString, b'-----BEGIN RSA KEY-----\nwA==\n') # key with invalid DEK Info self.assertRaises( keys.BadKeyError, keys.Key.fromString, b"""-----BEGIN ENCRYPTED RSA KEY----- Proc-Type: 4,ENCRYPTED DEK-Info: weird type 4Ed/a9OgJWHJsne7yOGWeWMzHYKsxuP9w1v0aYcp+puS75wvhHLiUnNwxz0KDi6n T3YkKLBsoCWS68ApR2J9yeQ6R+EyS+UQDrO9nwqo3DB5BT3Ggt8S1wE7vjNLQD0H g/SJnlqwsECNhh8aAx+Ag0m3ZKOZiRD5mCkcDQsZET7URSmFytDKOjhFn3u6ZFVB sXrfpYc6TJtOQlHd/52JB6aAbjt6afSv955Z7enIi+5yEJ5y7oYQTaE5zrFMP7N5 9LbfJFlKXxEddy/DErRLxEjmC+t4svHesoJKc2jjjyNPiOoGGF3kJXea62vsjdNV gMK5Eged3TBVIk2dv8rtJUvyFeCUtjQ1UJZIebScRR47KrbsIpCmU8I4/uHWm5hW 0mOwvdx1L/mqx/BHqVU9Dw2COhOdLbFxlFI92chkovkmNk4P48ziyVnpm7ME22sE vfCMsyirdqB1mrL4CSM7FXONv+CgfBfeYVkYW8RfJac9U1L/O+JNn7yee414O/rS hRYw4UdWnH6Gg6niklVKWNY0ZwUZC8zgm2iqy8YCYuneS37jC+OEKP+/s6HSKuqk 2bzcl3/TcZXNSM815hnFRpz0anuyAsvwPNRyvxG2/DacJHL1f6luV4B0o6W410yf qXQx01DLo7nuyhJqoH3UGCyyXB+/QUs0mbG2PAEn3f5dVs31JMdbt+PrxURXXjKk 4cexpUcIpqqlfpIRe3RD0sDVbH4OXsGhi2kiTfPZu7mgyFxKopRbn1KwU1qKinfY EU9O4PoTak/tPT+5jFNhaP+HrURoi/pU8EAUNSktl7xAkHYwkN/9Cm7DeBghgf3n 8+tyCGYDsB5utPD0/Xe9yx0Qhc/kMm4xIyQDyA937dk3mUvLC9vulnAP8I+Izim0 fZ182+D1bWwykoD0997mUHG/AUChWR01V1OLwRyPv2wUtiS8VNG76Y2aqKlgqP1P V+IvIEqR4ERvSBVFzXNF8Y6j/sVxo8+aZw+d0L1Ns/R55deErGg3B8i/2EqGd3r+ 0jps9BqFHHWW87n3VyEB3jWCMj8Vi2EJIfa/7pSaViFIQn8LiBLf+zxG5LTOToK5 xkN42fReDcqi3UNfKNGnv4dsplyTR2hyx65lsj4bRKDGLKOuB1y7iB0AGb0LtcAI dcsVlcCeUquDXtqKvRnwfIMg+ZunyjqHBhj3qgRgbXbT6zjaSdNnih569aTg0Vup VykzZ7+n/KVcGLmvX0NesdoI7TKbq4TnEIOynuG5Sf+2GpARO5bjcWKSZeN/Ybgk gccf8Cqf6XWqiwlWd0B7BR3SymeHIaSymC45wmbgdstrbk7Ppa2Tp9AZku8M2Y7c 8mY9b+onK075/ypiwBm4L4GRNTFLnoNQJXx0OSl4FNRWsn6ztbD+jZhu8Seu10Jw SEJVJ+gmTKdRLYORJKyqhDet6g7kAxs4EoJ25WsOnX5nNr00rit+NkMPA7xbJT+7 CfI51GQLw7pUPeO2WNt6yZO/YkzZrqvTj5FEwybkUyBv7L0gkqu9wjfDdUw0fVHE xEm4DxjEoaIp8dW/JOzXQ2EF+WaSOgdYsw3Ac+rnnjnNptCdOEDGP6QBkt+oXj4P -----END RSA PRIVATE KEY-----""", passphrase='encrypted') # key with invalid encryption type self.assertRaises( keys.BadKeyError, keys.Key.fromString, b"""-----BEGIN ENCRYPTED RSA KEY----- Proc-Type: 4,ENCRYPTED DEK-Info: FOO-123-BAR,01234567 4Ed/a9OgJWHJsne7yOGWeWMzHYKsxuP9w1v0aYcp+puS75wvhHLiUnNwxz0KDi6n T3YkKLBsoCWS68ApR2J9yeQ6R+EyS+UQDrO9nwqo3DB5BT3Ggt8S1wE7vjNLQD0H g/SJnlqwsECNhh8aAx+Ag0m3ZKOZiRD5mCkcDQsZET7URSmFytDKOjhFn3u6ZFVB sXrfpYc6TJtOQlHd/52JB6aAbjt6afSv955Z7enIi+5yEJ5y7oYQTaE5zrFMP7N5 9LbfJFlKXxEddy/DErRLxEjmC+t4svHesoJKc2jjjyNPiOoGGF3kJXea62vsjdNV gMK5Eged3TBVIk2dv8rtJUvyFeCUtjQ1UJZIebScRR47KrbsIpCmU8I4/uHWm5hW 0mOwvdx1L/mqx/BHqVU9Dw2COhOdLbFxlFI92chkovkmNk4P48ziyVnpm7ME22sE vfCMsyirdqB1mrL4CSM7FXONv+CgfBfeYVkYW8RfJac9U1L/O+JNn7yee414O/rS hRYw4UdWnH6Gg6niklVKWNY0ZwUZC8zgm2iqy8YCYuneS37jC+OEKP+/s6HSKuqk 2bzcl3/TcZXNSM815hnFRpz0anuyAsvwPNRyvxG2/DacJHL1f6luV4B0o6W410yf qXQx01DLo7nuyhJqoH3UGCyyXB+/QUs0mbG2PAEn3f5dVs31JMdbt+PrxURXXjKk 4cexpUcIpqqlfpIRe3RD0sDVbH4OXsGhi2kiTfPZu7mgyFxKopRbn1KwU1qKinfY EU9O4PoTak/tPT+5jFNhaP+HrURoi/pU8EAUNSktl7xAkHYwkN/9Cm7DeBghgf3n 8+tyCGYDsB5utPD0/Xe9yx0Qhc/kMm4xIyQDyA937dk3mUvLC9vulnAP8I+Izim0 fZ182+D1bWwykoD0997mUHG/AUChWR01V1OLwRyPv2wUtiS8VNG76Y2aqKlgqP1P V+IvIEqR4ERvSBVFzXNF8Y6j/sVxo8+aZw+d0L1Ns/R55deErGg3B8i/2EqGd3r+ 0jps9BqFHHWW87n3VyEB3jWCMj8Vi2EJIfa/7pSaViFIQn8LiBLf+zxG5LTOToK5 xkN42fReDcqi3UNfKNGnv4dsplyTR2hyx65lsj4bRKDGLKOuB1y7iB0AGb0LtcAI dcsVlcCeUquDXtqKvRnwfIMg+ZunyjqHBhj3qgRgbXbT6zjaSdNnih569aTg0Vup VykzZ7+n/KVcGLmvX0NesdoI7TKbq4TnEIOynuG5Sf+2GpARO5bjcWKSZeN/Ybgk gccf8Cqf6XWqiwlWd0B7BR3SymeHIaSymC45wmbgdstrbk7Ppa2Tp9AZku8M2Y7c 8mY9b+onK075/ypiwBm4L4GRNTFLnoNQJXx0OSl4FNRWsn6ztbD+jZhu8Seu10Jw SEJVJ+gmTKdRLYORJKyqhDet6g7kAxs4EoJ25WsOnX5nNr00rit+NkMPA7xbJT+7 CfI51GQLw7pUPeO2WNt6yZO/YkzZrqvTj5FEwybkUyBv7L0gkqu9wjfDdUw0fVHE xEm4DxjEoaIp8dW/JOzXQ2EF+WaSOgdYsw3Ac+rnnjnNptCdOEDGP6QBkt+oXj4P -----END RSA PRIVATE KEY-----""", passphrase='encrypted') # key with bad IV (AES) self.assertRaises( keys.BadKeyError, keys.Key.fromString, b"""-----BEGIN ENCRYPTED RSA KEY----- Proc-Type: 4,ENCRYPTED DEK-Info: AES-128-CBC,01234 4Ed/a9OgJWHJsne7yOGWeWMzHYKsxuP9w1v0aYcp+puS75wvhHLiUnNwxz0KDi6n T3YkKLBsoCWS68ApR2J9yeQ6R+EyS+UQDrO9nwqo3DB5BT3Ggt8S1wE7vjNLQD0H g/SJnlqwsECNhh8aAx+Ag0m3ZKOZiRD5mCkcDQsZET7URSmFytDKOjhFn3u6ZFVB sXrfpYc6TJtOQlHd/52JB6aAbjt6afSv955Z7enIi+5yEJ5y7oYQTaE5zrFMP7N5 9LbfJFlKXxEddy/DErRLxEjmC+t4svHesoJKc2jjjyNPiOoGGF3kJXea62vsjdNV gMK5Eged3TBVIk2dv8rtJUvyFeCUtjQ1UJZIebScRR47KrbsIpCmU8I4/uHWm5hW 0mOwvdx1L/mqx/BHqVU9Dw2COhOdLbFxlFI92chkovkmNk4P48ziyVnpm7ME22sE vfCMsyirdqB1mrL4CSM7FXONv+CgfBfeYVkYW8RfJac9U1L/O+JNn7yee414O/rS hRYw4UdWnH6Gg6niklVKWNY0ZwUZC8zgm2iqy8YCYuneS37jC+OEKP+/s6HSKuqk 2bzcl3/TcZXNSM815hnFRpz0anuyAsvwPNRyvxG2/DacJHL1f6luV4B0o6W410yf qXQx01DLo7nuyhJqoH3UGCyyXB+/QUs0mbG2PAEn3f5dVs31JMdbt+PrxURXXjKk 4cexpUcIpqqlfpIRe3RD0sDVbH4OXsGhi2kiTfPZu7mgyFxKopRbn1KwU1qKinfY EU9O4PoTak/tPT+5jFNhaP+HrURoi/pU8EAUNSktl7xAkHYwkN/9Cm7DeBghgf3n 8+tyCGYDsB5utPD0/Xe9yx0Qhc/kMm4xIyQDyA937dk3mUvLC9vulnAP8I+Izim0 fZ182+D1bWwykoD0997mUHG/AUChWR01V1OLwRyPv2wUtiS8VNG76Y2aqKlgqP1P V+IvIEqR4ERvSBVFzXNF8Y6j/sVxo8+aZw+d0L1Ns/R55deErGg3B8i/2EqGd3r+ 0jps9BqFHHWW87n3VyEB3jWCMj8Vi2EJIfa/7pSaViFIQn8LiBLf+zxG5LTOToK5 xkN42fReDcqi3UNfKNGnv4dsplyTR2hyx65lsj4bRKDGLKOuB1y7iB0AGb0LtcAI dcsVlcCeUquDXtqKvRnwfIMg+ZunyjqHBhj3qgRgbXbT6zjaSdNnih569aTg0Vup VykzZ7+n/KVcGLmvX0NesdoI7TKbq4TnEIOynuG5Sf+2GpARO5bjcWKSZeN/Ybgk gccf8Cqf6XWqiwlWd0B7BR3SymeHIaSymC45wmbgdstrbk7Ppa2Tp9AZku8M2Y7c 8mY9b+onK075/ypiwBm4L4GRNTFLnoNQJXx0OSl4FNRWsn6ztbD+jZhu8Seu10Jw SEJVJ+gmTKdRLYORJKyqhDet6g7kAxs4EoJ25WsOnX5nNr00rit+NkMPA7xbJT+7 CfI51GQLw7pUPeO2WNt6yZO/YkzZrqvTj5FEwybkUyBv7L0gkqu9wjfDdUw0fVHE xEm4DxjEoaIp8dW/JOzXQ2EF+WaSOgdYsw3Ac+rnnjnNptCdOEDGP6QBkt+oXj4P -----END RSA PRIVATE KEY-----""", passphrase='encrypted') # key with bad IV (DES3) self.assertRaises( keys.BadKeyError, keys.Key.fromString, b"""-----BEGIN ENCRYPTED RSA KEY----- Proc-Type: 4,ENCRYPTED DEK-Info: DES-EDE3-CBC,01234 4Ed/a9OgJWHJsne7yOGWeWMzHYKsxuP9w1v0aYcp+puS75wvhHLiUnNwxz0KDi6n T3YkKLBsoCWS68ApR2J9yeQ6R+EyS+UQDrO9nwqo3DB5BT3Ggt8S1wE7vjNLQD0H g/SJnlqwsECNhh8aAx+Ag0m3ZKOZiRD5mCkcDQsZET7URSmFytDKOjhFn3u6ZFVB sXrfpYc6TJtOQlHd/52JB6aAbjt6afSv955Z7enIi+5yEJ5y7oYQTaE5zrFMP7N5 9LbfJFlKXxEddy/DErRLxEjmC+t4svHesoJKc2jjjyNPiOoGGF3kJXea62vsjdNV gMK5Eged3TBVIk2dv8rtJUvyFeCUtjQ1UJZIebScRR47KrbsIpCmU8I4/uHWm5hW 0mOwvdx1L/mqx/BHqVU9Dw2COhOdLbFxlFI92chkovkmNk4P48ziyVnpm7ME22sE vfCMsyirdqB1mrL4CSM7FXONv+CgfBfeYVkYW8RfJac9U1L/O+JNn7yee414O/rS hRYw4UdWnH6Gg6niklVKWNY0ZwUZC8zgm2iqy8YCYuneS37jC+OEKP+/s6HSKuqk 2bzcl3/TcZXNSM815hnFRpz0anuyAsvwPNRyvxG2/DacJHL1f6luV4B0o6W410yf qXQx01DLo7nuyhJqoH3UGCyyXB+/QUs0mbG2PAEn3f5dVs31JMdbt+PrxURXXjKk 4cexpUcIpqqlfpIRe3RD0sDVbH4OXsGhi2kiTfPZu7mgyFxKopRbn1KwU1qKinfY EU9O4PoTak/tPT+5jFNhaP+HrURoi/pU8EAUNSktl7xAkHYwkN/9Cm7DeBghgf3n 8+tyCGYDsB5utPD0/Xe9yx0Qhc/kMm4xIyQDyA937dk3mUvLC9vulnAP8I+Izim0 fZ182+D1bWwykoD0997mUHG/AUChWR01V1OLwRyPv2wUtiS8VNG76Y2aqKlgqP1P V+IvIEqR4ERvSBVFzXNF8Y6j/sVxo8+aZw+d0L1Ns/R55deErGg3B8i/2EqGd3r+ 0jps9BqFHHWW87n3VyEB3jWCMj8Vi2EJIfa/7pSaViFIQn8LiBLf+zxG5LTOToK5 xkN42fReDcqi3UNfKNGnv4dsplyTR2hyx65lsj4bRKDGLKOuB1y7iB0AGb0LtcAI dcsVlcCeUquDXtqKvRnwfIMg+ZunyjqHBhj3qgRgbXbT6zjaSdNnih569aTg0Vup VykzZ7+n/KVcGLmvX0NesdoI7TKbq4TnEIOynuG5Sf+2GpARO5bjcWKSZeN/Ybgk gccf8Cqf6XWqiwlWd0B7BR3SymeHIaSymC45wmbgdstrbk7Ppa2Tp9AZku8M2Y7c 8mY9b+onK075/ypiwBm4L4GRNTFLnoNQJXx0OSl4FNRWsn6ztbD+jZhu8Seu10Jw SEJVJ+gmTKdRLYORJKyqhDet6g7kAxs4EoJ25WsOnX5nNr00rit+NkMPA7xbJT+7 CfI51GQLw7pUPeO2WNt6yZO/YkzZrqvTj5FEwybkUyBv7L0gkqu9wjfDdUw0fVHE xEm4DxjEoaIp8dW/JOzXQ2EF+WaSOgdYsw3Ac+rnnjnNptCdOEDGP6QBkt+oXj4P -----END RSA PRIVATE KEY-----""", passphrase='encrypted')
keys.Key.fromString should raise BadKeyError when the key is invalid.
test_fromStringErrors
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
MIT
def test_fromFile(self): """ Test that fromFile works correctly. """ self.assertEqual(keys.Key.fromFile(self.keyFile), keys.Key.fromString(keydata.privateRSA_lsh)) self.assertRaises(keys.BadKeyError, keys.Key.fromFile, self.keyFile, 'bad_type') self.assertRaises(keys.BadKeyError, keys.Key.fromFile, self.keyFile, passphrase='unencrypted')
Test that fromFile works correctly.
test_fromFile
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
MIT
def test_init(self): """ Test that the PublicKey object is initialized correctly. """ obj = keys.Key._fromRSAComponents(n=long(5), e=long(3))._keyObject key = keys.Key(obj) self.assertEqual(key._keyObject, obj)
Test that the PublicKey object is initialized correctly.
test_init
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
MIT
def test_equal(self): """ Test that Key objects are compared correctly. """ rsa1 = keys.Key(self.rsaObj) rsa2 = keys.Key(self.rsaObj) rsa3 = keys.Key( keys.Key._fromRSAComponents(n=long(5), e=long(3))._keyObject) dsa = keys.Key(self.dsaObj) self.assertTrue(rsa1 == rsa2) self.assertFalse(rsa1 == rsa3) self.assertFalse(rsa1 == dsa) self.assertFalse(rsa1 == object) self.assertFalse(rsa1 == None)
Test that Key objects are compared correctly.
test_equal
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
MIT
def test_notEqual(self): """ Test that Key objects are not-compared correctly. """ rsa1 = keys.Key(self.rsaObj) rsa2 = keys.Key(self.rsaObj) rsa3 = keys.Key( keys.Key._fromRSAComponents(n=long(5), e=long(3))._keyObject) dsa = keys.Key(self.dsaObj) self.assertFalse(rsa1 != rsa2) self.assertTrue(rsa1 != rsa3) self.assertTrue(rsa1 != dsa) self.assertTrue(rsa1 != object) self.assertTrue(rsa1 != None)
Test that Key objects are not-compared correctly.
test_notEqual
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
MIT
def test_dataError(self): """ The L{keys.Key.data} method raises RuntimeError for bad keys. """ badKey = keys.Key(b'') self.assertRaises(RuntimeError, badKey.data)
The L{keys.Key.data} method raises RuntimeError for bad keys.
test_dataError
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
MIT
def test_fingerprintdefault(self): """ Test that the fingerprint method returns fingerprint in L{FingerprintFormats.MD5-HEX} format by default. """ self.assertEqual(keys.Key(self.rsaObj).fingerprint(), '85:25:04:32:58:55:96:9f:57:ee:fb:a8:1a:ea:69:da') self.assertEqual(keys.Key(self.dsaObj).fingerprint(), '63:15:b3:0e:e6:4f:50:de:91:48:3d:01:6b:b3:13:c1')
Test that the fingerprint method returns fingerprint in L{FingerprintFormats.MD5-HEX} format by default.
test_fingerprintdefault
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
MIT
def test_fingerprint_md5_hex(self): """ fingerprint method generates key fingerprint in L{FingerprintFormats.MD5-HEX} format if explicitly specified. """ self.assertEqual( keys.Key(self.rsaObj).fingerprint( keys.FingerprintFormats.MD5_HEX), '85:25:04:32:58:55:96:9f:57:ee:fb:a8:1a:ea:69:da') self.assertEqual( keys.Key(self.dsaObj).fingerprint( keys.FingerprintFormats.MD5_HEX), '63:15:b3:0e:e6:4f:50:de:91:48:3d:01:6b:b3:13:c1')
fingerprint method generates key fingerprint in L{FingerprintFormats.MD5-HEX} format if explicitly specified.
test_fingerprint_md5_hex
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
MIT
def test_fingerprintsha256(self): """ fingerprint method generates key fingerprint in L{FingerprintFormats.SHA256-BASE64} format if explicitly specified. """ self.assertEqual( keys.Key(self.rsaObj).fingerprint( keys.FingerprintFormats.SHA256_BASE64), 'FBTCOoknq0mHy+kpfnY9tDdcAJuWtCpuQMaV3EsvbUI=') self.assertEqual( keys.Key(self.dsaObj).fingerprint( keys.FingerprintFormats.SHA256_BASE64), 'Wz5o2YbKyxOEcJn1au/UaALSVruUzfz0vaLI1xiIGyY=')
fingerprint method generates key fingerprint in L{FingerprintFormats.SHA256-BASE64} format if explicitly specified.
test_fingerprintsha256
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
MIT
def test_fingerprintBadFormat(self): """ A C{BadFingerPrintFormat} error is raised when unsupported formats are requested. """ with self.assertRaises(keys.BadFingerPrintFormat) as em: keys.Key(self.rsaObj).fingerprint('sha256-base') self.assertEqual('Unsupported fingerprint format: sha256-base', em.exception.args[0])
A C{BadFingerPrintFormat} error is raised when unsupported formats are requested.
test_fingerprintBadFormat
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
MIT
def test_type(self): """ Test that the type method returns the correct type for an object. """ self.assertEqual(keys.Key(self.rsaObj).type(), 'RSA') self.assertEqual(keys.Key(self.rsaObj).sshType(), b'ssh-rsa') self.assertEqual(keys.Key(self.dsaObj).type(), 'DSA') self.assertEqual(keys.Key(self.dsaObj).sshType(), b'ssh-dss') self.assertEqual(keys.Key(self.ecObj).type(), 'EC') self.assertEqual(keys.Key(self.ecObj).sshType(), keydata.ECDatanistp256['curve']) self.assertRaises(RuntimeError, keys.Key(None).type) self.assertRaises(RuntimeError, keys.Key(None).sshType) self.assertRaises(RuntimeError, keys.Key(self).type) self.assertRaises(RuntimeError, keys.Key(self).sshType)
Test that the type method returns the correct type for an object.
test_type
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
MIT
def test_fromBlobUnsupportedType(self): """ A C{BadKeyError} error is raised whey the blob has an unsupported key type. """ badBlob = common.NS(b'ssh-bad') self.assertRaises(keys.BadKeyError, keys.Key.fromString, badBlob)
A C{BadKeyError} error is raised whey the blob has an unsupported key type.
test_fromBlobUnsupportedType
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
MIT
def test_fromBlobRSA(self): """ A public RSA key is correctly generated from a public key blob. """ rsaPublicData = { 'n': keydata.RSAData['n'], 'e': keydata.RSAData['e'], } rsaBlob = ( common.NS(b'ssh-rsa') + common.MP(rsaPublicData['e']) + common.MP(rsaPublicData['n']) ) rsaKey = keys.Key.fromString(rsaBlob) self.assertTrue(rsaKey.isPublic()) self.assertEqual(rsaPublicData, rsaKey.data())
A public RSA key is correctly generated from a public key blob.
test_fromBlobRSA
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
MIT
def test_fromBlobDSA(self): """ A public DSA key is correctly generated from a public key blob. """ dsaPublicData = { 'p': keydata.DSAData['p'], 'q': keydata.DSAData['q'], 'g': keydata.DSAData['g'], 'y': keydata.DSAData['y'], } dsaBlob = ( common.NS(b'ssh-dss') + common.MP(dsaPublicData['p']) + common.MP(dsaPublicData['q']) + common.MP(dsaPublicData['g']) + common.MP(dsaPublicData['y']) ) dsaKey = keys.Key.fromString(dsaBlob) self.assertTrue(dsaKey.isPublic()) self.assertEqual(dsaPublicData, dsaKey.data())
A public DSA key is correctly generated from a public key blob.
test_fromBlobDSA
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
MIT
def test_fromBlobECDSA(self): """ Key.fromString generates ECDSA keys from blobs. """ from cryptography import utils ecPublicData = { 'x': keydata.ECDatanistp256['x'], 'y': keydata.ECDatanistp256['y'], 'curve': keydata.ECDatanistp256['curve'] } ecblob = (common.NS(ecPublicData['curve']) + common.NS(ecPublicData['curve'][-8:]) + common.NS(b'\x04' + utils.int_to_bytes(ecPublicData['x'], 32) + utils.int_to_bytes(ecPublicData['y'], 32)) ) eckey = keys.Key.fromString(ecblob) self.assertTrue(eckey.isPublic()) self.assertEqual(ecPublicData, eckey.data())
Key.fromString generates ECDSA keys from blobs.
test_fromBlobECDSA
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
MIT
def test_fromPrivateBlobUnsupportedType(self): """ C{BadKeyError} is raised when loading a private blob with an unsupported type. """ badBlob = common.NS(b'ssh-bad') self.assertRaises( keys.BadKeyError, keys.Key._fromString_PRIVATE_BLOB, badBlob)
C{BadKeyError} is raised when loading a private blob with an unsupported type.
test_fromPrivateBlobUnsupportedType
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
MIT
def test_fromPrivateBlobRSA(self): """ A private RSA key is correctly generated from a private key blob. """ rsaBlob = ( common.NS(b'ssh-rsa') + common.MP(keydata.RSAData['n']) + common.MP(keydata.RSAData['e']) + common.MP(keydata.RSAData['d']) + common.MP(keydata.RSAData['u']) + common.MP(keydata.RSAData['p']) + common.MP(keydata.RSAData['q']) ) rsaKey = keys.Key._fromString_PRIVATE_BLOB(rsaBlob) self.assertFalse(rsaKey.isPublic()) self.assertEqual(keydata.RSAData, rsaKey.data())
A private RSA key is correctly generated from a private key blob.
test_fromPrivateBlobRSA
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
MIT
def test_fromPrivateBlobDSA(self): """ A private DSA key is correctly generated from a private key blob. """ dsaBlob = ( common.NS(b'ssh-dss') + common.MP(keydata.DSAData['p']) + common.MP(keydata.DSAData['q']) + common.MP(keydata.DSAData['g']) + common.MP(keydata.DSAData['y']) + common.MP(keydata.DSAData['x']) ) dsaKey = keys.Key._fromString_PRIVATE_BLOB(dsaBlob) self.assertFalse(dsaKey.isPublic()) self.assertEqual(keydata.DSAData, dsaKey.data())
A private DSA key is correctly generated from a private key blob.
test_fromPrivateBlobDSA
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
MIT
def test_fromPrivateBlobECDSA(self): """ A private EC key is correctly generated from a private key blob. """ from cryptography.hazmat.backends import default_backend from cryptography.hazmat.primitives.asymmetric import ec from cryptography.hazmat.primitives import serialization publicNumbers = ec.EllipticCurvePublicNumbers( x=keydata.ECDatanistp256['x'], y=keydata.ECDatanistp256['y'], curve=ec.SECP256R1()) ecblob = ( common.NS(keydata.ECDatanistp256['curve']) + common.NS(keydata.ECDatanistp256['curve'][-8:]) + common.NS(publicNumbers.public_key(default_backend()).public_bytes( serialization.Encoding.X962, serialization.PublicFormat.UncompressedPoint )) + common.MP(keydata.ECDatanistp256['privateValue']) ) eckey = keys.Key._fromString_PRIVATE_BLOB(ecblob) self.assertFalse(eckey.isPublic()) self.assertEqual(keydata.ECDatanistp256, eckey.data())
A private EC key is correctly generated from a private key blob.
test_fromPrivateBlobECDSA
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
MIT
def test_blobRSA(self): """ Return the over-the-wire SSH format of the RSA public key. """ self.assertEqual( keys.Key(self.rsaObj).blob(), common.NS(b'ssh-rsa') + common.MP(self.rsaObj.private_numbers().public_numbers.e) + common.MP(self.rsaObj.private_numbers().public_numbers.n) )
Return the over-the-wire SSH format of the RSA public key.
test_blobRSA
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
MIT
def test_blobDSA(self): """ Return the over-the-wire SSH format of the DSA public key. """ publicNumbers = self.dsaObj.private_numbers().public_numbers self.assertEqual( keys.Key(self.dsaObj).blob(), common.NS(b'ssh-dss') + common.MP(publicNumbers.parameter_numbers.p) + common.MP(publicNumbers.parameter_numbers.q) + common.MP(publicNumbers.parameter_numbers.g) + common.MP(publicNumbers.y) )
Return the over-the-wire SSH format of the DSA public key.
test_blobDSA
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
MIT
def test_blobEC(self): """ Return the over-the-wire SSH format of the EC public key. """ from cryptography import utils byteLength = (self.ecObj.curve.key_size + 7) // 8 self.assertEqual( keys.Key(self.ecObj).blob(), common.NS(keydata.ECDatanistp256['curve']) + common.NS(keydata.ECDatanistp256['curve'][-8:]) + common.NS(b'\x04' + utils.int_to_bytes( self.ecObj.private_numbers().public_numbers.x, byteLength) + utils.int_to_bytes( self.ecObj.private_numbers().public_numbers.y, byteLength)) )
Return the over-the-wire SSH format of the EC public key.
test_blobEC
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
MIT
def test_blobNoKey(self): """ C{RuntimeError} is raised when the blob is requested for a Key which is not wrapping anything. """ badKey = keys.Key(None) self.assertRaises(RuntimeError, badKey.blob)
C{RuntimeError} is raised when the blob is requested for a Key which is not wrapping anything.
test_blobNoKey
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
MIT
def test_privateBlobRSA(self): """ L{keys.Key.privateBlob} returns the SSH protocol-level format of an RSA private key. """ from cryptography.hazmat.primitives.asymmetric import rsa numbers = self.rsaObj.private_numbers() u = rsa.rsa_crt_iqmp(numbers.q, numbers.p) self.assertEqual( keys.Key(self.rsaObj).privateBlob(), common.NS(b'ssh-rsa') + common.MP(self.rsaObj.private_numbers().public_numbers.n) + common.MP(self.rsaObj.private_numbers().public_numbers.e) + common.MP(self.rsaObj.private_numbers().d) + common.MP(u) + common.MP(self.rsaObj.private_numbers().p) + common.MP(self.rsaObj.private_numbers().q) )
L{keys.Key.privateBlob} returns the SSH protocol-level format of an RSA private key.
test_privateBlobRSA
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
MIT
def test_privateBlobDSA(self): """ L{keys.Key.privateBlob} returns the SSH protocol-level format of a DSA private key. """ publicNumbers = self.dsaObj.private_numbers().public_numbers self.assertEqual( keys.Key(self.dsaObj).privateBlob(), common.NS(b'ssh-dss') + common.MP(publicNumbers.parameter_numbers.p) + common.MP(publicNumbers.parameter_numbers.q) + common.MP(publicNumbers.parameter_numbers.g) + common.MP(publicNumbers.y) + common.MP(self.dsaObj.private_numbers().x) )
L{keys.Key.privateBlob} returns the SSH protocol-level format of a DSA private key.
test_privateBlobDSA
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
MIT
def test_privateBlobEC(self): """ L{keys.Key.privateBlob} returns the SSH ptotocol-level format of EC private key. """ self.assertEqual( keys.Key(self.ecObj).privateBlob(), common.NS(keydata.ECDatanistp256['curve']) + common.MP(self.ecObj.private_numbers().public_numbers.x) + common.MP(self.ecObj.private_numbers().public_numbers.y) + common.MP(self.ecObj.private_numbers().private_value) )
L{keys.Key.privateBlob} returns the SSH ptotocol-level format of EC private key.
test_privateBlobEC
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
MIT
def test_privateBlobNoKeyObject(self): """ Raises L{RuntimeError} if the underlying key object does not exists. """ badKey = keys.Key(None) self.assertRaises(RuntimeError, badKey.privateBlob)
Raises L{RuntimeError} if the underlying key object does not exists.
test_privateBlobNoKeyObject
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
MIT
def test_toOpenSSHRSA(self): """ L{keys.Key.toString} serializes an RSA key in OpenSSH format. """ key = keys.Key.fromString(keydata.privateRSA_agentv3) self.assertEqual(key.toString('openssh'), keydata.privateRSA_openssh) self.assertEqual(key.toString('openssh', b'encrypted'), keydata.privateRSA_openssh_encrypted) self.assertEqual(key.public().toString('openssh'), keydata.publicRSA_openssh[:-8]) # no comment self.assertEqual(key.public().toString('openssh', b'comment'), keydata.publicRSA_openssh)
L{keys.Key.toString} serializes an RSA key in OpenSSH format.
test_toOpenSSHRSA
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
MIT
def test_toOpenSSHDSA(self): """ L{keys.Key.toString} serializes a DSA key in OpenSSH format. """ key = keys.Key.fromString(keydata.privateDSA_lsh) self.assertEqual(key.toString('openssh'), keydata.privateDSA_openssh) self.assertEqual(key.public().toString('openssh', b'comment'), keydata.publicDSA_openssh) self.assertEqual(key.public().toString('openssh'), keydata.publicDSA_openssh[:-8]) # no comment
L{keys.Key.toString} serializes a DSA key in OpenSSH format.
test_toOpenSSHDSA
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
MIT
def test_toOpenSSHECDSA(self): """ L{keys.Key.toString} serializes a ECDSA key in OpenSSH format. """ key = keys.Key.fromString(keydata.privateECDSA_openssh) self.assertEqual(key.public().toString('openssh', b'comment'), keydata.publicECDSA_openssh) self.assertEqual(key.public().toString('openssh'), keydata.publicECDSA_openssh[:-8]) # no comment
L{keys.Key.toString} serializes a ECDSA key in OpenSSH format.
test_toOpenSSHECDSA
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
MIT
def test_toLSHRSA(self): """ L{keys.Key.toString} serializes an RSA key in LSH format. """ key = keys.Key.fromString(keydata.privateRSA_openssh) self.assertEqual(key.toString('lsh'), keydata.privateRSA_lsh) self.assertEqual(key.public().toString('lsh'), keydata.publicRSA_lsh)
L{keys.Key.toString} serializes an RSA key in LSH format.
test_toLSHRSA
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
MIT
def test_toLSHDSA(self): """ L{keys.Key.toString} serializes a DSA key in LSH format. """ key = keys.Key.fromString(keydata.privateDSA_openssh) self.assertEqual(key.toString('lsh'), keydata.privateDSA_lsh) self.assertEqual(key.public().toString('lsh'), keydata.publicDSA_lsh)
L{keys.Key.toString} serializes a DSA key in LSH format.
test_toLSHDSA
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
MIT
def test_toAgentv3RSA(self): """ L{keys.Key.toString} serializes an RSA key in Agent v3 format. """ key = keys.Key.fromString(keydata.privateRSA_openssh) self.assertEqual(key.toString('agentv3'), keydata.privateRSA_agentv3)
L{keys.Key.toString} serializes an RSA key in Agent v3 format.
test_toAgentv3RSA
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
MIT
def test_toAgentv3DSA(self): """ L{keys.Key.toString} serializes a DSA key in Agent v3 format. """ key = keys.Key.fromString(keydata.privateDSA_openssh) self.assertEqual(key.toString('agentv3'), keydata.privateDSA_agentv3)
L{keys.Key.toString} serializes a DSA key in Agent v3 format.
test_toAgentv3DSA
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
MIT
def test_toStringErrors(self): """ L{keys.Key.toString} raises L{keys.BadKeyError} when passed an invalid format type. """ self.assertRaises(keys.BadKeyError, keys.Key(self.rsaObj).toString, 'bad_type')
L{keys.Key.toString} raises L{keys.BadKeyError} when passed an invalid format type.
test_toStringErrors
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
MIT
def test_signAndVerifyRSA(self): """ Signed data can be verified using RSA. """ data = b'some-data' key = keys.Key.fromString(keydata.privateRSA_openssh) signature = key.sign(data) self.assertTrue(key.public().verify(signature, data)) self.assertTrue(key.verify(signature, data))
Signed data can be verified using RSA.
test_signAndVerifyRSA
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
MIT
def test_signAndVerifyDSA(self): """ Signed data can be verified using DSA. """ data = b'some-data' key = keys.Key.fromString(keydata.privateDSA_openssh) signature = key.sign(data) self.assertTrue(key.public().verify(signature, data)) self.assertTrue(key.verify(signature, data))
Signed data can be verified using DSA.
test_signAndVerifyDSA
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
MIT
def test_signAndVerifyEC(self): """ Signed data can be verified using EC. """ data = b'some-data' key = keys.Key.fromString(keydata.privateECDSA_openssh) signature = key.sign(data) key384 = keys.Key.fromString(keydata.privateECDSA_openssh384) signature384 = key384.sign(data) key521 = keys.Key.fromString(keydata.privateECDSA_openssh521) signature521 = key521.sign(data) self.assertTrue(key.public().verify(signature, data)) self.assertTrue(key.verify(signature, data)) self.assertTrue(key384.public().verify(signature384, data)) self.assertTrue(key384.verify(signature384, data)) self.assertTrue(key521.public().verify(signature521, data)) self.assertTrue(key521.verify(signature521, data))
Signed data can be verified using EC.
test_signAndVerifyEC
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
MIT
def test_verifyRSA(self): """ A known-good RSA signature verifies successfully. """ key = keys.Key.fromString(keydata.publicRSA_openssh) self.assertTrue(key.verify(self.rsaSignature, b'')) self.assertFalse(key.verify(self.rsaSignature, b'a')) self.assertFalse(key.verify(self.dsaSignature, b''))
A known-good RSA signature verifies successfully.
test_verifyRSA
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
MIT
def test_verifyDSA(self): """ A known-good DSA signature verifies successfully. """ key = keys.Key.fromString(keydata.publicDSA_openssh) self.assertTrue(key.verify(self.dsaSignature, b'')) self.assertFalse(key.verify(self.dsaSignature, b'a')) self.assertFalse(key.verify(self.rsaSignature, b''))
A known-good DSA signature verifies successfully.
test_verifyDSA
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
MIT
def test_verifyDSANoPrefix(self): """ Some commercial SSH servers send DSA keys as 2 20-byte numbers; they are still verified as valid keys. """ key = keys.Key.fromString(keydata.publicDSA_openssh) self.assertTrue(key.verify(self.dsaSignature[-40:], b''))
Some commercial SSH servers send DSA keys as 2 20-byte numbers; they are still verified as valid keys.
test_verifyDSANoPrefix
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
MIT
def test_reprPrivateRSA(self): """ The repr of a L{keys.Key} contains all of the RSA components for an RSA private key. """ self.assertEqual(repr(keys.Key(self.rsaObj)),
The repr of a L{keys.Key} contains all of the RSA components for an RSA private key.
test_reprPrivateRSA
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
MIT
def test_reprPublicRSA(self): """ The repr of a L{keys.Key} contains all of the RSA components for an RSA public key. """ self.assertEqual(repr(keys.Key(self.rsaObj).public()),
The repr of a L{keys.Key} contains all of the RSA components for an RSA public key.
test_reprPublicRSA
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
MIT
def test_reprPublicECDSA(self): """ The repr of a L{keys.Key} contains all the OpenSSH format for an ECDSA public key. """ self.assertEqual(repr(keys.Key(self.ecObj).public()),
The repr of a L{keys.Key} contains all the OpenSSH format for an ECDSA public key.
test_reprPublicECDSA
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
MIT
def test_reprPrivateECDSA(self): """ The repr of a L{keys.Key} contains all the OpenSSH format for an ECDSA private key. """ self.assertEqual(repr(keys.Key(self.ecObj)),
The repr of a L{keys.Key} contains all the OpenSSH format for an ECDSA private key.
test_reprPrivateECDSA
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
MIT
def test_providedArguments(self): """ L{keys._getPersistentRSAKey} will put the key in C{directory}/C{filename}, with the key length of C{keySize}. """ tempDir = FilePath(self.mktemp()) keyFile = tempDir.child("mykey.pem") key = keys._getPersistentRSAKey(keyFile, keySize=512) self.assertEqual(key.size(), 512) self.assertTrue(keyFile.exists())
L{keys._getPersistentRSAKey} will put the key in C{directory}/C{filename}, with the key length of C{keySize}.
test_providedArguments
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
MIT
def test_noRegeneration(self): """ L{keys._getPersistentRSAKey} will not regenerate the key if the key already exists. """ tempDir = FilePath(self.mktemp()) keyFile = tempDir.child("mykey.pem") key = keys._getPersistentRSAKey(keyFile, keySize=512) self.assertEqual(key.size(), 512) self.assertTrue(keyFile.exists()) keyContent = keyFile.getContent() # Set the key size to 1024 bits. Since it exists already, it will find # the 512 bit key, and not generate a 1024 bit key. key = keys._getPersistentRSAKey(keyFile, keySize=1024) self.assertEqual(key.size(), 512) self.assertEqual(keyFile.getContent(), keyContent)
L{keys._getPersistentRSAKey} will not regenerate the key if the key already exists.
test_noRegeneration
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
MIT
def test_keySizeZero(self): """ If the key generated by L{keys.getPersistentRSAKey} is set to None the key size should then become 0. """ tempDir = FilePath(self.mktemp()) keyFile = tempDir.child("mykey.pem") key = keys._getPersistentRSAKey(keyFile, keySize=512) key._keyObject = None self.assertEqual( key.size(), 0)
If the key generated by L{keys.getPersistentRSAKey} is set to None the key size should then become 0.
test_keySizeZero
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_keys.py
MIT
def test_trivial(self): """ Using no formatting attributes produces no VT102 control sequences in the flattened output. """ self.assertEqual( text.assembleFormattedText(A.normal['Hello, world.']), 'Hello, world.')
Using no formatting attributes produces no VT102 control sequences in the flattened output.
test_trivial
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_text.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_text.py
MIT
def test_bold(self): """ The bold formatting attribute, L{A.bold}, emits the VT102 control sequence to enable bold when flattened. """ self.assertEqual( text.assembleFormattedText(A.bold['Hello, world.']), '\x1b[1mHello, world.')
The bold formatting attribute, L{A.bold}, emits the VT102 control sequence to enable bold when flattened.
test_bold
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_text.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_text.py
MIT
def test_underline(self): """ The underline formatting attribute, L{A.underline}, emits the VT102 control sequence to enable underlining when flattened. """ self.assertEqual( text.assembleFormattedText(A.underline['Hello, world.']), '\x1b[4mHello, world.')
The underline formatting attribute, L{A.underline}, emits the VT102 control sequence to enable underlining when flattened.
test_underline
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_text.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_text.py
MIT
def test_blink(self): """ The blink formatting attribute, L{A.blink}, emits the VT102 control sequence to enable blinking when flattened. """ self.assertEqual( text.assembleFormattedText(A.blink['Hello, world.']), '\x1b[5mHello, world.')
The blink formatting attribute, L{A.blink}, emits the VT102 control sequence to enable blinking when flattened.
test_blink
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_text.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_text.py
MIT
def test_reverseVideo(self): """ The reverse-video formatting attribute, L{A.reverseVideo}, emits the VT102 control sequence to enable reversed video when flattened. """ self.assertEqual( text.assembleFormattedText(A.reverseVideo['Hello, world.']), '\x1b[7mHello, world.')
The reverse-video formatting attribute, L{A.reverseVideo}, emits the VT102 control sequence to enable reversed video when flattened.
test_reverseVideo
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_text.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_text.py
MIT
def test_minus(self): """ Formatting attributes prefixed with a minus (C{-}) temporarily disable the prefixed attribute, emitting no VT102 control sequence to enable it in the flattened output. """ self.assertEqual( text.assembleFormattedText( A.bold[A.blink['Hello', -A.bold[' world'], '.']]), '\x1b[1;5mHello\x1b[0;5m world\x1b[1;5m.')
Formatting attributes prefixed with a minus (C{-}) temporarily disable the prefixed attribute, emitting no VT102 control sequence to enable it in the flattened output.
test_minus
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_text.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_text.py
MIT
def test_foreground(self): """ The foreground color formatting attribute, L{A.fg}, emits the VT102 control sequence to set the selected foreground color when flattened. """ self.assertEqual( text.assembleFormattedText( A.normal[A.fg.red['Hello, '], A.fg.green['world!']]), '\x1b[31mHello, \x1b[32mworld!')
The foreground color formatting attribute, L{A.fg}, emits the VT102 control sequence to set the selected foreground color when flattened.
test_foreground
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_text.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_text.py
MIT
def test_background(self): """ The background color formatting attribute, L{A.bg}, emits the VT102 control sequence to set the selected background color when flattened. """ self.assertEqual( text.assembleFormattedText( A.normal[A.bg.red['Hello, '], A.bg.green['world!']]), '\x1b[41mHello, \x1b[42mworld!')
The background color formatting attribute, L{A.bg}, emits the VT102 control sequence to set the selected background color when flattened.
test_background
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_text.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_text.py
MIT
def test_flattenDeprecated(self): """ L{twisted.conch.insults.text.flatten} emits a deprecation warning when imported or accessed. """ warningsShown = self.flushWarnings([self.test_flattenDeprecated]) self.assertEqual(len(warningsShown), 0) # Trigger the deprecation warning. text.flatten warningsShown = self.flushWarnings([self.test_flattenDeprecated]) self.assertEqual(len(warningsShown), 1) self.assertEqual(warningsShown[0]['category'], DeprecationWarning) self.assertEqual( warningsShown[0]['message'], 'twisted.conch.insults.text.flatten was deprecated in Twisted ' '13.1.0: Use twisted.conch.insults.text.assembleFormattedText ' 'instead.')
L{twisted.conch.insults.text.flatten} emits a deprecation warning when imported or accessed.
test_flattenDeprecated
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_text.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_text.py
MIT
def test_initialPrivateModes(self): """ Verify that only DEC Auto Wrap Mode (DECAWM) and DEC Text Cursor Enable Mode (DECTCEM) are initially in the Set Mode (SM) state. """ self.assertEqual( {privateModes.AUTO_WRAP: True, privateModes.CURSOR_MODE: True}, self.term.privateModes)
Verify that only DEC Auto Wrap Mode (DECAWM) and DEC Text Cursor Enable Mode (DECTCEM) are initially in the Set Mode (SM) state.
test_initialPrivateModes
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_helper.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_helper.py
MIT
def test_carriageReturn(self): """ C{"\r"} moves the cursor to the first column in the current row. """ self.term.cursorForward(5) self.term.cursorDown(3) self.assertEqual(self.term.reportCursorPosition(), (5, 3)) self.term.insertAtCursor(b"\r") self.assertEqual(self.term.reportCursorPosition(), (0, 3))
C{"\r"} moves the cursor to the first column in the current row.
test_carriageReturn
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_helper.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_helper.py
MIT
def test_linefeed(self): """ C{"\n"} moves the cursor to the next row without changing the column. """ self.term.cursorForward(5) self.assertEqual(self.term.reportCursorPosition(), (5, 0)) self.term.insertAtCursor(b"\n") self.assertEqual(self.term.reportCursorPosition(), (5, 1))
C{"\n"} moves the cursor to the next row without changing the column.
test_linefeed
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_helper.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_helper.py
MIT
def test_newline(self): """ C{write} transforms C{"\n"} into C{"\r\n"}. """ self.term.cursorForward(5) self.term.cursorDown(3) self.assertEqual(self.term.reportCursorPosition(), (5, 3)) self.term.write(b"\n") self.assertEqual(self.term.reportCursorPosition(), (0, 4))
C{write} transforms C{"\n"} into C{"\r\n"}.
test_newline
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_helper.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_helper.py
MIT
def test_setPrivateModes(self): """ Verify that L{helper.TerminalBuffer.setPrivateModes} changes the Set Mode (SM) state to "set" for the private modes it is passed. """ expected = self.term.privateModes.copy() self.term.setPrivateModes([privateModes.SCROLL, privateModes.SCREEN]) expected[privateModes.SCROLL] = True expected[privateModes.SCREEN] = True self.assertEqual(expected, self.term.privateModes)
Verify that L{helper.TerminalBuffer.setPrivateModes} changes the Set Mode (SM) state to "set" for the private modes it is passed.
test_setPrivateModes
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_helper.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_helper.py
MIT
def test_resetPrivateModes(self): """ Verify that L{helper.TerminalBuffer.resetPrivateModes} changes the Set Mode (SM) state to "reset" for the private modes it is passed. """ expected = self.term.privateModes.copy() self.term.resetPrivateModes([privateModes.AUTO_WRAP, privateModes.CURSOR_MODE]) del expected[privateModes.AUTO_WRAP] del expected[privateModes.CURSOR_MODE] self.assertEqual(expected, self.term.privateModes)
Verify that L{helper.TerminalBuffer.resetPrivateModes} changes the Set Mode (SM) state to "reset" for the private modes it is passed.
test_resetPrivateModes
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_helper.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_helper.py
MIT
def test_nextLine(self): """ C{nextLine} positions the cursor at the beginning of the row below the current row. """ self.term.nextLine() self.assertEqual(self.term.reportCursorPosition(), (0, 1)) self.term.cursorForward(5) self.assertEqual(self.term.reportCursorPosition(), (5, 1)) self.term.nextLine() self.assertEqual(self.term.reportCursorPosition(), (0, 2))
C{nextLine} positions the cursor at the beginning of the row below the current row.
test_nextLine
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_helper.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_helper.py
MIT
def test_equality(self): """ L{CharacterAttribute}s must have matching character attribute values (bold, blink, underline, etc) with the same values to be considered equal. """ self.assertEqual( helper.CharacterAttribute(), helper.CharacterAttribute()) self.assertEqual( helper.CharacterAttribute(), helper.CharacterAttribute(charset=G0)) self.assertEqual( helper.CharacterAttribute( bold=True, underline=True, blink=False, reverseVideo=True, foreground=helper.BLUE), helper.CharacterAttribute( bold=True, underline=True, blink=False, reverseVideo=True, foreground=helper.BLUE)) self.assertNotEqual( helper.CharacterAttribute(), helper.CharacterAttribute(charset=G1)) self.assertNotEqual( helper.CharacterAttribute(bold=True), helper.CharacterAttribute(bold=False))
L{CharacterAttribute}s must have matching character attribute values (bold, blink, underline, etc) with the same values to be considered equal.
test_equality
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_helper.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_helper.py
MIT
def test_wantOneDeprecated(self): """ L{twisted.conch.insults.helper.CharacterAttribute.wantOne} emits a deprecation warning when invoked. """ # Trigger the deprecation warning. helper._FormattingState().wantOne(bold=True) warningsShown = self.flushWarnings([self.test_wantOneDeprecated]) self.assertEqual(len(warningsShown), 1) self.assertEqual(warningsShown[0]['category'], DeprecationWarning) if _PY3: deprecatedClass = ( "twisted.conch.insults.helper._FormattingState.wantOne") else: deprecatedClass = "twisted.conch.insults.helper.wantOne" self.assertEqual( warningsShown[0]['message'], '%s was deprecated in Twisted 13.1.0' % (deprecatedClass))
L{twisted.conch.insults.helper.CharacterAttribute.wantOne} emits a deprecation warning when invoked.
test_wantOneDeprecated
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_helper.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_helper.py
MIT
def makeGetpass(*passphrases): """ Return a callable to patch C{getpass.getpass}. Yields a passphrase each time called. Use case is to provide an old, then new passphrase(s) as if requested interactively. @param passphrases: The list of passphrases returned, one per each call. @return: A callable to patch C{getpass.getpass}. """ passphrases = iter(passphrases) def fakeGetpass(_): return next(passphrases) return fakeGetpass
Return a callable to patch C{getpass.getpass}. Yields a passphrase each time called. Use case is to provide an old, then new passphrase(s) as if requested interactively. @param passphrases: The list of passphrases returned, one per each call. @return: A callable to patch C{getpass.getpass}.
makeGetpass
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_ckeygen.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_ckeygen.py
MIT
def setUp(self): """ Patch C{sys.stdout} so tests can make assertions about what's printed. """ if _PY3: self.stdout = StringIO() else: self.stdout = BytesIO() self.patch(sys, 'stdout', self.stdout)
Patch C{sys.stdout} so tests can make assertions about what's printed.
setUp
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_ckeygen.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_ckeygen.py
MIT
def test_enumrepresentation(self): """ L{enumrepresentation} takes a dictionary as input and returns a dictionary with its attributes changed to enum representation. """ options = enumrepresentation({'format': 'md5-hex'}) self.assertIs(options['format'], FingerprintFormats.MD5_HEX)
L{enumrepresentation} takes a dictionary as input and returns a dictionary with its attributes changed to enum representation.
test_enumrepresentation
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_ckeygen.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_ckeygen.py
MIT
def test_enumrepresentationsha256(self): """ Test for format L{FingerprintFormats.SHA256-BASE64}. """ options = enumrepresentation({'format': 'sha256-base64'}) self.assertIs(options['format'], FingerprintFormats.SHA256_BASE64)
Test for format L{FingerprintFormats.SHA256-BASE64}.
test_enumrepresentationsha256
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_ckeygen.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_ckeygen.py
MIT
def test_enumrepresentationBadFormat(self): """ Test for unsupported fingerprint format """ with self.assertRaises(BadFingerPrintFormat) as em: enumrepresentation({'format': 'sha-base64'}) self.assertEqual('Unsupported fingerprint format: sha-base64', em.exception.args[0])
Test for unsupported fingerprint format
test_enumrepresentationBadFormat
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_ckeygen.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_ckeygen.py
MIT
def test_printFingerprint(self): """ L{printFingerprint} writes a line to standard out giving the number of bits of the key, its fingerprint, and the basename of the file from it was read. """ filename = self.mktemp() FilePath(filename).setContent(publicRSA_openssh) printFingerprint({'filename': filename, 'format': 'md5-hex'}) self.assertEqual( self.stdout.getvalue(), '2048 85:25:04:32:58:55:96:9f:57:ee:fb:a8:1a:ea:69:da temp\n')
L{printFingerprint} writes a line to standard out giving the number of bits of the key, its fingerprint, and the basename of the file from it was read.
test_printFingerprint
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_ckeygen.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_ckeygen.py
MIT
def test_printFingerprintsha256(self): """ L{printFigerprint} will print key fingerprint in L{FingerprintFormats.SHA256-BASE64} format if explicitly specified. """ filename = self.mktemp() FilePath(filename).setContent(publicRSA_openssh) printFingerprint({'filename': filename, 'format': 'sha256-base64'}) self.assertEqual( self.stdout.getvalue(), '2048 FBTCOoknq0mHy+kpfnY9tDdcAJuWtCpuQMaV3EsvbUI= temp\n')
L{printFigerprint} will print key fingerprint in L{FingerprintFormats.SHA256-BASE64} format if explicitly specified.
test_printFingerprintsha256
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_ckeygen.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_ckeygen.py
MIT
def test_printFingerprintBadFingerPrintFormat(self): """ L{printFigerprint} raises C{keys.BadFingerprintFormat} when unsupported formats are requested. """ filename = self.mktemp() FilePath(filename).setContent(publicRSA_openssh) with self.assertRaises(BadFingerPrintFormat) as em: printFingerprint({'filename': filename, 'format':'sha-base64'}) self.assertEqual('Unsupported fingerprint format: sha-base64', em.exception.args[0])
L{printFigerprint} raises C{keys.BadFingerprintFormat} when unsupported formats are requested.
test_printFingerprintBadFingerPrintFormat
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_ckeygen.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_ckeygen.py
MIT
def test_saveKey(self): """ L{_saveKey} writes the private and public parts of a key to two different files and writes a report of this to standard out. """ base = FilePath(self.mktemp()) base.makedirs() filename = base.child('id_rsa').path key = Key.fromString(privateRSA_openssh) _saveKey(key, {'filename': filename, 'pass': 'passphrase', 'format': 'md5-hex'}) self.assertEqual( self.stdout.getvalue(), "Your identification has been saved in %s\n" "Your public key has been saved in %s.pub\n" "The key fingerprint in <FingerprintFormats=MD5_HEX> is:\n" "85:25:04:32:58:55:96:9f:57:ee:fb:a8:1a:ea:69:da\n" % ( filename, filename)) self.assertEqual( key.fromString( base.child('id_rsa').getContent(), None, 'passphrase'), key) self.assertEqual( Key.fromString(base.child('id_rsa.pub').getContent()), key.public())
L{_saveKey} writes the private and public parts of a key to two different files and writes a report of this to standard out.
test_saveKey
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_ckeygen.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_ckeygen.py
MIT
def test_saveKeyECDSA(self): """ L{_saveKey} writes the private and public parts of a key to two different files and writes a report of this to standard out. Test with ECDSA key. """ base = FilePath(self.mktemp()) base.makedirs() filename = base.child('id_ecdsa').path key = Key.fromString(privateECDSA_openssh) _saveKey(key, {'filename': filename, 'pass': 'passphrase', 'format': 'md5-hex'}) self.assertEqual( self.stdout.getvalue(), "Your identification has been saved in %s\n" "Your public key has been saved in %s.pub\n" "The key fingerprint in <FingerprintFormats=MD5_HEX> is:\n" "1e:ab:83:a6:f2:04:22:99:7c:64:14:d2:ab:fa:f5:16\n" % ( filename, filename)) self.assertEqual( key.fromString( base.child('id_ecdsa').getContent(), None, 'passphrase'), key) self.assertEqual( Key.fromString(base.child('id_ecdsa.pub').getContent()), key.public())
L{_saveKey} writes the private and public parts of a key to two different files and writes a report of this to standard out. Test with ECDSA key.
test_saveKeyECDSA
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_ckeygen.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_ckeygen.py
MIT
def test_saveKeysha256(self): """ L{_saveKey} will generate key fingerprint in L{FingerprintFormats.SHA256-BASE64} format if explicitly specified. """ base = FilePath(self.mktemp()) base.makedirs() filename = base.child('id_rsa').path key = Key.fromString(privateRSA_openssh) _saveKey(key, {'filename': filename, 'pass': 'passphrase', 'format': 'sha256-base64'}) self.assertEqual( self.stdout.getvalue(), "Your identification has been saved in %s\n" "Your public key has been saved in %s.pub\n" "The key fingerprint in <FingerprintFormats=SHA256_BASE64> is:\n" "FBTCOoknq0mHy+kpfnY9tDdcAJuWtCpuQMaV3EsvbUI=\n" % ( filename, filename)) self.assertEqual( key.fromString( base.child('id_rsa').getContent(), None, 'passphrase'), key) self.assertEqual( Key.fromString(base.child('id_rsa.pub').getContent()), key.public())
L{_saveKey} will generate key fingerprint in L{FingerprintFormats.SHA256-BASE64} format if explicitly specified.
test_saveKeysha256
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_ckeygen.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_ckeygen.py
MIT
def test_saveKeyBadFingerPrintformat(self): """ L{_saveKey} raises C{keys.BadFingerprintFormat} when unsupported formats are requested. """ base = FilePath(self.mktemp()) base.makedirs() filename = base.child('id_rsa').path key = Key.fromString(privateRSA_openssh) with self.assertRaises(BadFingerPrintFormat) as em: _saveKey(key, {'filename': filename, 'pass': 'passphrase', 'format': 'sha-base64'}) self.assertEqual('Unsupported fingerprint format: sha-base64', em.exception.args[0])
L{_saveKey} raises C{keys.BadFingerprintFormat} when unsupported formats are requested.
test_saveKeyBadFingerPrintformat
python
wistbean/learn_python3_spider
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_ckeygen.py
https://github.com/wistbean/learn_python3_spider/blob/master/stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_ckeygen.py
MIT