def test_upload(self):
        cache = ResourceCache(directory='/tmp')
        cache.clear()

        print 'Testing GET'
        entry = cache.get('s3://anchore-testing/testkey1')
        print entry
        assert entry['content'] is not None

        if not os.path.exists('./testfile'):
            with open('./testfile', 'w') as f:
                f.write('Some content here')

        print 'Testing PUT 1'
        entry = cache.upload('./testfile', 's3://anchore-testing/testkey')
        print entry
        assert entry['content'] is not None
        date1 = entry['last-modified']

        print 'Testing PUT of existing file'
        entry = cache.upload('./testfile', 's3://anchore-testing/testkey')
        print entry
        assert entry['content'] is not None
        assert date1 == entry['last-modified']

        cache.clear()
    def test_basic(self):
        cache = ResourceCache(directory='/tmp')
        cache.clear()
        assert cache.is_empty()

        entry = cache.get('http://downloads.anchore.s3-website-us-west-2.amazonaws.com/')
        print entry
        assert entry['content'] is not None

        entry = cache.get('s3://downloads.anchore/readme.txt')
        print entry
        assert entry['content'] is not None

        entry = cache.get('s3://anchore-sync-service/subscriptions/engine.json')
        print entry
        assert entry['content'] is not None

        print cache.metadata
        cache.clear()
    def test_etagmatch(self):
        cache = ResourceCache(directory='/tmp')
        cache.clear()

        entry = cache.get('s3://downloads.anchore/readme.txt')
        print entry
        assert entry['content'] is not None

        entry = cache.get('s3://downloads.anchore/readme.txt')
        print entry
        assert entry['content'] is not None
        cache.clear()
Beispiel #4
0
    def test_basic(self):
        cache = ResourceCache(directory='/tmp')
        cache.clear()
        assert cache.is_empty()

        entry = cache.get(
            'http://downloads.anchore.s3-website-us-west-2.amazonaws.com/')
        print entry
        assert entry['content'] is not None

        print cache.metadata
        cache.clear()
Beispiel #5
0
    def test_etagmatch(self):
        cache = ResourceCache(directory='/tmp')
        cache.clear()

        entry = cache.get(
            'http://downloads.anchore.s3-website-us-west-2.amazonaws.com/')
        print entry
        assert entry['content'] is not None
        cache.clear()
Beispiel #6
0
    def test_basic(self):
        cache = ResourceCache(directory='/tmp')
        cache.clear()
        assert cache.is_empty()

        entry = cache.get('http://downloads.anchore.s3-website-us-west-2.amazonaws.com/')
        print entry
        assert entry['content'] is not None

        print cache.metadata
        cache.clear()
Beispiel #7
0
    def test_etagmatch(self):
        cache = ResourceCache(directory='/tmp')
        cache.clear()

        entry = cache.get('http://downloads.anchore.s3-website-us-west-2.amazonaws.com/')
        print entry
        assert entry['content'] is not None
        cache.clear()
Beispiel #8
0
    def _load(self):
        resource_cache_dir = os.path.join(self._config['anchore_data_dir'], self._resource_cache_name)
        self.resource_cache = ResourceCache(path=resource_cache_dir,
                                            progress_bars=('quiet' not in self._config.cliargs or not self._config.cliargs['quiet']))

        self.metadata = AnalysisMetadataManager(remote_sync_url=self._config['analysis']['url'],
                                                sync_dir=self._config['image_data_store'],
                                                resource_cache=self.resource_cache)

        self.vulnerabilities = VulnerabilityManager(data_dir=self._config['anchore_data_dir'],
                                                    remote_sync_url=self._config['vulnerabilities']['url'],
                                                    resource_cache=self.resource_cache)

        self.images = ImageManager(docker_url=self._config['images']['docker_conn'])

        self.subscription = RepoSubscription(path=os.path.join(self._config['anchore_data_dir'], self._subscription_filename))