Merge remote-tracking branch 'origin/unittesting'
This commit is contained in:
commit
f5fff3657c
5 changed files with 1315 additions and 14 deletions
|
@ -261,7 +261,6 @@ def convert_user_to_organization():
|
|||
@internal_api_call
|
||||
def change_user_details():
|
||||
user = current_user.db_user()
|
||||
|
||||
user_data = request.get_json()
|
||||
|
||||
try:
|
||||
|
@ -314,6 +313,8 @@ def create_new_user():
|
|||
@internal_api_call
|
||||
def signin_user():
|
||||
signin_data = request.get_json()
|
||||
if not signin_data:
|
||||
abort(404)
|
||||
|
||||
username = signin_data['username']
|
||||
password = signin_data['password']
|
||||
|
@ -420,6 +421,7 @@ def get_matching_entities(prefix):
|
|||
|
||||
team_data = [entity_team_view(team) for team in teams]
|
||||
user_data = [user_view(user) for user in users]
|
||||
|
||||
return jsonify({
|
||||
'results': team_data + user_data
|
||||
})
|
||||
|
@ -445,11 +447,16 @@ def create_organization():
|
|||
existing = None
|
||||
|
||||
try:
|
||||
existing = (model.get_organization(org_data['name']) or
|
||||
model.get_user(org_data['name']))
|
||||
existing = model.get_organization(org_data['name'])
|
||||
except model.InvalidOrganizationException:
|
||||
pass
|
||||
|
||||
if not existing:
|
||||
try:
|
||||
existing = model.get_user(org_data['name'])
|
||||
except model.InvalidUserException:
|
||||
pass
|
||||
|
||||
if existing:
|
||||
msg = 'A user or organization with this name already exists'
|
||||
return request_error(message=msg)
|
||||
|
@ -603,9 +610,9 @@ def create_organization_prototype_permission(orgname):
|
|||
'name' in details['activating_user']):
|
||||
activating_username = details['activating_user']['name']
|
||||
|
||||
delegate = details['delegate']
|
||||
delegate_kind = delegate['kind']
|
||||
delegate_name = delegate['name']
|
||||
delegate = details['delegate'] if 'delegate' in details else {}
|
||||
delegate_kind = delegate.get('kind', None)
|
||||
delegate_name = delegate.get('name', None)
|
||||
|
||||
delegate_username = delegate_name if delegate_kind == 'user' else None
|
||||
delegate_teamname = delegate_name if delegate_kind == 'team' else None
|
||||
|
@ -621,7 +628,7 @@ def create_organization_prototype_permission(orgname):
|
|||
return request_error(message='Unknown activating user')
|
||||
|
||||
if not delegate_user and not delegate_team:
|
||||
return request_error(message='Missing delagate user or team')
|
||||
return request_error(message='Missing delegate user or team')
|
||||
|
||||
role_name = details['role']
|
||||
|
||||
|
@ -1241,7 +1248,11 @@ def create_webhook(namespace, repository):
|
|||
def get_webhook(namespace, repository, public_id):
|
||||
permission = AdministerRepositoryPermission(namespace, repository)
|
||||
if permission.can():
|
||||
webhook = model.get_webhook(namespace, repository, public_id)
|
||||
try:
|
||||
webhook = model.get_webhook(namespace, repository, public_id)
|
||||
except model.InvalidWebhookException:
|
||||
abort(404)
|
||||
|
||||
return jsonify(webhook_view(webhook))
|
||||
|
||||
abort(403) # Permission denied
|
||||
|
@ -1636,7 +1647,11 @@ def list_repo_tokens(namespace, repository):
|
|||
def get_tokens(namespace, repository, code):
|
||||
permission = AdministerRepositoryPermission(namespace, repository)
|
||||
if permission.can():
|
||||
perm = model.get_repo_delegate_token(namespace, repository, code)
|
||||
try:
|
||||
perm = model.get_repo_delegate_token(namespace, repository, code)
|
||||
except model.InvalidTokenException:
|
||||
abort(404)
|
||||
|
||||
return jsonify(token_view(perm))
|
||||
|
||||
abort(403) # Permission denied
|
||||
|
@ -1773,6 +1788,8 @@ def set_card(user, token):
|
|||
cus.save()
|
||||
except stripe.CardError as e:
|
||||
return carderror_response(e)
|
||||
except stripe.InvalidRequestError as e:
|
||||
return carderror_response(e)
|
||||
|
||||
return get_card(user)
|
||||
|
||||
|
|
|
@ -427,6 +427,8 @@ quayApp = angular.module('quay', ['ngRoute', 'chieffancypants.loadingBar', 'rest
|
|||
var planService = {};
|
||||
var listeners = [];
|
||||
|
||||
var previousSubscribeFailure = false;
|
||||
|
||||
planService.getFreePlan = function() {
|
||||
return 'free';
|
||||
};
|
||||
|
@ -616,12 +618,15 @@ quayApp = angular.module('quay', ['ngRoute', 'chieffancypants.loadingBar', 'rest
|
|||
if (orgname && !planService.isOrgCompatible(plan)) { return; }
|
||||
|
||||
planService.getCardInfo(orgname, function(cardInfo) {
|
||||
if (plan.price > 0 && !cardInfo.last4) {
|
||||
if (plan.price > 0 && (previousSubscribeFailure || !cardInfo.last4)) {
|
||||
planService.showSubscribeDialog($scope, orgname, planId, callbacks);
|
||||
return;
|
||||
}
|
||||
|
||||
previousSubscribeFailure = false;
|
||||
|
||||
planService.setSubscription(orgname, planId, callbacks['success'], function(resp) {
|
||||
previousSubscribeFailure = true;
|
||||
planService.handleCardError(resp);
|
||||
callbacks['failure'](resp);
|
||||
});
|
||||
|
|
Binary file not shown.
|
@ -231,9 +231,9 @@ def build_specs():
|
|||
TestSpec(url_for('api.get_webhook', repository=PUBLIC_REPO,
|
||||
public_id=FAKE_WEBHOOK), admin_code=403),
|
||||
TestSpec(url_for('api.get_webhook', repository=ORG_REPO,
|
||||
public_id=FAKE_WEBHOOK), admin_code=400),
|
||||
public_id=FAKE_WEBHOOK), admin_code=404),
|
||||
TestSpec(url_for('api.get_webhook', repository=PRIVATE_REPO,
|
||||
public_id=FAKE_WEBHOOK), admin_code=400),
|
||||
public_id=FAKE_WEBHOOK), admin_code=404),
|
||||
|
||||
TestSpec(url_for('api.list_webhooks', repository=PUBLIC_REPO),
|
||||
admin_code=403),
|
||||
|
@ -382,9 +382,9 @@ def build_specs():
|
|||
TestSpec(url_for('api.get_tokens', repository=PUBLIC_REPO,
|
||||
code=FAKE_TOKEN), admin_code=403),
|
||||
TestSpec(url_for('api.get_tokens', repository=ORG_REPO, code=FAKE_TOKEN),
|
||||
admin_code=400),
|
||||
admin_code=404),
|
||||
TestSpec(url_for('api.get_tokens', repository=PRIVATE_REPO,
|
||||
code=FAKE_TOKEN), admin_code=400),
|
||||
code=FAKE_TOKEN), admin_code=404),
|
||||
|
||||
TestSpec(url_for('api.create_token', repository=PUBLIC_REPO),
|
||||
admin_code=403).set_method('POST'),
|
||||
|
|
1279
test/test_api_usage.py
Normal file
1279
test/test_api_usage.py
Normal file
File diff suppressed because it is too large
Load diff
Reference in a new issue