Skip to content

Commit

Permalink
fix issue that port is removed
Browse files Browse the repository at this point in the history
Signed-off-by: Benjamin Brahmer <[email protected]>
  • Loading branch information
Grotax committed Jan 8, 2025
1 parent df01931 commit db5f551
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
14 changes: 12 additions & 2 deletions lib/Config/FetcherConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,11 @@ public function __construct(
$url->setUserinfo($auth[0], $auth[1]);
}

$this->proxy = $url->getNormalizedURL();
$this->proxy = $url->getURL();

$this->logger->debug(
'Proxy configuration finalized: {proxy}',
['proxy' => $proxy]
['proxy' => $this->proxy]
);

return $this;
Expand Down Expand Up @@ -198,4 +198,14 @@ public function getUserAgent(): string

return 'NextCloud-News/' . $this->version;
}

/**
* Get the proxy configuration
*
* @return string|null
*/
public function getProxy(): ?string
{
return $this->proxy;
}
}
27 changes: 27 additions & 0 deletions tests/Unit/Config/FetcherConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,31 @@ public function testGetUserAgentUnknownVersion()
$response = $this->class->getUserAgent();
$this->assertEquals($expected, $response);
}

public function testProxyPortPreserved()
{
$this->config->expects($this->exactly(2))
->method('getValueInt')
->willReturnMap([
['news', 'feedFetcherTimeout', 60, false, 60],
['news', 'maxRedirects', 10, false, 10]
]);

$this->appmanager->expects($this->exactly(1))
->method('getAppVersion')
->willReturn('1.0');

$this->sysconfig->expects($this->exactly(2))
->method('getSystemValue')
->willReturnMap([
['proxy', null, 'http://192.168.178.1:80'],
['proxyuserpwd', null , null]
]);

$this->class = new FetcherConfig($this->config, $this->sysconfig, $this->appmanager, $this->logger);

$expected = 'http://192.168.178.1:80';
$response = $this->class->getProxy();
$this->assertEquals($expected, $response);
}
}

0 comments on commit db5f551

Please sign in to comment.