Skip to content

Commit

Permalink
Set ReplicatorAPITest proxy options from _sg.proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
callumbirks committed Jul 18, 2023
1 parent a736f95 commit 19d4f6d
Showing 1 changed file with 37 additions and 1 deletion.
38 changes: 37 additions & 1 deletion Replicator/tests/ReplicatorAPITest.hh
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,43 @@ class ReplicatorAPITest : public C4Test {
enc.writeString(_sg.networkInterface);
}

// TODO: Set proxy settings from _proxy
if ( _sg.proxy ) {
enc.writeKey(C4STR(kC4ReplicatorProxyType));
slice proxyType;
switch ( _sg.proxy->type ) {
case ProxyType::HTTP:
proxyType = slice(kC4ProxyTypeHTTP);
case ProxyType::HTTPS:
proxyType = slice(kC4ProxyTypeHTTPS);
// TODO: Once SOCKS is implemented (CBL-4715)
// case ProxyType::SOCKS:
// proxyType = slice(kC4ProxyTypeSOCKS);
default:
proxyType = kC4ProxyTypeNone;
}
enc.writeString(proxyType);
if ( proxyType != slice(kC4ProxyTypeNone) ) {
enc.writeKey(kC4ReplicatorProxyHost);
enc.writeString(_sg.proxy->hostname);

enc.writeKey(kC4ReplicatorProxyPort);
enc.writeInt(_sg.proxy->port);

enc.writeKey(kC4ReplicatorProxyAuth);
enc.beginDict();

enc.writeKey(kC4ReplicatorAuthType);
enc.writeString(kC4AuthTypeBasic);

enc.writeKey(kC4ReplicatorAuthUserName);
enc.writeString(_sg.proxy->username);

enc.writeKey(kC4ReplicatorAuthPassword);
enc.writeString(_sg.proxy->password);

enc.endDict();
}
}
// Copy any preexisting options:
for ( Dict::iterator i(_options.asDict()); i; ++i ) {
enc.writeKey(i.keyString());
Expand Down

0 comments on commit 19d4f6d

Please sign in to comment.