1 //
2 //
3 // Copyright 2016 gRPC authors.
4 //
5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17 //
18
19 #include <memory>
20
21 #include "gtest/gtest.h"
22
23 #include "test/core/handshake/server_ssl_common.h"
24 #include "test/core/util/test_config.h"
25
TEST(ServerSslTest,MainTest)26 TEST(ServerSslTest, MainTest) {
27 // Handshake succeeeds when the client supplies only h2 as the ALPN list. This
28 // covers legacy gRPC clients which don't support grpc-exp.
29 const char* h2_only_alpn_list[] = {"h2"};
30 ASSERT_TRUE(server_ssl_test(h2_only_alpn_list, 1, "h2"));
31 // Handshake succeeds when the client supplies superfluous ALPN entries and
32 // also when h2 is included.
33 const char* extra_alpn_list[] = {"foo", "h2", "bar"};
34 ASSERT_TRUE(server_ssl_test(extra_alpn_list, 3, "h2"));
35 // Handshake fails when the client uses a fake protocol as its only ALPN
36 // preference. This validates the server is correctly validating ALPN
37 // and sanity checks the server_ssl_test.
38 const char* fake_alpn_list[] = {"foo"};
39 ASSERT_FALSE(server_ssl_test(fake_alpn_list, 1, "foo"));
40 CleanupSslLibrary();
41 }
42
main(int argc,char ** argv)43 int main(int argc, char** argv) {
44 grpc::testing::TestEnvironment env(&argc, argv);
45 ::testing::InitGoogleTest(&argc, argv);
46 return RUN_ALL_TESTS();
47 }
48