Ejemplo n.º 1
0
def funcx_test_config(pytestconfig, funcx_test_config_name):
    # start with basic config load
    config = _CONFIGS[funcx_test_config_name]

    # if `--endpoint` was passed or `endpoint_uuid` is present in config,
    # handle those cases
    endpoint = pytestconfig.getoption("--endpoint")
    if endpoint:
        config["endpoint_uuid"] = endpoint
    elif config["endpoint_uuid"] is None:
        config["endpoint_uuid"] = _get_local_endpoint_id()
    if not config["endpoint_uuid"]:
        # If there's no endpoint_uuid available, the smoke tests won't work
        raise Exception("No target endpoint_uuid available to test against")

    # set URIs if passed
    client_args = config["client_args"]
    ws_uri = pytestconfig.getoption("--ws-uri")
    api_uri = pytestconfig.getoption("--service-address")

    # env vars to allow use of client creds in GitHub Actions
    api_client_id = os.getenv("FUNCX_SMOKE_CLIENT_ID")
    api_client_secret = os.getenv("FUNCX_SMOKE_CLIENT_SECRET")
    if ws_uri:
        client_args["results_ws_uri"] = ws_uri
    if api_uri:
        client_args["funcx_service_address"] = api_uri

    if api_client_id and api_client_secret:
        client = ConfidentialAppAuthClient(api_client_id, api_client_secret)
        scopes = [
            "https://auth.globus.org/scopes/facd7ccc-c5f4-42aa-916b-a0e270e2c2a9/all",
            "urn:globus:auth:scope:search.api.globus.org:all",
            "openid",
        ]

        token_response = client.oauth2_client_credentials_tokens(
            requested_scopes=scopes)
        fx_token = token_response.by_resource_server["funcx_service"][
            "access_token"]
        search_token = token_response.by_resource_server[
            "search.api.globus.org"]["access_token"]
        openid_token = token_response.by_resource_server["auth.globus.org"][
            "access_token"]

        fx_auth = AccessTokenAuthorizer(fx_token)
        search_auth = AccessTokenAuthorizer(search_token)
        openid_auth = AccessTokenAuthorizer(openid_token)

        client_args["fx_authorizer"] = fx_auth
        client_args["search_authorizer"] = search_auth
        client_args["openid_authorizer"] = openid_auth

    return config
Ejemplo n.º 2
0
def start(client_id, client_secret, flow_id=None, flow_scope=None):
    """Use a confidential client to run and monitor a flow.
    """
    global CLIENT_ID
    global CLIENT_SECRET
    global TOKENS
    global FLOW_ID

    if not CLIENT_ID:
        CLIENT_ID = client_id
    if not CLIENT_SECRET:
        CLIENT_SECRET = client_secret

    confidential_client = ConfidentialAppAuthClient(
        client_id=CLIENT_ID, client_secret=CLIENT_SECRET)

    if flow_scope:
        SCOPES.append(FLOW_SCOPE)

    TOKENS = confidential_client.oauth2_client_credentials_tokens(
        requested_scopes=SCOPES)

    cca = ClientCredentialsAuthorizer(
        confidential_client, MANAGE_FLOWS_SCOPE,
        TOKENS.by_resource_server['flows.globus.org']['access_token'],
        TOKENS.by_resource_server['flows.globus.org']['expires_at_seconds'])

    fc = FlowsClient.new_client(client_id=CLIENT_ID,
                                authorizer_callback=authorizer_callback,
                                authorizer=cca)

    #fc.delete_flow(FLOW_ID)
    #flow_id, flow_scope = create_flow(fc, flow_id, flow_scope)
    res = run_and_monitor(fc, FLOW_ID, FLOW_SCOPE)

    if res == "SUCCEEDED":
        return
    else:
        raise Exception("Flow did not succeed")
Ejemplo n.º 3
0
                        required=True,
                        help="API_CLIENT_ID for Globus")
    parser.add_argument("-s",
                        "--secret",
                        required=True,
                        help="API_CLIENT_SECRET for Globus")
    args = parser.parse_args()

    client = ConfidentialAppAuthClient(args.id, args.secret)
    scopes = [
        "https://auth.globus.org/scopes/facd7ccc-c5f4-42aa-916b-a0e270e2c2a9/all",
        "urn:globus:auth:scope:search.api.globus.org:all",
        "openid",
    ]

    token_response = client.oauth2_client_credentials_tokens(
        requested_scopes=scopes)
    fx_token = token_response.by_resource_server["funcx_service"][
        "access_token"]
    search_token = token_response.by_resource_server["search.api.globus.org"][
        "access_token"]
    openid_token = token_response.by_resource_server["auth.globus.org"][
        "access_token"]

    fx_auth = AccessTokenAuthorizer(fx_token)
    search_auth = AccessTokenAuthorizer(search_token)
    openid_auth = AccessTokenAuthorizer(openid_token)

    val = 1
    tt = TestTutorial(fx_auth,
                      search_auth,
                      openid_auth,