Exemplo n.º 1
0
    def _export_message(self, uuid, doc):
        """
        Given a UUID and a CouchDocument, it saves it directly in the
        couchdb that serves as a backend for Soledad, in a db
        accessible to the recipient of the mail.

        :param uuid: the mail owner's uuid
        :type uuid: str
        :param doc: CouchDocument that represents the email
        :type doc: CouchDocument

        :return: True if it's ok to remove the message, False
                 otherwise
        :rtype: bool
        """
        if uuid is None or doc is None:
            log.msg("_export_message: Something went wrong, here's all "
                    "I know: %r | %r" % (uuid, doc))
            return False

        log.msg("Exporting message for %s" % (uuid,))

        db = CouchDatabase(self._mail_couch_url, "user-%s" % (uuid,))
        db.put_doc(doc)

        log.msg("Done exporting")

        return True
Exemplo n.º 2
0
 def tearDown(self):
     main_test_class = getattr(self, 'main_test_class', None)
     if main_test_class is not None:
         main_test_class.tearDown(self)
     # delete the test database
     try:
         db = CouchDatabase(self._couch_url, 'test')
         db.delete_database()
     except DatabaseDoesNotExist:
         pass
     BaseSoledadTest.tearDown(self)
     CouchDBTestCase.tearDown(self)
def couch_database(couch_url, uuid):
    db = CouchDatabase(couch_url, "user-%s" % (uuid,))
    return db
Exemplo n.º 4
0
from leap.soledad.common.couch import CouchDatabase

if len(sys.argv) != 2:
    print 'Usage: %s <uuid>' % sys.argv[0]
    exit(1)

uuid = sys.argv[1]

# get couch url
cp = ConfigParser()
cp.read('/etc/leap/soledad-server.conf')
url = cp.get('soledad-server', 'couch_url')

# access user db
dbname = 'user-%s' % uuid
db = CouchDatabase(url, dbname)

# get replica info
replica_uid = db._replica_uid
gen, docs = db.get_all_docs()
print "dbname:      %s" % dbname
print "replica_uid: %s" % replica_uid
print "generation:  %d" % gen

# get relevant docs
schemes = map(lambda d: d.content['_enc_scheme'], docs)
pubenc = filter(lambda d: d.content['_enc_scheme'] == 'pubkey', docs)

print "total number of docs:  %d" % len(docs)
print "pubkey encrypted docs: %d" % len(pubenc)