# -*- mode: python -*-
Import("env")
Import("get_option")
Import("has_feature_option")

env = env.Clone()

env.Library(
    target='externalsaslauth',
    source=[
        'awsiam_server_mechanism.cpp',
        'cyrus_sasl_server_session.cpp',
        'external_sasl_authentication_session.cpp',
        'gssapi_server_mechanism.cpp',
        'sasl_oidc_server_mechanism.cpp' if has_feature_option('enable-oidc') else [],
    ],
    LIBDEPS=[
        '$BUILD_DIR/mongo/db/auth/saslauth',
    ],
    LIBDEPS_PRIVATE=[
        '$BUILD_DIR/mongo/client/sasl_aws_common' if get_option('ssl') == 'on' else [],
        '$BUILD_DIR/mongo/crypto/jwt',
        '$BUILD_DIR/mongo/db/auth/oidc/oidc' if has_feature_option('enable-oidc') else [],
        '$BUILD_DIR/mongo/db/auth/oidc_protocol_messages' if has_feature_option('enable-oidc') else [],
        '$BUILD_DIR/mongo/db/ldap/ldapmanager',
        '$BUILD_DIR/mongo/db/ldap_options',
        '$BUILD_DIR/mongo/db/service_context',
        '$BUILD_DIR/mongo/util/net/http_client',
    ],
    SYSLIBDEPS=[
        'gssapi_krb5',
        'ldap',
        'sasl2',
    ],
)

if has_feature_option('enable-oidc'):
    env.CppUnitTest(
        target='sasl_oidc_test',
        source=[
            'sasl_oidc_server_mechanism_test.cpp',
        ],
        LIBDEPS=[
            '$BUILD_DIR/mongo/db/auth/oidc/oidc',
            'externalsaslauth',
        ],
    )
