Skip to content

Commit

Permalink
dont repeat "ClientCertificate" in enum values
Browse files Browse the repository at this point in the history
  • Loading branch information
jtattermusch committed Oct 5, 2018
1 parent 209aee1 commit 460faf4
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 23 deletions.
18 changes: 9 additions & 9 deletions src/csharp/Grpc.Core/ServerCredentials.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public enum SslClientCertificateRequestType {
/// all. (A client may present a self signed or signed certificate or not
/// present a certificate at all and any of those option would be accepted)
/// </summary>
DontRequestClientCertificate = 0,
DontRequest = 0,
/// <summary>
/// Server requests client certificate but does not enforce that the client
/// presents a certificate.
Expand All @@ -78,7 +78,7 @@ public enum SslClientCertificateRequestType {
/// The client's key certificate pair must be valid for the SSL connection to
/// be established.
///</summary>
RequestClientCertificateButDontVerify,
RequestButDontVerify,
/// <summary>
/// Server requests client certificate but does not enforce that the client
/// presents a certificate.
Expand All @@ -89,7 +89,7 @@ public enum SslClientCertificateRequestType {
/// The client's key certificate pair must be valid for the SSL connection to
/// be established.
/// </summary>
RequestClientCertificateAndVerify,
RequestAndVerify,
/// <summary>
/// Server requests client certificate and enforces that the client presents a
/// certificate.
Expand All @@ -99,7 +99,7 @@ public enum SslClientCertificateRequestType {
/// The client's key certificate pair must be valid for the SSL connection to
/// be established.
///</summary>
RequestAndRequireClientCertificateButDontVerify,
RequestAndRequireButDontVerify,
/// <summary>
/// Server requests client certificate and enforces that the client presents a
/// certificate.
Expand All @@ -109,7 +109,7 @@ public enum SslClientCertificateRequestType {
/// The client's key certificate pair must be valid for the SSL connection to
/// be established.
/// </summary>
RequestAndRequireClientCertificateAndVerify,
RequestAndRequireAndVerify,
}
/// <summary>
/// Server-side SSL credentials.
Expand All @@ -127,7 +127,7 @@ public class SslServerCredentials : ServerCredentials
/// <param name="rootCertificates">PEM encoded client root certificates used to authenticate client.</param>
/// <param name="forceClientAuth">Deprecated, use clientCertificateRequest overload instead.</param>
public SslServerCredentials(IEnumerable<KeyCertificatePair> keyCertificatePairs, string rootCertificates, bool forceClientAuth)
: this(keyCertificatePairs, rootCertificates, forceClientAuth ? SslClientCertificateRequestType.RequestAndRequireClientCertificateAndVerify : SslClientCertificateRequestType.DontRequestClientCertificate)
: this(keyCertificatePairs, rootCertificates, forceClientAuth ? SslClientCertificateRequestType.RequestAndRequireAndVerify : SslClientCertificateRequestType.DontRequest)
{
}

Expand All @@ -142,7 +142,7 @@ public SslServerCredentials(IEnumerable<KeyCertificatePair> keyCertificatePairs,
this.keyCertificatePairs = new List<KeyCertificatePair>(keyCertificatePairs).AsReadOnly();
GrpcPreconditions.CheckArgument(this.keyCertificatePairs.Count > 0,
"At least one KeyCertificatePair needs to be provided.");
if (clientCertificateRequest == SslClientCertificateRequestType.RequestAndRequireClientCertificateAndVerify)
if (clientCertificateRequest == SslClientCertificateRequestType.RequestAndRequireAndVerify)
{
GrpcPreconditions.CheckNotNull(rootCertificates,
"Cannot require and verify client certificate unless you provide rootCertificates.");
Expand All @@ -157,7 +157,7 @@ public SslServerCredentials(IEnumerable<KeyCertificatePair> keyCertificatePairs,
/// (client certificate won't be requested and checked by the server at all).
/// </summary>
/// <param name="keyCertificatePairs">Key-certificates to use.</param>
public SslServerCredentials(IEnumerable<KeyCertificatePair> keyCertificatePairs) : this(keyCertificatePairs, null, SslClientCertificateRequestType.DontRequestClientCertificate)
public SslServerCredentials(IEnumerable<KeyCertificatePair> keyCertificatePairs) : this(keyCertificatePairs, null, SslClientCertificateRequestType.DontRequest)
{
}

Expand Down Expand Up @@ -190,7 +190,7 @@ public bool ForceClientAuthentication
{
get
{
return this.clientCertificateRequest == SslClientCertificateRequestType.RequestAndRequireClientCertificateAndVerify;
return this.clientCertificateRequest == SslClientCertificateRequestType.RequestAndRequireAndVerify;
}
}

Expand Down
28 changes: 14 additions & 14 deletions src/csharp/Grpc.IntegrationTesting/SslCredentialsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public async Task NoClientCert_DontRequestClientCertificate_Accepted()
{
InitClientAndServer(
clientAddKeyCertPair: false,
clientCertRequestType: SslClientCertificateRequestType.DontRequestClientCertificate);
clientCertRequestType: SslClientCertificateRequestType.DontRequest);

await CheckAccepted(expectPeerAuthenticated: false);
}
Expand All @@ -101,7 +101,7 @@ public async Task ClientWithCert_DontRequestClientCertificate_AcceptedButPeerNot
{
InitClientAndServer(
clientAddKeyCertPair: true,
clientCertRequestType: SslClientCertificateRequestType.DontRequestClientCertificate);
clientCertRequestType: SslClientCertificateRequestType.DontRequest);

await CheckAccepted(expectPeerAuthenticated: false);
}
Expand All @@ -111,7 +111,7 @@ public async Task NoClientCert_RequestClientCertificateButDontVerify_Accepted()
{
InitClientAndServer(
clientAddKeyCertPair: false,
clientCertRequestType: SslClientCertificateRequestType.RequestClientCertificateButDontVerify);
clientCertRequestType: SslClientCertificateRequestType.RequestButDontVerify);

await CheckAccepted(expectPeerAuthenticated: false);
}
Expand All @@ -121,7 +121,7 @@ public async Task NoClientCert_RequestClientCertificateAndVerify_Accepted()
{
InitClientAndServer(
clientAddKeyCertPair: false,
clientCertRequestType: SslClientCertificateRequestType.RequestClientCertificateAndVerify);
clientCertRequestType: SslClientCertificateRequestType.RequestAndVerify);

await CheckAccepted(expectPeerAuthenticated: false);
}
Expand All @@ -131,7 +131,7 @@ public async Task ClientWithCert_RequestAndRequireClientCertificateButDontVerify
{
InitClientAndServer(
clientAddKeyCertPair: true,
clientCertRequestType: SslClientCertificateRequestType.RequestAndRequireClientCertificateButDontVerify);
clientCertRequestType: SslClientCertificateRequestType.RequestAndRequireButDontVerify);

await CheckAccepted(expectPeerAuthenticated: true);
await CheckAuthContextIsPopulated();
Expand All @@ -142,7 +142,7 @@ public async Task ClientWithCert_RequestAndRequireClientCertificateAndVerify_Acc
{
InitClientAndServer(
clientAddKeyCertPair: true,
clientCertRequestType: SslClientCertificateRequestType.RequestAndRequireClientCertificateAndVerify);
clientCertRequestType: SslClientCertificateRequestType.RequestAndRequireAndVerify);

await CheckAccepted(expectPeerAuthenticated: true);
await CheckAuthContextIsPopulated();
Expand All @@ -153,7 +153,7 @@ public void NoClientCert_RequestAndRequireClientCertificateButDontVerify_Rejecte
{
InitClientAndServer(
clientAddKeyCertPair: false,
clientCertRequestType: SslClientCertificateRequestType.RequestAndRequireClientCertificateButDontVerify);
clientCertRequestType: SslClientCertificateRequestType.RequestAndRequireButDontVerify);

CheckRejected();
}
Expand All @@ -163,7 +163,7 @@ public void NoClientCert_RequestAndRequireClientCertificateAndVerify_Rejected()
{
InitClientAndServer(
clientAddKeyCertPair: false,
clientCertRequestType: SslClientCertificateRequestType.RequestAndRequireClientCertificateAndVerify);
clientCertRequestType: SslClientCertificateRequestType.RequestAndRequireAndVerify);

CheckRejected();
}
Expand All @@ -172,20 +172,20 @@ public void NoClientCert_RequestAndRequireClientCertificateAndVerify_Rejected()
public void Constructor_LegacyForceClientAuth()
{
var creds = new SslServerCredentials(new[] { keyCertPair }, rootCert, true);
Assert.AreEqual(SslClientCertificateRequestType.RequestAndRequireClientCertificateAndVerify, creds.ClientCertificateRequest);
Assert.AreEqual(SslClientCertificateRequestType.RequestAndRequireAndVerify, creds.ClientCertificateRequest);

var creds2 = new SslServerCredentials(new[] { keyCertPair }, rootCert, false);
Assert.AreEqual(SslClientCertificateRequestType.DontRequestClientCertificate, creds2.ClientCertificateRequest);
Assert.AreEqual(SslClientCertificateRequestType.DontRequest, creds2.ClientCertificateRequest);
}

[Test]
public void Constructor_NullRootCerts()
{
var keyCertPairs = new[] { keyCertPair };
Assert.DoesNotThrow(() => new SslServerCredentials(keyCertPairs, null, SslClientCertificateRequestType.DontRequestClientCertificate));
Assert.DoesNotThrow(() => new SslServerCredentials(keyCertPairs, null, SslClientCertificateRequestType.RequestClientCertificateAndVerify));
Assert.DoesNotThrow(() => new SslServerCredentials(keyCertPairs, null, SslClientCertificateRequestType.RequestAndRequireClientCertificateButDontVerify));
Assert.Throws(typeof(ArgumentNullException), () => new SslServerCredentials(keyCertPairs, null, SslClientCertificateRequestType.RequestAndRequireClientCertificateAndVerify));
Assert.DoesNotThrow(() => new SslServerCredentials(keyCertPairs, null, SslClientCertificateRequestType.DontRequest));
Assert.DoesNotThrow(() => new SslServerCredentials(keyCertPairs, null, SslClientCertificateRequestType.RequestAndVerify));
Assert.DoesNotThrow(() => new SslServerCredentials(keyCertPairs, null, SslClientCertificateRequestType.RequestAndRequireButDontVerify));
Assert.Throws(typeof(ArgumentNullException), () => new SslServerCredentials(keyCertPairs, null, SslClientCertificateRequestType.RequestAndRequireAndVerify));
}

private async Task CheckAccepted(bool expectPeerAuthenticated)
Expand Down

0 comments on commit 460faf4

Please sign in to comment.