Beispiel #1
0
 def login(self, secret, username, password):
     r = self.get("session")
     data = get_form_data(r.content, action="/session")
     data['login'] = username
     data['password'] = password
     r = self.post("session", data=data)
     data = get_form_data(r.content, action="/sessions/two-factor")
     data['otp'] = TOTP(secret).now()
     r = self.post("sessions/two-factor", data=data)
Beispiel #2
0
 def delete_app(self):
     r = self.get(f"settings/apps/{self.app_id}/advanced")
     soup = BeautifulSoup(r.content, 'html5lib')
     form = soup.find('input', id='confirm-delete-app').parent.parent
     data = get_form_data(form=form)
     data['verify'] = self.app_name
     r = self.post(f"settings/apps/{self.app_id}", data=data)
     self.state['app'] = None
Beispiel #3
0
 def get_app_data(self) -> dict:
     r = self.get(f"settings/apps/{self.app_id}")
     if r.status_code == 200:
         soup = BeautifulSoup(r.content, 'html5lib')
         form = soup.find('form', class_='edit_integration')
         data = {}
         for key, value in get_form_data(form=form).items():
             if key.startswith('integration'):
                 name = key[len('integration') +
                            1:key.find(']')] + key[key.find(']') + 1:]
                 data[name] = value
         return data
     return {}
Beispiel #4
0
    def create_app(self):
        app = json.dumps(self.manifest)
        r = self.post("settings/apps/new", data={'manifest': app})

        soup = BeautifulSoup(r.content, 'html5lib')
        error = soup.find('div', class_='manifest-errors')
        if error:
            raise ValueError([
                e.text.strip()
                for e in error.parent.find_all('strong', class_='text-red')
            ])

        data = get_form_data(r.content, id='new_integration_manifest')
        r = self.post("settings/apps", data=data)
        soup = BeautifulSoup(r.content, 'html5lib')
        errors = soup.find_all('dd', class_='error')
        if errors:
            raise ValueError([e.text.strip() for e in errors])
        redirect = soup.find('a', id="redirect")['href']
        code = parse_qs(urlparse(redirect).query)['code'][0]
        r = self.session.post(
            f"https://api.github.com/app-manifests/{code}/conversions",
            headers={'Accept': 'application/vnd.github.fury-preview+json'})
        self.state['app'] = r.json()
Beispiel #5
0
 def install_app(self):
     r = self.get(f"apps/{self.app_id}/installations/new")
     data = get_form_data(r.content, class_='js-integrations-install-form')
     data['install_target'] = 'all'
     r = self.post(f"apps/{self.app_id}/installations", data=data)