Skip to content

Commit

Permalink
Doc and test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
clemensv committed Aug 30, 2024
1 parent ac9dc10 commit 709bd5c
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 17 deletions.
38 changes: 27 additions & 11 deletions CONFIG.md
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ and multiple entries are permitted.

* **RelayName** - name of the Azure Relay name to bind to
* **ConnectionString** - optional Azure Relay connection string to use just for this forwarder, overriding the global **AzureRelayConnectionString** property.
* **NoAuthentication** - optional, if set to true, the connection is made without authentication with the assumption that the hybrid connection is configured to not require it.

For a single port binding on the Relay name, the following properties can be
used on the same entry. For multiple bindings they can be used to form a list.
Expand All @@ -359,20 +360,32 @@ Examples:

- Single listener binding:
``` YAML
- RelayName: myrelay
BindAddress: 127.0.8.1
BindPort: 8888
LocalForward:
- RelayName: myrelay
BindAddress: 127.0.8.1
BindPort: 8888
```
- Single listener binding (no client authentication):
``` YAML
LocalForward:
- RelayName: myrelay
BindAddress: 127.0.8.1
BindPort: 8888
NoAuthentication: true
```
- Multiple listener binding:
``` YAML
- RelayName: myrelay
Bindings:
- BindAddress: 127.0.8.1
BindPort: 5671
PortName: amqps
- BindAddress: 127.0.8.1
BindPort: 5672
PortName: amqp
LocalForward:
- RelayName: myrelay
Bindings:
- BindAddress: 127.0.8.1
BindPort: 5671
PortName: amqps
- BindAddress: 127.0.8.1
BindPort: 5672
PortName: amqp
```
Expand Down Expand Up @@ -410,12 +423,15 @@ Examples:

- Single listener binding:
``` YAML
RemoteForward:
- RelayName: myrelay
Host: localhost
HostPort: 8888
```

- Multiple listener binding:
``` YAML
RemoteForward:
- RelayName: myrelay
Bindings:
- Host: broker.corp.example.com
Expand Down
23 changes: 17 additions & 6 deletions test/unit/Microsoft.Azure.Relay.Bridge.Tests/ConfigTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ string CreateMaxConfig()
" BindPort : 8008" + textWriter.NewLine +
" RelayName : bar" + textWriter.NewLine +
" HostName : bar.example.com" + textWriter.NewLine +
" - BindAddress : 127.0.100.3" + textWriter.NewLine +
" BindPort : 8008" + textWriter.NewLine +
" RelayName : bam" + textWriter.NewLine +
" HostName : bam.example.com" + textWriter.NewLine +
" NoAuthentication: true" + textWriter.NewLine +
#if !NETFRAMEWORK
" - BindLocalSocket : test" + textWriter.NewLine +
" RelayName : baz" + textWriter.NewLine +
Expand Down Expand Up @@ -786,27 +791,33 @@ private static void CheckMaxConfig(Config config)
Assert.True(config.ExitOnForwardFailure);

#if !NETFRAMEWORK
Assert.Equal(3, config.LocalForward.Count);
Assert.Equal(4, config.LocalForward.Count);
#else
Assert.Equal(2, config.LocalForward.Count);
Assert.Equal(3, config.LocalForward.Count);
#endif
Assert.Equal("127.0.100.1", config.LocalForward[0].BindAddress);
Assert.Equal(8008, config.LocalForward[0].BindPort);
Assert.Equal("foo", config.LocalForward[0].RelayName);
Assert.Equal("foo.example.com", config.LocalForward[0].HostName);
Assert.False(config.LocalForward[0].NoAuthentication);
Assert.Equal("127.0.100.2", config.LocalForward[1].BindAddress);
Assert.Equal(8008, config.LocalForward[1].BindPort);
Assert.Equal("bar", config.LocalForward[1].RelayName);
Assert.Equal("bar.example.com", config.LocalForward[1].HostName);
Assert.False(config.LocalForward[1].NoAuthentication);
Assert.Equal("127.0.100.3", config.LocalForward[2].BindAddress);
Assert.Equal(8008, config.LocalForward[2].BindPort);
Assert.Equal("bam", config.LocalForward[2].RelayName);
Assert.True(config.LocalForward[2].NoAuthentication);
#if !NETFRAMEWORK
Assert.Equal("test", config.LocalForward[2].BindLocalSocket);
Assert.Equal("baz", config.LocalForward[2].RelayName);
Assert.Equal("test", config.LocalForward[3].BindLocalSocket);
Assert.Equal("baz", config.LocalForward[3].RelayName);
#endif

#if !NETFRAMEWORK
Assert.Equal(3, config.RemoteForward.Count);
#else
Assert.Equal(2, config.RemoteForward.Count);
Assert.Equal(4, config.RemoteForward.Count);
#endif
Assert.Equal("foo", config.RemoteForward[0].RelayName);
Assert.Equal(123, config.RemoteForward[0].HostPort);
Expand All @@ -830,7 +841,7 @@ public void ConfigSaveLoadFileTest()
Config config = Config.LoadConfig(settings);

config.SaveConfigFile(configFileName, false);

config = Config.LoadConfigFile(configFileName);

CheckMaxConfig(config);
Expand Down

0 comments on commit 709bd5c

Please sign in to comment.