How to use okta - 10 common examples

To help you get started, we’ve selected a few okta examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github okta / okta-sdk-python / tests / unit / test_client.py View on Github external
def test_constructor_user_config_url_empty():
    config = {'orgUrl': '', 'token': 'TOKEN'}
    with pytest.raises(ValueError) as exception_info:
        OktaClient(user_config=config)
    assert ERROR_MESSAGE_ORG_URL_MISSING in str(exception_info.value)
github okta / okta-sdk-python / tests / unit / test_client.py View on Github external
def test_constructor_local_config_SSWS(fs):
    fs.pause()
    local_sample = os.path.join(os.path.dirname(
        __file__), "files", "SSWS-sample-local.yaml")
    with open(local_sample) as file:
        local_config = yaml.load(file, Loader=yaml.SafeLoader)
        org_url = local_config["okta"]["client"]["orgUrl"]
        token = local_config["okta"]["client"]["token"]
        fs.resume()
        fs.create_file(_LOCAL_YAML_PATH, contents=yaml.dump(local_config))

    client = OktaClient()
    loaded_config = client.get_config()

    assert org_url == loaded_config['client']['orgUrl']
    assert token == loaded_config['client']['token']
github okta / okta-sdk-python / tests / unit / test_client.py View on Github external
fs.pause()
    local_sample = os.path.join(os.path.dirname(
        __file__), "files", "SSWS-sample-local.yaml")
    with open(local_sample) as file:
        local_config = yaml.load(file, Loader=yaml.SafeLoader)
        local_org_url = local_config["okta"]["client"]["orgUrl"]
        local_token = local_config["okta"]["client"]["token"]
        fs.resume()
        fs.create_file(_LOCAL_YAML_PATH, contents=yaml.dump(local_config))
    # Setup env. vars
    env_org_url = "https://test.env.okta.com"
    env_token = "envTOKEN"
    os.environ["OKTA_CLIENT_ORGURL"] = env_org_url
    os.environ["OKTA_CLIENT_TOKEN"] = env_token

    client = OktaClient()
    loaded_config = client.get_config()

    os.environ.pop("OKTA_CLIENT_ORGURL")
    os.environ.pop("OKTA_CLIENT_TOKEN")

    assert local_org_url != loaded_config['client']['orgUrl']
    assert local_token != loaded_config['client']['token']
    assert local_org_url != env_org_url
    assert local_token != env_token
    assert env_org_url == loaded_config['client']['orgUrl']
    assert env_token == loaded_config['client']['token']
github okta / okta-sdk-python / tests / unit / test_client.py View on Github external
fs.resume()
        fs.create_file(_GLOBAL_YAML_PATH, contents=yaml.dump(global_config))

    # Setup Local config
    fs.pause()
    local_sample = os.path.join(os.path.dirname(
        __file__), "files", "SSWS-sample-local.yaml")
    with open(local_sample) as file:
        local_config = yaml.load(file, Loader=yaml.SafeLoader)
        local_org_url = local_config["okta"]["client"]["orgUrl"]
        local_token = local_config["okta"]["client"]["token"]
        fs.resume()
        fs.create_file(_LOCAL_YAML_PATH, contents=yaml.dump(local_config))

    # Create client and validate values
    client = OktaClient()
    loaded_config = client.get_config()

    assert local_org_url == loaded_config['client']['orgUrl']
    assert local_token == loaded_config['client']['token']
    assert local_org_url != global_org_url
    assert local_token != global_token
    assert global_org_url != loaded_config['client']['orgUrl']
    assert global_token != loaded_config['client']['token']
github okta / okta-sdk-python / tests / unit / test_client.py View on Github external
def test_constructor_user_config_token_empty(fs):
    config = {'orgUrl': 'https://test.okta.com', 'token': ''}
    with pytest.raises(ValueError) as exception_info:
        OktaClient(user_config=config)
    assert ERROR_MESSAGE_API_TOKEN_MISSING in str(exception_info.value)
github okta / okta-sdk-python / tests / unit / test_client.py View on Github external
def test_constructor_user_config_PK_client_id_empty():
    org_url = "https://test.okta.com"
    authorizationMode = "PrivateKey"
    scopes = ["scope1"]
    private_key_hash = "private key hash"

    config = {
        'orgUrl': org_url,
        'authorizationMode': authorizationMode,
        'clientId': "",
        'scopes': scopes,
        'privateKey': private_key_hash
    }
    with pytest.raises(ValueError) as exception_info:
        OktaClient(user_config=config)
    assert all(string in str(exception_info.value) for string in [
               ERROR_MESSAGE_CLIENT_ID_MISSING
               ])
github okta / okta-sdk-python / tests / unit / test_client.py View on Github external
def test_constructor_user_config_url_has_yourOktaDomain():
    config = {
        'orgUrl': 'https://{yourOktaDomain}.okta.com', 'token': 'TOKEN'
    }
    with pytest.raises(ValueError) as exception_info:
        OktaClient(user_config=config)
    assert ERROR_MESSAGE_ORG_URL_YOUROKTADOMAIN in str(exception_info.value)
github okta / okta-sdk-python / tests / unit / test_client.py View on Github external
def test_constructor_user_config_PK_client_id_default():
    org_url = "https://test.okta.com"
    authorizationMode = "PrivateKey"
    scopes = ["scope1"]
    private_key_hash = "private key hash"

    config = {
        'orgUrl': org_url,
        'authorizationMode': authorizationMode,
        'clientId': "{clientId}",
        'scopes': scopes,
        'privateKey': private_key_hash
    }
    with pytest.raises(ValueError) as exception_info:
        OktaClient(user_config=config)
    assert all(string in str(exception_info.value) for string in [
               ERROR_MESSAGE_CLIENT_ID_DEFAULT
               ])
github okta / okta-sdk-python / tests / unit / test_client.py View on Github external
def test_constructor_user_config_url_has_admin(url):
    config = {
        'orgUrl': url, 'token': 'TOKEN'
    }
    with pytest.raises(ValueError) as exception_info:
        OktaClient(user_config=config)
    assert all(string in str(exception_info.value) for string in [
               ERROR_MESSAGE_ORG_URL_ADMIN, f"Current value: {url}"])
github okta / okta-sdk-python / tests / unit / test_client.py View on Github external
def test_constructor_user_config_url_dot_com_twice():
    url = 'https://test.okta.com.com'
    config = {
        'orgUrl': url, 'token': 'TOKEN'
    }
    with pytest.raises(ValueError) as exception_info:
        OktaClient(user_config=config)
    assert all(string in str(exception_info.value) for string in [
               ERROR_MESSAGE_ORG_URL_TYPO, f"Current value: {url}"])