Example #1
0
    def patch(self, id_):
        """
        Update a service account

        Args:
            id_ (str): Google service account identifier to update
        """
        sa = _get_service_account_for_patch(id_)
        error_response = _get_patched_service_account_error_status(id_, sa)
        if error_response.get("success") is not True:
            return error_response, 400
        resp, status_code = self._update_service_account_permissions(sa)
        if status_code != 200:
            return resp, status_code

        # extend access to all datasets
        extend_service_account_access(sa.email)

        return "", 204
Example #2
0
def test_extend_service_account_access(db_session,
                                       register_user_service_account):
    """
    Test that we can successfully update the db and extend access for a
    service account
    """
    service_account = register_user_service_account["service_account"]

    extend_service_account_access(service_account.email)

    service_account_accesses = (
        db_session.query(ServiceAccountToGoogleBucketAccessGroup).filter_by(
            service_account_id=service_account.id)).all()

    assert len(service_account_accesses) == len(
        register_user_service_account["bucket_access_groups"])

    # make sure we actually extended access past the current time
    for access in service_account_accesses:
        assert access.expires > int(time.time())