def browse(self, setup=None, **kw): alice = self.make_participant('alice', claimed_time='now', number='plural') exchange_id = self.make_exchange('balanced-cc', 19, 0, alice) alice.insert_into_communities(True, 'Wonderland', 'wonderland') alan = self.make_participant('alan', claimed_time='now') alice.add_member(alan) if setup: setup(alice) i = len(self.client.www_root) for spt in find_files(self.client.www_root, '*.spt'): url = spt[i:-4].replace('/%username/', '/alice/') \ .replace('/for/%slug/', '/for/wonderland/') \ .replace('/%platform/', '/github/') \ .replace('/%user_name/', '/gratipay/') \ .replace('/%membername', '/alan') \ .replace('/%exchange_id.int', '/%s' % exchange_id) \ .replace('/%redirect_to', '/giving') \ .replace('/%endpoint', '/public') assert '/%' not in url if 'index' in url.split('/')[-1]: url = url.rsplit('/', 1)[0] + '/' try: r = self.client.GET(url, **kw) except Response as r: if r.code == 404 or r.code >= 500: raise assert r.code != 404 assert r.code < 500 assert not overescaping_re.search(r.body.decode('utf8'))
def browse(self, setup=None, **kw): alice = self.make_participant('alice', claimed_time='now') # for pricing page self.make_team('Gratipay') # for the receipt page result = braintree.PaymentMethod.create({ "customer_id": alice.get_braintree_account().id, "payment_method_nonce": Nonces.Transactable }) assert result.is_success address = result.payment_method.token exchange_id = self.make_exchange('braintree-cc', 19, 0, alice, address=address) # for npm page self.db.run("INSERT INTO packages (package_manager, name, description, emails) " "VALUES ('npm', 'foo-package', 'A package', ARRAY[]::text[])") if setup: setup(alice) i = len(self.client.www_root) urls = [] for spt in find_files(self.client.www_root, '*.spt'): url = spt[i:-4].replace('/%team/', '/Gratipay/') \ .replace('/Gratipay/%sub', '/alice/foo') \ .replace('/~/%username/', '/~alice/') \ .replace('/for/%slug/', '/for/wonderland/') \ .replace('/%platform/', '/github/') \ .replace('/%package/', '/foo-package/') \ .replace('/%user_name/', '/gratipay/') \ .replace('/%to', '/1') \ .replace('/%country', '/TT') \ .replace('/%exchange_id', '/%s' % exchange_id) \ .replace('/%redirect_to', '/giving') \ .replace('/%endpoint', '/public') \ .replace('/about/me/%sub', '/about/me') assert '/%' not in url if 'index' in url.split('/')[-1]: url = url.rsplit('/', 1)[0] + '/' urls.append(url) urls.extend(""" /about/me /about/me/ /about/me/history """.split()) for url in urls: try: r = self.client.GET(url, **kw) except Response as r: if r.code == 404 or r.code >= 500: raise assert r.code != 404 assert r.code < 500 type_in = lambda *x: any([r.headers['Content-Type'].startswith(y) for y in x]) if r.code == 200 and type_in('text', 'application/json'): assert not overescaping_re.search(r.body.decode('utf8'))
def browse(self, setup=None, **kw): alice = self.make_participant('alice', claimed_time='now') # for pricing page self.make_team('Gratipay') # for the receipt page result = braintree.PaymentMethod.create({ "customer_id": alice.get_braintree_account().id, "payment_method_nonce": Nonces.Transactable }) assert result.is_success address = result.payment_method.token exchange_id = self.make_exchange('braintree-cc', 19, 0, alice, address=address) if setup: setup(alice) i = len(self.client.www_root) urls = [] for spt in find_files(self.client.www_root, '*.spt'): url = spt[i:-4].replace('/%team/', '/alice/') \ .replace('/alice/%sub', '/alice/foo') \ .replace('/~/%username/', '/~alice/') \ .replace('/for/%slug/', '/for/wonderland/') \ .replace('/%platform/', '/github/') \ .replace('/%user_name/', '/gratipay/') \ .replace('/%to', '/1') \ .replace('/%country', '/TT') \ .replace('/%exchange_id.int', '/%s' % exchange_id) \ .replace('/%redirect_to', '/giving') \ .replace('/%endpoint', '/public') \ .replace('/about/me/%sub', '/about/me') assert '/%' not in url if 'index' in url.split('/')[-1]: url = url.rsplit('/', 1)[0] + '/' urls.append(url) urls.extend(""" /about/me /about/me/ /about/me/history """.split()) for url in urls: try: r = self.client.GET(url, **kw) except Response as r: if r.code == 404 or r.code >= 500: raise assert r.code != 404 assert r.code < 500 assert not overescaping_re.search(r.body.decode('utf8'))
def browse(self, setup=None, **kw): alice = self.make_participant('alice', claimed_time='now') # for pricing page self.make_team('Gratipay') # for the receipt page result = braintree.PaymentMethod.create({ "customer_id": alice.get_braintree_account().id, "payment_method_nonce": Nonces.Transactable }) assert result.is_success address = result.payment_method.token exchange_id = self.make_exchange('braintree-cc', 19, 0, alice, address=address) # for npm page self.db.run("INSERT INTO packages (package_manager, name, description, emails) " "VALUES ('npm', 'foo-package', 'A package', ARRAY[]::text[])") if setup: setup(alice) i = len(self.client.www_root) urls = [] for spt in find_files(self.client.www_root, '*.spt'): url = spt[i:-4].replace('/%team/', '/alice/') \ .replace('/alice/%sub', '/alice/foo') \ .replace('/~/%username/', '/~alice/') \ .replace('/for/%slug/', '/for/wonderland/') \ .replace('/%platform/', '/github/') \ .replace('/%package/', '/foo-package/') \ .replace('/%user_name/', '/gratipay/') \ .replace('/%to', '/1') \ .replace('/%country', '/TT') \ .replace('/%exchange_id.int', '/%s' % exchange_id) \ .replace('/%redirect_to', '/giving') \ .replace('/%endpoint', '/public') \ .replace('/about/me/%sub', '/about/me') assert '/%' not in url if 'index' in url.split('/')[-1]: url = url.rsplit('/', 1)[0] + '/' urls.append(url) urls.extend(""" /about/me /about/me/ /about/me/history """.split()) for url in urls: try: r = self.client.GET(url, **kw) except Response as r: if r.code == 404 or r.code >= 500: raise assert r.code != 404 assert r.code < 500 assert not overescaping_re.search(r.body.decode('utf8'))
def browse(self, **kw): alice = self.make_participant('alice', claimed_time='now') alice.insert_into_communities(True, 'Wonderland', 'wonderland') i = len(self.client.www_root) for spt in find_files(self.client.www_root, '*.spt'): url = spt[i:-4].replace('/%username/', 'alice') \ .replace('/for/%slug/', '/for/wonderland/') \ .replace('/%platform/', '/github/') \ .replace('/%user_name/', '/Gratipay/') if 'index' in url.split('/')[-1]: url = url.rsplit('/', 1)[0] + '/' try: r = self.client.GET(url, **kw) except Response as r: pass assert r.code < 500
def browse(self, setup=None, **kw): alice = self.make_participant("alice", claimed_time="now", number="plural") exchange_id = self.make_exchange("balanced-cc", 19, 0, alice) alice.insert_into_communities(True, "Wonderland", "wonderland") alan = self.make_participant("alan", claimed_time="now") alice.add_member(alan) if setup: setup(alice) i = len(self.client.www_root) urls = [] for spt in find_files(self.client.www_root, "*.spt"): url = ( spt[i:-4] .replace("/%team/", "/alice/") .replace("/alice/%sub", "/alice/foo") .replace("/~/%username/", "/~alice/") .replace("/for/%slug/", "/for/wonderland/") .replace("/%platform/", "/github/") .replace("/%user_name/", "/gratipay/") .replace("/%membername", "/alan") .replace("/%exchange_id.int", "/%s" % exchange_id) .replace("/%redirect_to", "/giving") .replace("/%endpoint", "/public") .replace("/about/me/%sub", "/about/me") ) assert "/%" not in url if "index" in url.split("/")[-1]: url = url.rsplit("/", 1)[0] + "/" urls.append(url) urls.extend( """ /about/me /about/me/ /about/me/history """.split() ) for url in urls: try: r = self.client.GET(url, **kw) except Response as r: if r.code == 404 or r.code >= 500: raise assert r.code != 404 assert r.code < 500 assert not overescaping_re.search(r.body.decode("utf8"))
def browse(self, setup=None, **kw): alice = self.make_participant('alice', claimed_time='now') exchange_id = self.make_exchange('braintree-cc', 19, 0, alice) if setup: setup(alice) i = len(self.client.www_root) urls = [] for spt in find_files(self.client.www_root, '*.spt'): url = spt[i:-4].replace('/%team/', '/alice/') \ .replace('/alice/%sub', '/alice/foo') \ .replace('/~/%username/', '/~alice/') \ .replace('/for/%slug/', '/for/wonderland/') \ .replace('/%platform/', '/github/') \ .replace('/%user_name/', '/gratipay/') \ .replace('/%membername', '/alan') \ .replace('/%exchange_id.int', '/%s' % exchange_id) \ .replace('/%redirect_to', '/giving') \ .replace('/%endpoint', '/public') \ .replace('/about/me/%sub', '/about/me') assert '/%' not in url if 'index' in url.split('/')[-1]: url = url.rsplit('/', 1)[0] + '/' urls.append(url) urls.extend(""" /about/me /about/me/ /about/me/history """.split()) for url in urls: try: r = self.client.GET(url, **kw) except Response as r: if r.code == 404 or r.code >= 500: raise assert r.code != 404 assert r.code < 500 assert not overescaping_re.search(r.body.decode('utf8'))
def browse(self, setup=None, **kw): alice = self.make_participant('alice', claimed_time='now') # for pricing page self.make_team('Gratipay') # for the pfos invoice page pfos = self.make_payment_for_open_source() pfos_base = '/payments/{}'.format(pfos.id) # for the receipt page result = braintree.PaymentMethod.create({ "customer_id": alice.get_braintree_account().id, "payment_method_nonce": Nonces.Transactable }) assert result.is_success address = result.payment_method.token exchange_id = self.make_exchange('braintree-cc', 19, 0, alice, address=address) # for npm page self.db.run(""" INSERT INTO packages (package_manager, name, description, emails) VALUES ('npm', 'foo-package', 'A package', ARRAY[]::text[]) , ('npm', '@foo/package', 'A scoped package', ARRAY[]::text[]) """) if setup: setup(alice) i = len(self.client.www_root) urls = [] for spt in find_files(self.client.www_root, '*.spt'): url = spt[i:-4].replace('/%team/', '/Gratipay/') \ .replace('/Gratipay/%sub', '/alice/foo') \ .replace('/~/%username/', '/~alice/') \ .replace('/for/%slug/', '/for/wonderland/') \ .replace('/%platform/', '/github/') \ .replace('/%package', '/foo-package') \ .replace('/%user_name/', '/gratipay/') \ .replace('/%to', '/1') \ .replace('/%country', '/TT') \ .replace('/%exchange_id', '/%s' % exchange_id) \ .replace('/%redirect_to', '/giving') \ .replace('/%endpoint', '/public') \ .replace('/payments/%pfos', pfos_base) \ .replace( pfos_base+'/invoice' , pfos_base+'/invoice?secret='+pfos.secret )\ .replace('/about/me/%sub', '/about/me') assert '/%' not in url if 'index' in url.split('/')[-1]: url = url.rsplit('/', 1)[0] + '/' urls.append(url) urls.extend(""" /about/me /about/me/ /about/me/history /on/npm/@foo/package """.split()) for url in urls: try: r = self.client.GET(url, **kw) except Response as r: if r.code == 404 or r.code >= 500: raise assert r.code != 404 assert r.code < 500 type_in = lambda *x: any([r.headers['Content-Type'].startswith(y) for y in x]) if r.code == 200 and type_in('text', 'application/json'): assert not overescaping_re.search(r.body.decode('utf8'))