Example #1
0
            def topic(self):
                conf = Config(MONGO_STORAGE_SERVER_PORT=7777, STORES_CRYPTO_KEY_FOR_EACH_IMAGE=True)
                server = get_server('ACME-SEC')
                storage = MongoStorage(Context(config=conf, server=server))
                storage.put(IMAGE_URL % 6, IMAGE_BYTES)

                return storage.get_crypto(IMAGE_URL % 6)
Example #2
0
 def topic(self):
     storage = MongoStorage(
         Context(
             config=Config(MONGO_STORAGE_SERVER_PORT=7777,
                           STORES_CRYPTO_KEY_FOR_EACH_IMAGE=True,
                           SECURITY_KEY='ACME-SEC')))
     return storage.get_crypto(IMAGE_URL % 7)
            def topic(self):
                storage = MongoStorage(
                    Context(config=Config(MONGO_STORAGE_SERVER_PORT=7777, STORES_CRYPTO_KEY_FOR_EACH_IMAGE=False))
                )
                storage.put(IMAGE_URL % 3, IMAGE_BYTES)

                return COLLECTION.find_one({"path": IMAGE_URL % 3})
Example #4
0
 def test_stores_image_does_not_store_crypt_key_if_not_in_options(self):
     rm_storage()
     options.STORES_CRYPTO_KEY_FOR_EACH_IMAGE = False
     image_url = 'www.globo.com/media/globocom/img/sprite1.png'
     http_loaded = http.load(image_url)
     storage = Storage()
     storage.put(image_url, http_loaded)
     assert not collection.find_one({'path': image_url}).has_key('crypto'), 'crypto key should not be found into the storage'
Example #5
0
 def test_stores_image(self):
     rm_storage()
     options.STORES_CRYPTO_KEY_FOR_EACH_IMAGE = False
     image_url = 'www.globo.com/media/globocom/img/sprite1.png'
     http_loaded = http.load(image_url)
     storage = Storage()
     storage.put(image_url, http_loaded)
     assert collection.find_one({'path': image_url}), 'image not found into the storage'
Example #6
0
 def test_before_expiration_returns_something(self):
     rm_storage()
     options.STORAGE_EXPIRATION_SECONDS = 1000
     image_url = 'www.globo.com/media/globocom/img/sprite1.png'
     http_loaded = http.load(image_url)
     storage = Storage()
     storage.put(image_url, http_loaded)
     assert storage.get(image_url)
Example #7
0
 def topic(self):
     storage = MongoStorage(
         Context(config=Config(
             MONGO_STORAGE_SERVER_PORT=7777, STORES_CRYPTO_KEY_FOR_EACH_IMAGE=True,
             SECURITY_KEY='ACME-SEC')
         )
     )
     return storage.get_crypto(IMAGE_URL % 7)
Example #8
0
            def topic(self):
                storage = MongoStorage(
                    Context(
                        config=Config(MONGO_STORAGE_SERVER_PORT=7777,
                                      STORES_CRYPTO_KEY_FOR_EACH_IMAGE=False)))
                storage.put(IMAGE_URL % 3, IMAGE_BYTES)

                return COLLECTION.find_one({'path': IMAGE_URL % 3})
Example #9
0
 def topic(self):
     conf = Config(MONGO_STORAGE_SERVER_PORT=7777,
                   STORES_CRYPTO_KEY_FOR_EACH_IMAGE=True,
                   STORAGE_EXPIRATION_SECONDS=5000)
     server = get_server('ACME-SEC')
     storage = MongoStorage(Context(server=server, config=conf))
     storage.put(IMAGE_URL % 8, IMAGE_BYTES)
     return storage.get(IMAGE_URL % 8)
Example #10
0
 def test_before_expiration_returns_something(self):
     rm_storage()
     options.STORAGE_EXPIRATION_SECONDS = 1000
     image_url = 'www.globo.com/media/globocom/img/sprite1.png'
     http_loaded = http.load(image_url)
     storage = Storage()
     storage.put(image_url, http_loaded)
     assert storage.get(image_url)
Example #11
0
            def topic(self):
                conf = Config(MONGO_STORAGE_SERVER_PORT=7777, STORES_CRYPTO_KEY_FOR_EACH_IMAGE=False)
                server = get_server('')
                storage = MongoStorage(Context(config=conf, server=server))
                storage.put(IMAGE_URL % 13, IMAGE_BYTES)

                conf.STORES_CRYPTO_KEY_FOR_EACH_IMAGE = True
                storage.put_crypto(IMAGE_URL % 13)
