Skip to content

CDRIVER-5952 remove deprecated URI API #1963

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ Unreleased (2.0.0)
* `mongoc_stream_tls_do_handshake` is removed. Use `mongoc_stream_tls_handshake` instead.
* `mongoc_stream_tls_check_cert` is removed. Use `mongoc_stream_tls_handshake` instead.
* `mongoc_stream_tls_new` is removed. Use `mongoc_stream_tls_new_with_hostname` instead.
* Deprecated URI API has been removed:
* `mongoc_uri_get_service` is removed. Use `mongoc_uri_get_srv_hostname` instead.
* `mongoc_uri_get_read_prefs` is removed. Use `mongoc_uri_get_read_prefs_t` instead.
* `mongoc_uri_get_ssl` is removed. Use `mongoc_uri_get_tls` instead.

### Forwarding headers (`#include <bson.h>` and `#include <mongoc.h>`)

Expand Down
33 changes: 0 additions & 33 deletions src/libmongoc/doc/mongoc_uri_get_read_prefs.rst

This file was deleted.

29 changes: 0 additions & 29 deletions src/libmongoc/doc/mongoc_uri_get_service.rst

This file was deleted.

34 changes: 0 additions & 34 deletions src/libmongoc/doc/mongoc_uri_get_ssl.rst

This file was deleted.

3 changes: 0 additions & 3 deletions src/libmongoc/doc/mongoc_uri_t.rst
Original file line number Diff line number Diff line change
Expand Up @@ -349,12 +349,9 @@ MONGOC_URI_SAFE safe {tr
mongoc_uri_get_options
mongoc_uri_get_password
mongoc_uri_get_read_concern
mongoc_uri_get_read_prefs
mongoc_uri_get_read_prefs_t
mongoc_uri_get_replica_set
mongoc_uri_get_server_monitoring_mode
mongoc_uri_get_service
mongoc_uri_get_ssl
mongoc_uri_get_string
mongoc_uri_get_srv_hostname
mongoc_uri_get_srv_service_name
Expand Down
19 changes: 0 additions & 19 deletions src/libmongoc/src/mongoc/mongoc-uri.c
Original file line number Diff line number Diff line change
Expand Up @@ -2555,13 +2555,6 @@ mongoc_uri_get_srv_hostname (const mongoc_uri_t *uri)
}


const char *
mongoc_uri_get_service (const mongoc_uri_t *uri)
{
return mongoc_uri_get_srv_hostname (uri);
}


/* Initial DNS Seedlist Discovery Spec: `srvServiceName` requires a string value
* and defaults to "mongodb". */
static const char *const mongoc_default_srv_service_name = "mongodb";
Expand Down Expand Up @@ -2664,13 +2657,6 @@ mongoc_uri_get_string (const mongoc_uri_t *uri)
}


const bson_t *
mongoc_uri_get_read_prefs (const mongoc_uri_t *uri)
{
BSON_ASSERT (uri);
return mongoc_read_prefs_get_tags (uri->read_prefs);
}

char *
mongoc_uri_unescape (const char *escaped_string)
{
Expand Down Expand Up @@ -2824,11 +2810,6 @@ mongoc_uri_get_tls (const mongoc_uri_t *uri) /* IN */
return false;
}

bool
mongoc_uri_get_ssl (const mongoc_uri_t *uri) /* IN */
{
return mongoc_uri_get_tls (uri);
}

const char *
mongoc_uri_get_server_monitoring_mode (const mongoc_uri_t *uri)
Expand Down
8 changes: 0 additions & 8 deletions src/libmongoc/src/mongoc/mongoc-uri.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,6 @@ mongoc_uri_new_for_host_port (const char *hostname, uint16_t port) BSON_GNUC_WAR
MONGOC_EXPORT (const mongoc_host_list_t *)
mongoc_uri_get_hosts (const mongoc_uri_t *uri);

BSON_DEPRECATED_FOR (mongoc_uri_get_srv_hostname)
MONGOC_EXPORT (const char *) mongoc_uri_get_service (const mongoc_uri_t *uri);

MONGOC_EXPORT (const char *)
mongoc_uri_get_srv_hostname (const mongoc_uri_t *uri);

