def test_with_allowed_sources(self): config = Config() config.ALLOWED_SOURCES = [ 's.glbimg.com', re.compile(r'https://www\.google\.com/img/.*') ] ctx = Context(None, config, None) expect( loader.validate( ctx, 'http://www.google.com/logo.jpg' ) ).to_be_false() expect( loader.validate( ctx, 'http://s2.glbimg.com/logo.jpg' ) ).to_be_false() expect( loader.validate( ctx, '/glob=:sfoir%20%20%3Co-pmb%20%20%20%20_%20%20%20%200%20%20g.-%3E%3Ca%20hplass=' ) ).to_be_false() expect( loader.validate( ctx, 'https://www.google.com/img/logo.jpg' ) ).to_be_true() expect( loader.validate(ctx, 'http://s.glbimg.com/logo.jpg')).to_be_true()
def topic(self): config = Config() config.ALLOWED_SOURCES = ['s.glbimg.com'] ctx = Context(None, config, None) is_valid = loader.validate(ctx, 'http://s2.glbimg.com/logo.jpg') return is_valid
def topic(self): config = Config() config.ALLOWED_SOURCES = [] ctx = Context(None, config, None) is_valid = loader.validate(ctx, 'http://www.google.com/logo.jpg') return is_valid
def topic(self): url = self.get_url('/') loader.http_client = self._http_client config = Config() config.ALLOWED_SOURCES = ['s.glbimg.com'] ctx = Context(None, config, None) return loader.load, ctx, url
def test_without_allowed_sources(self): config = Config() config.ALLOWED_SOURCES = [] ctx = Context(None, config, None) is_valid = loader.validate(ctx, 'https://www.google.com/logo.jpg') expect(is_valid).to_be_true() is_valid = loader.validate(ctx, 'http://www.google.com/logo.jpg') expect(is_valid).to_be_false()
def topic(self, callback): url = self.get_url('/') loader.http_client = self._http_client config = Config() config.ALLOWED_SOURCES = ['s.glbimg.com'] ctx = Context(None, config, None) loader.load(ctx, url, callback)
def topic(self): config = Config() config.ALLOWED_SOURCES = ['s2.glbimg.com'] ctx = Context(None, config, None) is_valid = loader.validate( ctx, '/glob=:sfoir%20%20%3Co-pmb%20%20%20%20_%20%20%20%200%20%20g.-%3E%3Ca%20hplass=' ) return is_valid
def test_with_allowed_sources(self): config = Config() config.ALLOWED_SOURCES = ["s.glbimg.com"] ctx = Context(None, config, None) expect(loader.validate(ctx, "http://www.google.com/logo.jpg")).to_be_false() expect(loader.validate(ctx, "http://s2.glbimg.com/logo.jpg")).to_be_false() expect( loader.validate(ctx, "/glob=:sfoir%20%20%3Co-pmb%20%20%20%20_%20%20%20%200%20%20g.-%3E%3Ca%20hplass=") ).to_be_false() expect(loader.validate(ctx, "http://s.glbimg.com/logo.jpg")).to_be_true()
async def test_with_allowed_sources(self): config = Config() config.ALLOWED_SOURCES = ["s.glbimg.com"] ctx = Context(None, config, None) expect(loader.validate(ctx, "http://www.google.com/logo.jpg")).to_be_false() expect(loader.validate(ctx, "http://s2.glbimg.com/logo.jpg")).to_be_false() expect( loader.validate( ctx, "/glob=:sfoir%20%20%3Co-pmb%20%20%20%20_%20%20%20%200%20%20g.-%3E%3Ca%20hplass=", # NOQA ) ).to_be_false() expect(loader.validate(ctx, "https://s.glbimg.com/logo.jpg")).to_be_true()
def test_with_allowed_sources(self): config = Config() config.ALLOWED_SOURCES = [ "s.glbimg.com", re.compile(r"https://www\.google\.com/img/.*"), ] ctx = Context(None, config, None) expect(loader.validate( ctx, "http://www.google.com/logo.jpg")).to_be_false() expect(loader.validate(ctx, "http://s2.glbimg.com/logo.jpg")).to_be_false() expect( loader.validate( ctx, "/glob=:sfoir%20%20%3Co-pmb%20%20%20%20_%20%20%20%200%20%20g.-%3E%3Ca%20hplass=", # NOQA, pylint: disable=line-too-long )).to_be_false() expect(loader.validate( ctx, "https://www.google.com/img/logo.jpg")).to_be_true() expect(loader.validate(ctx, "http://s.glbimg.com/logo.jpg")).to_be_true()
def topic(self): config = Config() config.ALLOWED_SOURCES = ['s.glbimg.com'] ctx = Context(None, config, None) is_valid = loader.validate(ctx, 'http://www.google.com/logo.jpg') return is_valid
def topic(self): config = Config() config.ALLOWED_SOURCES = ['s2.glbimg.com'] ctx = Context(None, config, None) is_valid = loader.validate(ctx, '/glob=:sfoir%20%20%3Co-pmb%20%20%20%20_%20%20%20%200%20%20g.-%3E%3Ca%20hplass=') return is_valid