Example #12
0
            def topic(self):
                conf = Config(MONGO_STORAGE_SERVER_PORT=7777, STORES_CRYPTO_KEY_FOR_EACH_IMAGE=True)

                storage = MongoStorage(Context(config=conf, server=get_server("ACME-SEC")))

                storage.put(IMAGE_URL % 5, IMAGE_BYTES)

                return COLLECTION.find_one({"path": IMAGE_URL % 5})
Example #13
0
            def topic(self):
                conf = Config(MONGO_STORAGE_SERVER_PORT=7777,
                              STORES_CRYPTO_KEY_FOR_EACH_IMAGE=True)
                server = get_server('ACME-SEC')
                storage = MongoStorage(Context(config=conf, server=server))
                storage.put(IMAGE_URL % 6, IMAGE_BYTES)

                return storage.get_crypto(IMAGE_URL % 6)
Example #14
0
    def test_get_crypto_for_url(self):
        rm_storage()
        image_url = 'www.globo.com/media/globocom/img/sprite1.png'
        http_loaded = http.load(image_url)
        storage = Storage()

        storage.put(image_url, http_loaded)

        assert storage.get_crypto(image_url) == options.SECURITY_KEY
Example #15
0
            def topic(self):
                conf = Config(MONGO_STORAGE_SERVER_PORT=7777,
                              STORES_CRYPTO_KEY_FOR_EACH_IMAGE=False)
                server = get_server('')
                storage = MongoStorage(Context(config=conf, server=server))
                storage.put(IMAGE_URL % 13, IMAGE_BYTES)

                conf.STORES_CRYPTO_KEY_FOR_EACH_IMAGE = True
                storage.put_crypto(IMAGE_URL % 13)
Example #16
0
 def test_after_expiration_returns_none(self):
     rm_storage()
     options.STORAGE_EXPIRATION_SECONDS = 1
     image_url = 'www.globo.com/media/globocom/img/sprite1.png'
     http_loaded = http.load(image_url)
     storage = Storage()
     storage.put(image_url, http_loaded)
     time.sleep(2)
     assert storage.get(image_url) is None
Example #17
0
 def topic(self):
     conf = Config(
         MONGO_STORAGE_SERVER_PORT=7777, STORES_CRYPTO_KEY_FOR_EACH_IMAGE=True,
         STORAGE_EXPIRATION_SECONDS=5000
     )
     server = get_server('ACME-SEC')
     storage = MongoStorage(Context(server=server, config=conf))
     storage.put(IMAGE_URL % 8, IMAGE_BYTES)
     return storage.get(IMAGE_URL % 8)
Example #18
0
 def test_stores_image(self):
     rm_storage()
     options.STORES_CRYPTO_KEY_FOR_EACH_IMAGE = False
     image_url = 'www.globo.com/media/globocom/img/sprite1.png'
     http_loaded = http.load(image_url)
     storage = Storage()
     storage.put(image_url, http_loaded)
     assert collection.find_one({'path': image_url
                                 }), 'image not found into the storage'
Example #19
0
 def test_after_expiration_returns_none(self):
     rm_storage()
     options.STORAGE_EXPIRATION_SECONDS = 1
     image_url = 'www.globo.com/media/globocom/img/sprite1.png'
     http_loaded = http.load(image_url)
     storage = Storage()
     storage.put(image_url, http_loaded)
     time.sleep(2)
     assert storage.get(image_url) is None
Example #20
0
    def test_get_crypto_for_url(self):
        rm_storage()
        image_url = 'www.globo.com/media/globocom/img/sprite1.png'
        http_loaded = http.load(image_url)
        storage = Storage()

        storage.put(image_url, http_loaded)

        assert storage.get_crypto(image_url) == options.SECURITY_KEY
Example #21
0
 def test_stores_image_does_not_store_crypt_key_if_not_in_options(self):
     rm_storage()
     options.STORES_CRYPTO_KEY_FOR_EACH_IMAGE = False
     image_url = 'www.globo.com/media/globocom/img/sprite1.png'
     http_loaded = http.load(image_url)
     storage = Storage()
     storage.put(image_url, http_loaded)
     assert not collection.find_one({
         'path': image_url
     }).has_key('crypto'), 'crypto key should not be found into the storage'