Expand Down Expand Up @@ -174,9 +171,6 @@ mongoc_uri_set_option_as_bool (mongoc_uri_t *uri, const char *option, bool value
MONGOC_EXPORT (bool)
mongoc_uri_set_option_as_utf8 (mongoc_uri_t *uri, const char *option, const char *value);

BSON_DEPRECATED_FOR (mongoc_uri_get_read_prefs_t)
MONGOC_EXPORT (const bson_t *) mongoc_uri_get_read_prefs (const mongoc_uri_t *uri);

MONGOC_EXPORT (const char *)
mongoc_uri_get_replica_set (const mongoc_uri_t *uri);

Expand Down Expand Up @@ -219,8 +213,6 @@ mongoc_uri_get_mechanism_properties (const mongoc_uri_t *uri, bson_t *properties
MONGOC_EXPORT (bool)
mongoc_uri_set_mechanism_properties (mongoc_uri_t *uri, const bson_t *properties);

BSON_DEPRECATED_FOR (mongoc_uri_get_tls) MONGOC_EXPORT (bool) mongoc_uri_get_ssl (const mongoc_uri_t *uri);

MONGOC_EXPORT (bool)
mongoc_uri_get_tls (const mongoc_uri_t *uri);

Expand Down
11 changes: 2 additions & 9 deletions src/libmongoc/tests/test-mongoc-uri.c
Original file line number Diff line number Diff line change
Expand Up @@ -2351,21 +2351,18 @@ test_mongoc_uri_tls_ssl (const char *tls,

bson_snprintf (url_buffer, sizeof (url_buffer), "mongodb://localhost/?%s=foo.pem", tlsCertificateKeyFile);
uri = mongoc_uri_new (url_buffer);
ASSERT (mongoc_uri_get_ssl (uri));
ASSERT (mongoc_uri_get_tls (uri));
mongoc_uri_destroy (uri);


bson_snprintf (url_buffer, sizeof (url_buffer), "mongodb://localhost/?%s=foo.pem", tlsCAFile);
uri = mongoc_uri_new (url_buffer);
ASSERT (mongoc_uri_get_ssl (uri));
ASSERT (mongoc_uri_get_tls (uri));
mongoc_uri_destroy (uri);


bson_snprintf (url_buffer, sizeof (url_buffer), "mongodb://localhost/?%s=true", tlsAllowInvalidCertificates);
uri = mongoc_uri_new (url_buffer);
ASSERT (mongoc_uri_get_ssl (uri));
ASSERT (mongoc_uri_get_tls (uri));
ASSERT (mongoc_uri_get_option_as_bool (uri, MONGOC_URI_SSLALLOWINVALIDCERTIFICATES, false));
ASSERT (mongoc_uri_get_option_as_bool (uri, MONGOC_URI_TLSALLOWINVALIDCERTIFICATES, false));
Expand All @@ -2374,7 +2371,6 @@ test_mongoc_uri_tls_ssl (const char *tls,

bson_snprintf (url_buffer, sizeof (url_buffer), "mongodb://localhost/?%s=true", tlsAllowInvalidHostnames);
uri = mongoc_uri_new (url_buffer);
ASSERT (mongoc_uri_get_ssl (uri));
ASSERT (mongoc_uri_get_tls (uri));
ASSERT (mongoc_uri_get_option_as_bool (uri, MONGOC_URI_SSLALLOWINVALIDHOSTNAMES, false));
ASSERT (mongoc_uri_get_option_as_bool (uri, MONGOC_URI_TLSALLOWINVALIDHOSTNAMES, false));
Expand All @@ -2384,23 +2380,20 @@ test_mongoc_uri_tls_ssl (const char *tls,
bson_snprintf (
url_buffer, sizeof (url_buffer), "mongodb://localhost/?%s=false&%s=foo.pem", tls, tlsCertificateKeyFile);
uri = mongoc_uri_new (url_buffer);
ASSERT (!mongoc_uri_get_ssl (uri));
ASSERT (!mongoc_uri_get_tls (uri));
mongoc_uri_destroy (uri);


bson_snprintf (
url_buffer, sizeof (url_buffer), "mongodb://localhost/?%s=false&%s=foo.pem", tls, tlsCertificateKeyFile);
uri = mongoc_uri_new (url_buffer);
ASSERT (!mongoc_uri_get_ssl (uri));
ASSERT (!mongoc_uri_get_tls (uri));
mongoc_uri_destroy (uri);


bson_snprintf (
url_buffer, sizeof (url_buffer), "mongodb://localhost/?%s=false&%s=true", tls, tlsAllowInvalidCertificates);
uri = mongoc_uri_new (url_buffer);
ASSERT (!mongoc_uri_get_ssl (uri));
ASSERT (!mongoc_uri_get_tls (uri));
ASSERT (mongoc_uri_get_option_as_bool (uri, MONGOC_URI_SSLALLOWINVALIDCERTIFICATES, false));
ASSERT (mongoc_uri_get_option_as_bool (uri, MONGOC_URI_TLSALLOWINVALIDCERTIFICATES, false));
Expand All @@ -2410,7 +2403,6 @@ test_mongoc_uri_tls_ssl (const char *tls,
bson_snprintf (
url_buffer, sizeof (url_buffer), "mongodb://localhost/?%s=false&%s=false", tls, tlsAllowInvalidHostnames);
uri = mongoc_uri_new (url_buffer);
ASSERT (!mongoc_uri_get_ssl (uri));
ASSERT (!mongoc_uri_get_tls (uri));
ASSERT (!mongoc_uri_get_option_as_bool (uri, MONGOC_URI_SSLALLOWINVALIDHOSTNAMES, true));
ASSERT (!mongoc_uri_get_option_as_bool (uri, MONGOC_URI_TLSALLOWINVALIDHOSTNAMES, true));
Expand Down Expand Up @@ -2917,7 +2909,8 @@ test_mongoc_uri_duplicates (void)
RECREATE_URI (MONGOC_URI_READPREFERENCE "=secondary&" MONGOC_URI_READPREFERENCETAGS
"=a:x&" MONGOC_URI_READPREFERENCETAGS "=b:y");
ASSERT_NO_CAPTURED_LOGS (mongoc_uri_get_string (uri));
bson = mongoc_uri_get_read_prefs (uri);
rp = mongoc_uri_get_read_prefs_t (uri);
bson = mongoc_read_prefs_get_tags (rp);
ASSERT_EQUAL_BSON (tmp_bson ("[{'a': 'x'}, {'b': 'y'}]"), bson);

RECREATE_URI (MONGOC_URI_REPLICASET "=a&" MONGOC_URI_REPLICASET "=b");
Expand Down