1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
/*
* Copyright (C) 2005-2018 Team Kodi
* This file is part of Kodi - https://kodi.tv
*
* SPDX-License-Identifier: GPL-2.0-or-later
* See LICENSES/README.md for more information.
*/
#include "URL.h"
#include <gtest/gtest.h>
using ::testing::Test;
using ::testing::WithParamInterface;
using ::testing::ValuesIn;
struct TestURLGetWithoutUserDetailsData
{
std::string input;
std::string expected;
bool redact;
};
std::ostream& operator<<(std::ostream& os,
const TestURLGetWithoutUserDetailsData& rhs)
{
return os << "(Input: " << rhs.input <<
"; Redact: " << (rhs.redact?"true":"false") <<
"; Expected: " << rhs.expected << ")";
}
class TestURLGetWithoutUserDetails : public Test,
public WithParamInterface<TestURLGetWithoutUserDetailsData>
{
};
TEST_P(TestURLGetWithoutUserDetails, GetWithoutUserDetails)
{
CURL input(GetParam().input);
std::string result = input.GetWithoutUserDetails(GetParam().redact);
EXPECT_EQ(result, GetParam().expected);
}
const TestURLGetWithoutUserDetailsData values[] = {
{ std::string("smb://example.com/example"), std::string("smb://example.com/example"), false },
{ std::string("smb://example.com/example"), std::string("smb://example.com/example"), true },
{ std::string("smb://god:universe@example.com/example"), std::string("smb://example.com/example"), false },
{ std::string("smb://god@example.com/example"), std::string("smb://USERNAME@example.com/example"), true },
{ std::string("smb://god:universe@example.com/example"), std::string("smb://USERNAME:PASSWORD@example.com/example"), true },
{ std::string("http://god:universe@example.com:8448/example|auth=digest"), std::string("http://USERNAME:PASSWORD@example.com:8448/example|auth=digest"), true },
{ std::string("smb://fd00::1/example"), std::string("smb://fd00::1/example"), false },
{ std::string("smb://fd00::1/example"), std::string("smb://fd00::1/example"), true },
{ std::string("smb://[fd00::1]:8080/example"), std::string("smb://[fd00::1]:8080/example"), false },
{ std::string("smb://[fd00::1]:8080/example"), std::string("smb://[fd00::1]:8080/example"), true },
{ std::string("smb://god:universe@[fd00::1]:8080/example"), std::string("smb://[fd00::1]:8080/example"), false },
{ std::string("smb://god@[fd00::1]:8080/example"), std::string("smb://USERNAME@[fd00::1]:8080/example"), true },
{ std::string("smb://god:universe@fd00::1/example"), std::string("smb://USERNAME:PASSWORD@fd00::1/example"), true },
{ std::string("http://god:universe@[fd00::1]:8448/example|auth=digest"), std::string("http://USERNAME:PASSWORD@[fd00::1]:8448/example|auth=digest"), true },
{ std::string("smb://00ff:1:0000:abde::/example"), std::string("smb://00ff:1:0000:abde::/example"), true },
{ std::string("smb://god:universe@[00ff:1:0000:abde::]:8080/example"), std::string("smb://[00ff:1:0000:abde::]:8080/example"), false },
{ std::string("smb://god@[00ff:1:0000:abde::]:8080/example"), std::string("smb://USERNAME@[00ff:1:0000:abde::]:8080/example"), true },
{ std::string("smb://god:universe@00ff:1:0000:abde::/example"), std::string("smb://USERNAME:PASSWORD@00ff:1:0000:abde::/example"), true },
{ std::string("http://god:universe@[00ff:1:0000:abde::]:8448/example|auth=digest"), std::string("http://USERNAME:PASSWORD@[00ff:1:0000:abde::]:8448/example|auth=digest"), true },
{ std::string("smb://milkyway;god:universe@example.com/example"), std::string("smb://DOMAIN;USERNAME:PASSWORD@example.com/example"), true },
{ std::string("smb://milkyway;god@example.com/example"), std::string("smb://DOMAIN;USERNAME@example.com/example"), true },
{ std::string("smb://milkyway;@example.com/example"), std::string("smb://example.com/example"), true },
{ std::string("smb://milkyway;god:universe@example.com/example"), std::string("smb://example.com/example"), false },
{ std::string("smb://milkyway;god@example.com/example"), std::string("smb://example.com/example"), false },
{ std::string("smb://milkyway;@example.com/example"), std::string("smb://example.com/example"), false },
};
INSTANTIATE_TEST_SUITE_P(URL, TestURLGetWithoutUserDetails, ValuesIn(values));
|