Example #22
0
 def test_gets_image(self):
     rm_storage()
     options.STORES_CRYPTO_KEY_FOR_EACH_IMAGE = False
     image_url = 'www.globo.com/media/globocom/img/sprite1.png'
     http_loaded = http.load(image_url)
     storage = Storage()
     storage.put(image_url, http_loaded)
     stored_image = storage.get(image_url)
     assert stored_image and not isinstance(stored_image, dict), 'image not found into the storage'
     assert http_loaded == stored_image, 'stored image did not match the loaded one'
Example #23
0
            def topic(self):
                conf = Config(MONGO_STORAGE_SERVER_PORT=7777,
                              STORES_CRYPTO_KEY_FOR_EACH_IMAGE=True)

                storage = MongoStorage(
                    Context(config=conf, server=get_server('ACME-SEC')))

                storage.put(IMAGE_URL % 5, IMAGE_BYTES)

                return COLLECTION.find_one({'path': IMAGE_URL % 5})
Example #24
0
            def topic(self):
                config = Config(MONGO_STORAGE_SERVER_PORT=7777,
                                STORES_CRYPTO_KEY_FOR_EACH_IMAGE=True,
                                SECURITY_KEY='ACME-SEC',
                                STORAGE_EXPIRATION_SECONDS=0)
                storage = MongoStorage(Context(config=config))
                storage.put(IMAGE_URL % 10, IMAGE_BYTES)

                item = storage.get(IMAGE_URL % 10)
                return item is None
Example #25
0
 def test_gets_image(self):
     rm_storage()
     options.STORES_CRYPTO_KEY_FOR_EACH_IMAGE = False
     image_url = 'www.globo.com/media/globocom/img/sprite1.png'
     http_loaded = http.load(image_url)
     storage = Storage()
     storage.put(image_url, http_loaded)
     stored_image = storage.get(image_url)
     assert stored_image and not isinstance(
         stored_image, dict), 'image not found into the storage'
     assert http_loaded == stored_image, 'stored image did not match the loaded one'
Example #26
0
            def topic(self):
                config = Config(
                    MONGO_STORAGE_SERVER_PORT=7777, STORES_CRYPTO_KEY_FOR_EACH_IMAGE=True,
                    SECURITY_KEY='ACME-SEC', STORAGE_EXPIRATION_SECONDS=0
                )
                server = get_server('ACME-SEC')
                storage = MongoStorage(Context(server=server, config=config))
                storage.put(IMAGE_URL % 10, IMAGE_BYTES)

                item = storage.get(IMAGE_URL % 10)
                return item is None
Example #27
0
    def test_finding_crypto_file(self):
        rm_storage()
        options.STORES_CRYPTO_KEY_FOR_EACH_IMAGE = True
        options.SECURITY_KEY = 'MY-SECURITY-KEY'
        image_url = 'www.globo.com/media/globocom/img/sprite1.png'
        http_loaded = http.load(image_url)
        storage = Storage()

        storage.put(image_url, http_loaded)

        stored_crypto_key = collection.find_one({'path': image_url}).get('crypto')
        assert stored_crypto_key == options.SECURITY_KEY, '%s crypto key should be equal %s' % (stored_crypto_key, options.SECURITY_KEY)
Example #28
0
    def test_storing_an_empty_key_raises(self):
        rm_storage()
        options.SECURITY_KEY = False
        options.STORES_CRYPTO_KEY_FOR_EACH_IMAGE = True
        image_url = 'www.globo.com/media/globocom/img/sprite1.png'
        http_loaded = http.load(image_url)
        storage = Storage()

        try:
            storage.put(image_url, http_loaded)
        except RuntimeError, err:
            assert str(err) == "STORES_CRYPTO_KEY_FOR_EACH_IMAGE can't be True if no SECURITY_KEY specified"
            return
Example #29
0
            def topic(self):
                conf = Config(MONGO_STORAGE_SERVER_PORT=7777, STORES_CRYPTO_KEY_FOR_EACH_IMAGE=True)

                storage = MongoStorage(
                    Context(
                        config=conf,
                        server=get_server('ACME-SEC')
                    )
                )

                storage.put(IMAGE_URL % 5, IMAGE_BYTES)

                return self.parent.parent.collection.find_one({'path': IMAGE_URL % 5})
