def test_get_bug_wrng_api_k(self): """ Wrong API Key, it should raise an Error""" # Load our agent for BMO bmo = BMOAgent('wrong_api_key_test') # Get the bugs from the api bug = bmo.get_bug(656222) print bug
def edit_account(): error = '' message = '' email = '' try: email = request.form['email'] password = request.form['password'] user = User.query.filter_by(email=session['user'].email).first() if verify_account(user, password): newpassword = request.form['newpassword'] if newpassword != request.form['confirmpassword']: raise Exception('Please re-enter the same password') else: session['bmo'] = bmo = BMOAgent(email, newpassword) try: bug = bmo.get_bug('80000') except: error = "Could not get bug, check your account details" salt = os.urandom(8) m = hashlib.md5() m.update(salt) m.update(newpassword) _hash = m.digest() user.hash = _hash.encode('base64') user.salt = salt.encode('base64') user.email = email db.session.commit() session['user'] = user message = 'Account updated' except Exception, e: error = e
def loginSession(user, password): initializeSession() session['logged_in'] = True session['user'] = user session['bmo'] = BMOAgent(user.email, password) session.permanent = True # TODO(lsblak): Make there be a default view available to non-logged in user #view = View.query.filter_by(default=True).filter_by(owner_id=user.id).first() return view_individual(user)
def signup(): error = None try: initializeSession() if request.method == 'GET': products = Product.query.order_by(Product.description).all() return render_template('signup.html', products=products) else: email = request.form['email'] user = User.query.filter_by(email=email).first() if user is not None: raise Exception('User email already exists') password = request.form['password'] if email == '' or password == '': raise Exception('User must have an email and a password!') if password != request.form['confirmpassword']: raise Exception('Please re-enter the same password') try: # verify email and password bmo = BMOAgent(email, password) bug = bmo.get_bug('80000') except Exception, e: raise Exception( 'Failed to verify Bugzilla account on Bugzilla server:' + e) #generate salt, hash and store to db salt = os.urandom(8) m = hashlib.md5() m.update(salt) m.update(password) _hash = m.digest() user = User(email=email, _hash=_hash.encode('base64'), salt=salt.encode('base64')) db.session.add(user) db.session.commit() print 'creating' create_view(user, request) return loginSession(user, password) except Exception, e: print e if error is None: error = e
def test_get_bug_list_wrng_api_k(self): """ Wrong API Key, it should raise an Error""" # Set whatever REST API options we want options = { 'changed_after': ['2012-12-24'], 'changed_before': ['2012-12-27'], 'changed_field': ['status'], 'changed_field_to': ['RESOLVED'], 'product': ['Firefox'], 'resolution': ['FIXED'], 'include_fields': ['attachments'], } # Load our agent for BMO bmo = BMOAgent('wrong_api_key_test') # Get the bugs from the api bmo.get_bug_list(options)
def test_get_bug_list(self): # Set whatever REST API options we want options = { 'changed_after': ['2012-12-24'], 'changed_before': ['2012-12-27'], 'changed_field': ['status'], 'changed_field_to': ['RESOLVED'], 'product': ['Firefox'], 'resolution': ['FIXED'], 'include_fields': ['attachments'], } # Load our agent for BMO bmo = BMOAgent() # Get the bugs from the api buglist = bmo.get_bug_list(options) assert buglist != []
def getBugs(host): # We can use "None" for both instead to not authenticate # username, password = get_credentials() # Load our agent for BMO bmo = BMOAgent(None, None) # Set whatever REST API options we want options = { 'alias': 'reboots-sjc1', } # Get the bugs from the api buglist = bmo.get_bug_list(options) print "Found %s bugs" % (len(buglist)) for bug in buglist: print bug.id, bug.status, bug.summary, bug.blocks, bug.depends_on print bug.id, bug.comments
d["include_fields"] = "_default, attachments, history" return d if __name__ == '__main__': query = sys.argv[1] if query == None: sys.exit("Please specify a query") username, password = get_credentials() # Load our agent for BMO bmo = BMOAgent(username, password) # Get the buglist(s) # import the query buglist = [] if os.path.exists(query): info = {} execfile(query, info) query_name = info['query_name'] if info.has_key('query_url'): buglist = bmo.get_bug_list(query_url_to_dict(info['query_url'])) else: print "Error - no valid query params or url in the config file" sys.exit(1) else:
def test_get_bug(self): # Load our agent for BMO bmo = BMOAgent() # Get the bugs from the api bug = bmo.get_bug(656222) assert bug != []
def initializeSession(): if 'initialized' not in session.keys(): session['initialized'] = True session['bmo'] = BMOAgent('', '') session['vt'] = VersionTracker()