hopefully fixed pgp test, added pgp export function
parent
0042e2fe51
commit
26c1983a61
|
@ -18,10 +18,11 @@
|
|||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
'''
|
||||
# Misc functions that do not fit in the main api, but are useful
|
||||
import getpass, sys, requests, configparser, os, socket
|
||||
import getpass, sys, requests, configparser, os, socket, gnupg
|
||||
class OnionrUtils():
|
||||
'''Various useful functions'''
|
||||
def __init__(self):
|
||||
self.fingerprintFile = 'data/own-fingerprint.txt'
|
||||
return
|
||||
def printErr(self, text='an error occured'):
|
||||
'''Print an error message to stderr with a new line'''
|
||||
|
@ -60,4 +61,13 @@ class OnionrUtils():
|
|||
retVal = True
|
||||
finally:
|
||||
sock.close()
|
||||
return retVal
|
||||
return retVal
|
||||
def exportMyPubkey(self):
|
||||
'''Export our PGP key if it exists'''
|
||||
if not os.path.exists(self.fingerprintFile):
|
||||
raise Exception("No fingerprint found, cannot export our PGP key.")
|
||||
gpg = gnupg.GPG(gnupghome='./data/pgp/')
|
||||
with open(self.fingerprintFile,'r') as f:
|
||||
fingerprint = f.read()
|
||||
ascii_armored_public_keys = gpg.export_keys(fingerprint)
|
||||
return ascii_armored_public_keys
|
|
@ -82,12 +82,13 @@ class OnionrTests(unittest.TestCase):
|
|||
def testPGPGen(self):
|
||||
print('--------------------------')
|
||||
print('Testing PGP key generation')
|
||||
torID = open('data/hs/hostname').read()
|
||||
if os.path.exists('data/pgp/'):
|
||||
self.assertTrue(True)
|
||||
else:
|
||||
import core
|
||||
myCore = core.Core()
|
||||
myCore.generateMainPGP()
|
||||
myCore.generateMainPGP(torID)
|
||||
if os.path.exists('data/pgp/'):
|
||||
self.assertTrue(True)
|
||||
def testHMACGen(self):
|
||||
|
|
Loading…
Reference in New Issue