Example #30
0
    def test_finding_crypto_file(self):
        rm_storage()
        options.STORES_CRYPTO_KEY_FOR_EACH_IMAGE = True
        options.SECURITY_KEY = 'MY-SECURITY-KEY'
        image_url = 'www.globo.com/media/globocom/img/sprite1.png'
        http_loaded = http.load(image_url)
        storage = Storage()

        storage.put(image_url, http_loaded)

        stored_crypto_key = collection.find_one({
            'path': image_url
        }).get('crypto')
        assert stored_crypto_key == options.SECURITY_KEY, '%s crypto key should be equal %s' % (
            stored_crypto_key, options.SECURITY_KEY)
Example #31
0
    def test_storing_an_empty_key_raises(self):
        rm_storage()
        options.SECURITY_KEY = False
        options.STORES_CRYPTO_KEY_FOR_EACH_IMAGE = True
        image_url = 'www.globo.com/media/globocom/img/sprite1.png'
        http_loaded = http.load(image_url)
        storage = Storage()

        try:
            storage.put(image_url, http_loaded)
        except RuntimeError, err:
            assert str(
                err
            ) == "STORES_CRYPTO_KEY_FOR_EACH_IMAGE can't be True if no SECURITY_KEY specified"
            return
Example #32
0
        def topic(self):
            conf = Config(MONGO_STORAGE_SERVER_PORT=7777)
            storage = MongoStorage(Context(config=conf))
            storage.put(IMAGE_URL % 14, IMAGE_BYTES)
            storage.put_detector_data(IMAGE_URL % 14, "some data")

            return storage.get_detector_data(IMAGE_URL % 14)
Example #33
0
        def topic(self):
            conf = Config(MONGO_STORAGE_SERVER_PORT=7777)
            storage = MongoStorage(Context(config=conf))
            storage.put(IMAGE_URL % 14, IMAGE_BYTES)
            storage.put_detector_data(IMAGE_URL % 14, "some data")

            return storage.get_detector_data(IMAGE_URL % 14)
Example #34
0
            def topic(self):
                conf = Config(MONGO_STORAGE_SERVER_PORT=7777, STORES_CRYPTO_KEY_FOR_EACH_IMAGE=False, SECURITY_KEY='ACME-SEC')
                storage = MongoStorage(Context(config=conf))
                storage.put(IMAGE_URL % 12, IMAGE_BYTES)
                storage.put_crypto(IMAGE_URL % 12)

                item = storage.get_crypto(IMAGE_URL % 12)
                return item
Example #35
0
            def topic(self):
                conf = Config(MONGO_STORAGE_SERVER_PORT=7777,
                              STORES_CRYPTO_KEY_FOR_EACH_IMAGE=False,
                              SECURITY_KEY='ACME-SEC')
                storage = MongoStorage(Context(config=conf))
                storage.put(IMAGE_URL % 12, IMAGE_BYTES)
                storage.put_crypto(IMAGE_URL % 12)

                item = storage.get_crypto(IMAGE_URL % 12)
                return item.result()
Example #36
0
            def topic(self):
                conf = Config(MONGO_STORAGE_SERVER_PORT=7777, STORES_CRYPTO_KEY_FOR_EACH_IMAGE=False)
                server = get_server('ACME-SEC')
                storage = MongoStorage(Context(config=conf, server=server))
                storage.put(IMAGE_URL % 11, IMAGE_BYTES)

                conf.STORES_CRYPTO_KEY_FOR_EACH_IMAGE = True
                storage.put_crypto(IMAGE_URL % 11)

                item = storage.get_crypto(IMAGE_URL % 11)
                return item.result()
Example #37
0
            def topic(self):
                conf = Config(MONGO_STORAGE_SERVER_PORT=7777,
                              STORES_CRYPTO_KEY_FOR_EACH_IMAGE=False)
                server = get_server('ACME-SEC')
                storage = MongoStorage(Context(config=conf, server=server))
                storage.put(IMAGE_URL % 11, IMAGE_BYTES)

                conf.STORES_CRYPTO_KEY_FOR_EACH_IMAGE = True
                storage.put_crypto(IMAGE_URL % 11)

                item = storage.get_crypto(IMAGE_URL % 11)
                return item.result()
Example #38
0
 def topic(self):
     storage = MongoStorage(
         Context(config=Config(MONGO_STORAGE_SERVER_PORT=7777)))
     return storage.exists(IMAGE_URL % 20000)
Example #39
0
 def topic(self):
     storage = MongoStorage(
         Context(config=Config(MONGO_STORAGE_SERVER_PORT=7777)))
     storage.remove(IMAGE_URL % 9999)
     return self.parent.parent.collection.find_one(
         {'path': IMAGE_URL % 9999})
