diff --git a/.travis.yml b/.travis.yml index 9bcb1da..5783f13 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ sudo: false -addons: - apt: - packages: - - python3 +python: + - "3.4" +language: python +install: "pip install gnupg" script: ./tests.py diff --git a/tests.py b/tests.py index 3e10342..05db358 100755 --- a/tests.py +++ b/tests.py @@ -2,15 +2,19 @@ import json import os import sys +import gnupg REQUIRED_FIELDS = ['publicKey', 'password', 'contact'] RECOMMENDED_FIELDS = ['gpg'] +GPG_SERVERS = ["pgp.mit.edu", "keys.gnupg.net"] RED = '\x1b[01;31m' GREEN = '\x1b[01;32m' YELLOW = '\x1b[01;33m' END = '\x1b[0m' +gpg = gnupg.GPG() + def validate(path): print("Validating %s" % path) @@ -30,6 +34,18 @@ def validate(path): warning = True print(" %sHost %s is missing the recommended field %s%s" % (YELLOW, host, field, END)) + if "gpg" in peers[host]: + is_on_keyserver = False + for server in GPG_SERVERS: + gpg_result = gpg.recv_keys(server, peers[host]['gpg']) + print(" %s%s key(s) found on %s when searching for %s%s" % + (YELLOW, len(gpg_result.results), server, peers[host]['gpg'], END)) + if len(gpg_result.results) > 0: + is_on_keyserver = True + if not is_on_keyserver: + print(" %s%s not found on any keyserver%s" % + (RED, peers[host]['gpg'], END)) + return False if warning: print(" %sSuccess, but missing recommended fields%s" % (YELLOW, END)) else: