Skip to content

Commit ea5efc6

Browse files
emilienbevjeffrymorris
authored andcommitted
NCBC-4133: Ignore Obsolete warnings stemming from NCBC-4102
Motivation ---------- NCBC-4102 deprecated authentication APIs, which causes multiple warnings to show up in the build. These should be ignored to increase vicibility in the build outputs. Changes ------- - Disabled invidual CS0618 warnings in tests Change-Id: I0a1bdacb52aa95be191bb432bac523bec38050c9 Reviewed-on: https://review.couchbase.org/c/couchbase-net-client/+/239451 Tested-by: Build Bot <build@couchbase.com> Reviewed-by: Jeffry Morris <jeffrymorris@gmail.com>
1 parent fb4d2d1 commit ea5efc6

17 files changed

Lines changed: 58 additions & 0 deletions

File tree

tests/Couchbase.CombinationTests/Tests/Cluster/ClusterTests.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ public async Task Test_Connect_BadPassword_ThrowsAuthenticationFailure()
3232
// NCBC-3000: wrong password raises ServiceNotAvailable instead of AuthenticationFailure
3333
using var loggerFactory = new TestOutputLoggerFactory(_outputHelper);
3434
var clusterOptions = _fixture.GetOptionsFromConfig();
35+
#pragma warning disable CS0618 // Type or member is obsolete
3536
clusterOptions.Password = "WRONG_PASSWORD_ON_PURPOSE";
37+
#pragma warning restore CS0618 // Type or member is obsolete
3638
clusterOptions.WithLogging(loggerFactory);
3739
var t = Couchbase.Cluster.ConnectAsync(clusterOptions);
3840
var ex = await Assert.ThrowsAsync<AuthenticationFailureException>(() => t);
@@ -80,10 +82,12 @@ public async Task Test_HttpConnectionStringWithManagementPort()
8082
var ub = new UriBuilder(fixtureOptions.ConnectionString ?? "http://localhost:8091");
8183
ub.Scheme = "http";
8284
Uri uri = ub.Uri;
85+
#pragma warning disable CS0618 // Type or member is obsolete
8386
ClusterOptions clusterOptions = new ClusterOptions
8487
{
8588
UserName = fixtureOptions.UserName,
8689
Password = fixtureOptions.Password,
90+
#pragma warning restore CS0618 // Type or member is obsolete
8791
TracingOptions = new TracingOptions { Enabled = false },
8892
EnableOperationDurationTracing = false,
8993
OrphanTracingOptions = new OrphanOptions { Enabled = false },

tests/Couchbase.IntegrationTests/ClusterTests.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,9 @@ public async Task Test_Cloud_Default()
168168
// default without overriding any callbacks.
169169
{
170170
// Initialize the Connection
171+
#pragma warning disable CS0618 // Type or member is obsolete
171172
var opts = new ClusterOptions().WithCredentials(username, password);
173+
#pragma warning restore CS0618 // Type or member is obsolete
172174
opts.EnableTls = true;
173175
opts.ForceIpAsTargetHost = false;
174176

@@ -224,9 +226,11 @@ public async Task Test_Cloud_Default()
224226
// If a callback is specified, default certificates should not be used.
225227
{
226228
// Initialize the Connection
229+
#pragma warning disable CS0618 // Type or member is obsolete
227230
var opts = new ClusterOptions().WithCredentials(username, password);
228231
opts.EnableTls = true;
229232
opts.KvCertificateCallbackValidation = (a, b, c, d) => false;
233+
#pragma warning restore CS0618 // Type or member is obsolete
230234

231235
var cluster = await Cluster.ConnectAsync( endpoint, opts);
232236

@@ -244,9 +248,11 @@ public async Task Test_Cloud_Default()
244248
// If a query callback is specified but KV is not, KV should still work.
245249
{
246250
// Initialize the Connection
251+
#pragma warning disable CS0618 // Type or member is obsolete
247252
var opts = new ClusterOptions().WithCredentials(username, password);
248253
opts.EnableTls = true;
249254
opts.HttpCertificateCallbackValidation = (a, b, c, d) => false;
255+
#pragma warning restore CS0618 // Type or member is obsolete
250256

251257
var cluster = await Cluster.ConnectAsync( endpoint, opts);
252258
var bucket = await cluster.BucketAsync(bucketName);
@@ -291,6 +297,7 @@ public async Task Test_Certificates()
291297
// default without overriding any callbacks.
292298
{
293299
// Initialize the Connection
300+
#pragma warning disable CS0618 // Type or member is obsolete
294301
var opts = new ClusterOptions().WithCredentials(username, password);
295302
opts.EnableTls = true;
296303
opts.ForceIpAsTargetHost = false;
@@ -305,6 +312,7 @@ public async Task Test_Certificates()
305312
certs[0] = new X509Certificate2(capemPath);
306313
#endif
307314
opts.WithX509CertificateFactory(CertificateFactory.FromCertificates(certs));
315+
#pragma warning restore CS0618 // Type or member is obsolete
308316

309317
IServiceCollection serviceCollection = new ServiceCollection();
310318
serviceCollection.AddLogging(builder => builder

tests/Couchbase.IntegrationTests/Core/IO/Authentication/SaslTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,10 @@ public async Task Authenticate_Connection()
5050
.CreateAndConnectAsync(endPoint)
5151
;
5252

53+
#pragma warning disable CS0618 // Type or member is obsolete
5354
var sha1Mechanism = new ScramShaMechanism(MechanismType.ScramSha1, options.Password,
5455
options.UserName, new Mock<ILogger<ScramShaMechanism>>().Object, NoopRequestTracer.Instance,
56+
#pragma warning restore CS0618 // Type or member is obsolete
5557
new OperationConfigurator(new JsonTranscoder(), Mock.Of<IOperationCompressor>(),
5658
new DefaultObjectPool<OperationBuilder>(new OperationBuilderPoolPolicy()),
5759
new BestEffortRetryStrategy()));

tests/Couchbase.IntegrationTests/Core/IO/Connections/SslConnectionTests.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public async Task ParallelOperations()
4444
store.AddRange(certs);
4545
var findByValue = certs[0].Thumbprint;
4646
// Find certificate in local store
47+
#pragma warning disable CS0618 // Type or member is obsolete
4748
options?.X509CertificateFactory = CertificateFactory.GetCertificatesFromStore(
4849
new CertificateStoreSearchCriteria
4950
{
@@ -52,6 +53,7 @@ public async Task ParallelOperations()
5253
X509FindType = X509FindType.FindByThumbprint,
5354
FindValue = findByValue
5455
});
56+
#pragma warning restore CS0618 // Type or member is obsolete
5557

5658
await using var cluster =
5759
await Cluster.ConnectAsync(fixture.GetClusterOptions()?.ConnectionString ?? throw new InvalidOperationException(),
@@ -119,6 +121,7 @@ public async Task MultiCertsTest()
119121
store.AddRange(certs);
120122
var findByValue = certs[0].Thumbprint;
121123
// Find certificate in local store
124+
#pragma warning disable CS0618 // Type or member is obsolete
122125
options?.X509CertificateFactory = CertificateFactory.GetCertificatesFromStore(
123126
new CertificateStoreSearchCriteria
124127
{
@@ -127,6 +130,7 @@ public async Task MultiCertsTest()
127130
X509FindType = X509FindType.FindByThumbprint,
128131
FindValue = findByValue
129132
});
133+
#pragma warning restore CS0618 // Type or member is obsolete
130134

131135
var cluster =
132136
await Cluster.ConnectAsync(fixture.GetClusterOptions()?.ConnectionString ?? throw new InvalidOperationException(), options);

tests/Couchbase.LoadTests/Core/IO/Connections/MultiplexingConnectionTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@ public class MultiplexingConnectionTests
1818
[GlobalSetup]
1919
public async Task GlobalSetup()
2020
{
21+
#pragma warning disable CS0618 // Type or member is obsolete
2122
var options = new ClusterOptions()
2223
.WithConnectionString("couchbase://localhost")
2324
.WithCredentials("Administrator", "password");
25+
#pragma warning restore CS0618 // Type or member is obsolete
2426

2527
_cluster = await Cluster.ConnectAsync(options);
2628

tests/Couchbase.LoadTests/Fixtures/ClusterFixture.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@ public class ClusterFixture : IDisposable
1010

1111
public ClusterFixture()
1212
{
13+
#pragma warning disable CS0618 // Type or member is obsolete
1314
Cluster = new Cluster(new ClusterOptions()
1415
.WithConnectionString("couchbase://localhost")
1516
.WithBuckets("default")
1617
.WithCredentials("Administrator", "password"));
18+
#pragma warning restore CS0618 // Type or member is obsolete
1719
}
1820

1921
public async Task<IBucket> GetDefaultBucketAsync()

tests/Couchbase.Stellar.CombinationTests/Fixtures/StellarFixture.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ public StellarFixture()
4343
{
4444
_settings = GetOptionsFromConfig();
4545
Debug.Assert(_settings != null, nameof(_settings) + " != null");
46+
#pragma warning disable CS0618 // Type or member is obsolete
4647
_options = new ClusterOptions
4748
{
4849
UserName = _settings.Username,
@@ -54,6 +55,7 @@ public StellarFixture()
5455
KvCertificateCallbackValidation = (_, _, _, _) => true,
5556
HttpCertificateCallbackValidation = (_, _, _, _) => true
5657
};
58+
#pragma warning restore CS0618 // Type or member is obsolete
5759

5860
IServiceCollection serviceCollection = new ServiceCollection();
5961
serviceCollection.AddLogging(builder => builder

tests/Couchbase.Test.Common/Utils/CouchbaseHasReplicasFact.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,13 @@ public class CouchbaseHasReplicasFact : FactAttribute
3434
(clusterOptions.Buckets.Count > 0 ? clusterOptions.Buckets[0] : "default"); // assume bucket name
3535
versionEndpoint.Query = string.Empty;
3636
versionEndpoint.Port = 8091;
37+
#pragma warning disable CS0618 // Type or member is obsolete
3738
versionEndpoint.UserName = clusterOptions.UserName ?? versionEndpoint.UserName;
3839
versionEndpoint.Password = clusterOptions.Password ?? versionEndpoint.Password;
3940

4041
using var httpClient = new HttpClient();
4142
var authString = $"{clusterOptions.UserName}:{clusterOptions.Password}";
43+
#pragma warning restore CS0618 // Type or member is obsolete
4244
var base64 = Convert.ToBase64String(Encoding.UTF8.GetBytes(authString));
4345
httpClient.DefaultRequestHeaders.Authorization =
4446
new AuthenticationHeaderValue("Basic", base64);

tests/Couchbase.Test.Common/Utils/CouchbaseVersionDependentFact.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,13 @@ public class CouchbaseVersionDependentFact : FactAttribute
4343
versionEndpoint.Path = "versions";
4444
versionEndpoint.Query = string.Empty;
4545
versionEndpoint.Port = 8091;
46+
#pragma warning disable CS0618 // Type or member is obsolete
4647
versionEndpoint.UserName = clusterOptions.UserName ?? versionEndpoint.UserName;
4748
versionEndpoint.Password = clusterOptions.Password ?? versionEndpoint.Password;
4849

4950
using var httpClient = new HttpClient();
5051
var authString = $"{clusterOptions.UserName}:{clusterOptions.Password}";
52+
#pragma warning restore CS0618 // Type or member is obsolete
5153
var base64 = Convert.ToBase64String(Encoding.UTF8.GetBytes(authString));
5254
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", base64);
5355
var responseJsonString = httpClient.GetStringAsync(versionEndpoint.Uri).Result;

tests/Couchbase.UnitTests/ClusterOptionsTests.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,14 @@ public ClusterOptionsTests(ITestOutputHelper output)
2929
[Fact]
3030
public void WhenDnsSrvAllowReconfigure()
3131
{
32+
#pragma warning disable CS0618 // Type or member is obsolete
3233
var options = new ClusterOptions()
3334
{
3435
UserName = "Administrator",
3536
Password = "password",
3637
EnableDnsSrvResolution = true
3738
}.WithConnectionString("dotnet123.cbqeoc.com");
39+
#pragma warning restore CS0618 // Type or member is obsolete
3840

3941
//fake like DNS SRV records were returned
4042
var serversOld = new List<HostEndpoint>
@@ -149,12 +151,15 @@ public void X509Certificate_Is_Null_By_Default()
149151
{
150152
var options = new ClusterOptions();
151153

154+
#pragma warning disable CS0618 // Type or member is obsolete
152155
Assert.Null(options.X509CertificateFactory);
156+
#pragma warning restore CS0618 // Type or member is obsolete
153157
}
154158

155159
[Fact]
156160
public void When_Set_X509Certificate_Is_NotNull_And_EnableTls_True()
157161
{
162+
#pragma warning disable CS0618 // Type or member is obsolete
158163
var options = new ClusterOptions().
159164
WithX509CertificateFactory(CertificateFactory.GetCertificatesFromStore(
160165
new CertificateStoreSearchCriteria
@@ -166,13 +171,16 @@ public void When_Set_X509Certificate_Is_NotNull_And_EnableTls_True()
166171
}));
167172

168173
Assert.NotNull(options.X509CertificateFactory);
174+
#pragma warning restore CS0618 // Type or member is obsolete
169175
Assert.True(options.EffectiveEnableTls);
170176
}
171177

172178
[Fact]
173179
public void When_X509Certificate_Is_Set_To_Null_Throw_NRE()
174180
{
181+
#pragma warning disable CS0618 // Type or member is obsolete
175182
Assert.Throws<NullReferenceException>(() => new ClusterOptions().WithX509CertificateFactory(null));
183+
#pragma warning restore CS0618 // Type or member is obsolete
176184
}
177185

178186
#endregion

0 commit comments

Comments
 (0)