Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
B
brpc
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
brpc
Commits
5711cfce
Commit
5711cfce
authored
Sep 19, 2017
by
Ge Jun
Committed by
GitHub
Sep 19, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #23 from brpc/jiangrujie-dev
Fix UT of server which rely on the format of curl's output
parents
8ae7b0c8
f3553a12
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
41 deletions
+13
-41
brpc_server_unittest.cpp
test/brpc_server_unittest.cpp
+13
-41
No files found.
test/brpc_server_unittest.cpp
View file @
5711cfce
...
...
@@ -1277,11 +1277,10 @@ TEST_F(ServerTest, too_big_message) {
server
.
Join
();
}
void
CheckCert
(
const
char
*
fname
,
const
char
*
cert
)
{
butil
::
ScopedFILE
fp
(
fname
,
"r"
);
char
buf
[
1024
];
fgets
(
buf
,
sizeof
(
buf
),
fp
);
ASSERT_EQ
(
0
,
strncmp
(
cert
,
buf
+
1
,
strlen
(
cert
)))
<<
cert
;
// Skip the first blank
void
CheckCert
(
const
char
*
address
,
const
char
*
cert
)
{
std
::
string
cmd
=
butil
::
string_printf
(
"/usr/bin/curl -Ikv https://%s 2>&1 | grep %s"
,
address
,
cert
);
ASSERT_EQ
(
0
,
system
(
cmd
.
c_str
()));
}
std
::
string
GetRawPemString
(
const
char
*
fname
)
{
...
...
@@ -1311,20 +1310,12 @@ TEST_F(ServerTest, ssl_sni) {
options
.
ssl_options
.
certs
.
push_back
(
cert
);
}
ASSERT_EQ
(
0
,
server
.
Start
(
8613
,
&
options
));
{
std
::
string
cmd
=
"/usr/bin/curl -Ikv https://localhost:8613 2>&1 "
"| grep common | cut -d':' -f2 > cname.out"
;
ASSERT_EQ
(
0
,
system
(
cmd
.
c_str
()));
CheckCert
(
"cname.out"
,
"cert1"
);
}
CheckCert
(
"localhost:8613"
,
"cert1"
);
#ifdef SSL_CTRL_SET_TLSEXT_HOSTNAME
{
std
::
string
cmd
=
"/usr/bin/curl -Ikv https://localhost.localdomain:8613 "
"2>&1 | grep common | cut -d':' -f2 > cname.out"
;
ASSERT_EQ
(
0
,
system
(
cmd
.
c_str
()));
CheckCert
(
"cname.out"
,
"cert2"
);
}
CheckCert
(
"localhost.localdomain:8613"
,
"cert2"
);
#endif // SSL_CTRL_SET_TLSEXT_HOSTNAME
server
.
Stop
(
0
);
server
.
Join
();
}
...
...
@@ -1340,12 +1331,8 @@ TEST_F(ServerTest, ssl_reload) {
options
.
ssl_options
.
default_cert
=
cert
;
}
ASSERT_EQ
(
0
,
server
.
Start
(
8613
,
&
options
));
{
std
::
string
cmd
=
"/usr/bin/curl -Ikv https://localhost:8613 2>&1 "
"| grep common | cut -d':' -f2 > cname.out"
;
ASSERT_EQ
(
0
,
system
(
cmd
.
c_str
()));
CheckCert
(
"cname.out"
,
"cert1"
);
}
CheckCert
(
"localhost:8613"
,
"cert1"
);
{
brpc
::
CertInfo
cert
;
cert
.
certificate
=
GetRawPemString
(
"cert2.crt"
);
...
...
@@ -1354,12 +1341,7 @@ TEST_F(ServerTest, ssl_reload) {
ASSERT_EQ
(
0
,
server
.
AddCertificate
(
cert
));
}
#ifdef SSL_CTRL_SET_TLSEXT_HOSTNAME
{
std
::
string
cmd
=
"/usr/bin/curl -Ikv https://localhost.localdomain:8613 "
"2>&1 | grep common | cut -d':' -f2 > cname.out"
;
ASSERT_EQ
(
0
,
system
(
cmd
.
c_str
()));
CheckCert
(
"cname.out"
,
"cert2"
);
}
CheckCert
(
"localhost.localdomain:8613"
,
"cert2"
);
#endif // SSL_CTRL_SET_TLSEXT_HOSTNAME
{
...
...
@@ -1369,12 +1351,7 @@ TEST_F(ServerTest, ssl_reload) {
ASSERT_EQ
(
0
,
server
.
RemoveCertificate
(
cert
));
}
#ifdef SSL_CTRL_SET_TLSEXT_HOSTNAME
{
std
::
string
cmd
=
"/usr/bin/curl -Ikv https://localhost.localdomain:8613 "
"2>&1 | grep common | cut -d':' -f2 > cname.out"
;
ASSERT_EQ
(
0
,
system
(
cmd
.
c_str
()));
CheckCert
(
"cname.out"
,
"cert1"
);
}
CheckCert
(
"localhost.localdomain:8613"
,
"cert1"
);
#endif // SSL_CTRL_SET_TLSEXT_HOSTNAME
{
...
...
@@ -1387,12 +1364,7 @@ TEST_F(ServerTest, ssl_reload) {
ASSERT_EQ
(
0
,
server
.
ResetCertificates
(
certs
));
}
#ifdef SSL_CTRL_SET_TLSEXT_HOSTNAME
{
std
::
string
cmd
=
"/usr/bin/curl -Ikv https://localhost.localdomain:8613 "
"2>&1 | grep common | cut -d':' -f2 > cname.out"
;
ASSERT_EQ
(
0
,
system
(
cmd
.
c_str
()));
CheckCert
(
"cname.out"
,
"cert2"
);
}
CheckCert
(
"localhost.localdomain:8613"
,
"cert2"
);
#endif // SSL_CTRL_SET_TLSEXT_HOSTNAME
server
.
Stop
(
0
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment