Пример #1
0
 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()
Пример #2
0
 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
Пример #3
0
 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
Пример #4
0
            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
Пример #5
0
    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()
Пример #6
0
    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()
Пример #7
0
            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)
Пример #8
0
 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
Пример #9
0
 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()
Пример #11
0
 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()
Пример #12
0
 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
Пример #13
0
 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