Example #40
0
            def topic(self):
                storage = MongoStorage(Context(config=Config(MONGO_STORAGE_SERVER_PORT=7777, STORES_CRYPTO_KEY_FOR_EACH_IMAGE=False)))
                storage.put(IMAGE_URL % 3, IMAGE_BYTES)

                return self.parent.parent.collection.find_one({'path': IMAGE_URL % 3})
Example #41
0
 def topic(self):
     storage = MongoStorage(Context(config=Config(MONGO_STORAGE_SERVER_PORT=7777)))
     storage.put(IMAGE_URL % 1, IMAGE_BYTES)
     return self.parent.collection.find_one({'path': IMAGE_URL % 1})
Example #42
0
 def topic(self):
     storage = MongoStorage(Context(config=Config(MONGO_STORAGE_SERVER_PORT=7777)))
     storage.remove(IMAGE_URL % 9999)
     return self.parent.parent.collection.find_one({'path': IMAGE_URL % 9999})
Example #43
0
 def topic(self):
     storage = MongoStorage(Context(config=Config(MONGO_STORAGE_SERVER_PORT=7777)))
     storage.remove(IMAGE_URL % 9999)
     return COLLECTION.find_one({'path': IMAGE_URL % 9999})
Example #44
0
 def topic(self):
     storage = MongoStorage(Context(config=Config(MONGO_STORAGE_SERVER_PORT=7777)))
     storage.put(IMAGE_URL % 1, IMAGE_BYTES)
     return COLLECTION.find_one({'path': IMAGE_URL % 1})
Example #45
0
 def topic(self):
     storage = MongoStorage(
         Context(config=Config(MONGO_STORAGE_SERVER_PORT=7777)))
     storage.put(IMAGE_URL % 1, IMAGE_BYTES)
     return self.parent.collection.find_one({'path': IMAGE_URL % 1})
Example #46
0
 def topic(self):
     storage = MongoStorage(
         Context(config=Config(MONGO_STORAGE_SERVER_PORT=7777)))
     storage.put(IMAGE_URL % 1, IMAGE_BYTES)
     return COLLECTION.find_one({'path': IMAGE_URL % 1})
Example #47
0
    def test_get_crypto_for_url_returns_None_if_urls_was_never_seen(self):
        rm_storage()
        image_url = 'www.globo.com/media/globocom/img/sprite1.png'
        storage = Storage()

        assert not storage.get_crypto(image_url)
Example #48
0
    def test_get_crypto_for_url_returns_None_if_urls_was_never_seen(self):
        rm_storage()
        image_url = 'www.globo.com/media/globocom/img/sprite1.png'
        storage = Storage()

        assert not storage.get_crypto(image_url)
Example #49
0
 def topic(self):
     storage = MongoStorage(
         Context(config=Config(MONGO_STORAGE_SERVER_PORT=7777)))
     storage.remove(IMAGE_URL % 9999)
     return COLLECTION.find_one({'path': IMAGE_URL % 9999})
Example #50
0
 def topic(self):
     storage = MongoStorage(
         Context(config=Config(MONGO_STORAGE_SERVER_PORT=7777)))
     storage.put(IMAGE_URL % 2, IMAGE_BYTES)
     return storage.get(IMAGE_URL % 2)
Example #51
0
 def topic(self):
     storage = MongoStorage(Context(config=Config(MONGO_STORAGE_SERVER_PORT=7777)))
     storage.put(IMAGE_URL % 10000, IMAGE_BYTES)
     return storage.exists(IMAGE_URL % 10000)
Example #52
0
 def topic(self):
     conf = Config(MONGO_STORAGE_SERVER_PORT=7777, STORES_CRYPTO_KEY_FOR_EACH_IMAGE=True)
     server = get_server()
     storage = MongoStorage(Context(server=server, config=conf))
     storage.put(IMAGE_URL % 4, IMAGE_BYTES)
Example #53
0
 def topic(self):
     storage = MongoStorage(Context(config=Config(MONGO_STORAGE_SERVER_PORT=7777)))
     return storage.get(IMAGE_URL % 99)
Example #54
0
 def topic(self):
     conf = Config(MONGO_STORAGE_SERVER_PORT=7777,
                   STORES_CRYPTO_KEY_FOR_EACH_IMAGE=True)
     server = get_server()
     storage = MongoStorage(Context(server=server, config=conf))
     storage.put(IMAGE_URL % 4, IMAGE_BYTES)