Ejemplo n.º 1
0
def test_get_organizations(deleted, initialized_db):
    # Delete an org.
    deleted_org = get_organization('sellnsmall')
    queue = WorkQueue('testgcnamespace', lambda db: db.transaction())
    mark_namespace_for_deletion(deleted_org, [], queue)

    orgs = get_organizations(deleted=deleted)
    assert orgs

    deleted_found = [org for org in orgs if org.id == deleted_org.id]
    assert bool(deleted_found) == deleted
Ejemplo n.º 2
0
def delete_proxy_cache_config(org_name):
    """
    Delete proxy cache configuration for the given organization name
    """
    org = get_organization(org_name)

    try:
        config = (ProxyCacheConfig.select().where(
            ProxyCacheConfig.organization == org.id)).get()
    except ProxyCacheConfig.DoesNotExist:
        return False

    if config is not None:
        ProxyCacheConfig.delete().where(
            ProxyCacheConfig.organization == org.id).execute()
        return True

    return False
Ejemplo n.º 3
0
def test_delete_robot(initialized_db):
  # Create a robot account.
  user = create_user_noverify('foobar', '*****@*****.**', email_required=False)
  robot, _ = create_robot('foo', user)

  # Add some notifications and other rows pointing to the robot.
  create_notification('repo_push', robot)

  team = create_team('someteam', get_organization('buynlarge'), 'member')
  add_user_to_team(robot, team)

  # Ensure the robot exists.
  assert lookup_robot(robot.username).id == robot.id

  # Delete the robot.
  delete_robot(robot.username)

  # Ensure it is gone.
  with pytest.raises(InvalidRobotException):
    lookup_robot(robot.username)
Ejemplo n.º 4
0
def create_proxy_cache_config(
    org_name,
    upstream_registry,
    upstream_registry_username=None,
    upstream_registry_password=None,
    expiration_s=DEFAULT_PROXY_CACHE_EXPIRATION,
    insecure=False,
):
    """
    Creates proxy cache configuration for the given organization name
    """
    org = get_organization(org_name)

    new_entry = ProxyCacheConfig.create(
        organization=org,
        upstream_registry=upstream_registry,
        upstream_registry_username=upstream_registry_username,
        upstream_registry_password=upstream_registry_password,
        expiration_s=expiration_s,
        insecure=insecure,
    )

    return new_entry