Adding safety test for keyrings.
This commit is contained in:
		
							
								
								
									
										2
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							| @@ -1,4 +1,6 @@ | ||||
| src/ | ||||
| pkg/ | ||||
| __pycache__ | ||||
| *.pyc | ||||
| *.tar.xz | ||||
| *.tar.zst | ||||
|   | ||||
							
								
								
									
										28
									
								
								tests/test_gpg.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								tests/test_gpg.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,28 @@ | ||||
| import os | ||||
| import pytest | ||||
| import shutil | ||||
| import subprocess | ||||
|  | ||||
|  | ||||
| def test_gpg_key_import(): | ||||
|     testdir = './gpg2-testdir' | ||||
|     os.mkdir(testdir) | ||||
|     assertion = True | ||||
|     # Import the key | ||||
|     subprocess.run(['gpg2','--no-permission-warning','--homedir',testdir,'--import','EtcFiles/aninix.gpg'],stdout=subprocess.PIPE) | ||||
|  | ||||
|     # Check for private keys -- should not disclose these. | ||||
|     privatekeys = subprocess.run(['gpg2','--no-permission-warning','--homedir','./gpg2-testdir','-K'],stdout=subprocess.PIPE) | ||||
|     if privatekeys.stdout != b'': | ||||
|         assertion = False | ||||
|         print('Private key should not be included in the GPG key.') | ||||
|         print(privatekeys.stdout) | ||||
|  | ||||
|     # Check for public keys -- need to disclose these. | ||||
|     publickeys = subprocess.run(['gpg2','--no-permission-warning','--homedir',testdir,'-k'],stdout=subprocess.PIPE) | ||||
|     if b'904DE6275579CB589D85720C1CC1E3F4ED06F296' not in publickeys.stdout or b'DarkFeather <ircs://aninix.net:6697/DarkFeather>' not in publickeys.stdout: | ||||
|         assertion = False | ||||
|         print('Did not find the public key.') | ||||
|         print(publickeys.stdout) | ||||
|     shutil.rmtree(testdir)     | ||||
|     assert assertion | ||||
		Reference in New Issue
	
	Block a user