Skip to content
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

Fix UDS connection exception handling and add test. #5435

Merged
merged 1 commit into from
Mar 5, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,48 @@ public void BasicIdentityOnlyAuthLinux()
}
}

[WcfFact]
[OuterLoop]
public void SocketExceptionHandlingTest()
{
string testString = new string('a', 3000);
IHost host = ServiceHelper.CreateWebHostBuilder<StartUpForUDS>(UDS.GetUDSFilePath());
using (host)
{
System.ServiceModel.ChannelFactory<IEchoService> factory = null;
IEchoService serviceProxy = null;
host.Start();
try
{
System.ServiceModel.UnixDomainSocketBinding binding = new UnixDomainSocketBinding(UnixDomainSocketSecurityMode.None);
var uriBuilder = new UriBuilder()
{
Scheme = "net.uds",
Path = UDS.GetInvalidUDSFilePath()
};
factory = new System.ServiceModel.ChannelFactory<IEchoService>(binding,
new System.ServiceModel.EndpointAddress(uriBuilder.ToString()));
serviceProxy = factory.CreateChannel();
Assert.Throws<EndpointNotFoundException>(() => ((IChannel)serviceProxy).Open());
}
finally
{
ServiceHelper.CloseServiceModelObjects((IChannel)serviceProxy, factory);
}
}
}

public class UDS
{
public static string GetUDSFilePath()
{
return Path.Combine(Path.GetTempPath(), "unix1.txt");
}

public static string GetInvalidUDSFilePath()
{
return Path.Combine(Path.GetTempPath(), "invalid.txt");
}
}

public class StartUpForUDS : UDS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -854,12 +854,11 @@ public async ValueTask<IConnection> ConnectAsync(Uri uri, TimeSpan timeout)
try
{
socketConnection = await CreateConnectionAsync(uri);
lastException = null;
}
catch (SocketException socketException)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
SocketConnectionInitiator.ConvertConnectException(lastException, uri,
SocketConnectionInitiator.ConvertConnectException(socketException, uri,
timeoutHelper.ElapsedTime(), socketException));
}

Expand Down
Loading