proxygen
TLSTicketKeyManagerTest.cpp File Reference
#include <folly/portability/GMock.h>
#include <gtest/gtest.h>
#include <wangle/ssl/SSLStats.h>
#include <wangle/ssl/TLSTicketKeyManager.h>

Go to the source code of this file.

Classes

class  MockSSLStats
 

Functions

 TEST (TLSTicketKeyManager, TestSetGetTLSTicketKeySeeds)
 
 TEST (TLSTicketKeyManager, TestValidateTicketSeedsSuccess)
 
 TEST (TLSTicketKeyManager, TestValidateTicketSeedsIdempotent)
 
 TEST (TLSTicketKeyManager, TestValidateTicketSeedsFailure)
 
 TEST (TLSTicketKeyManager, TestValidateTicketSeedsSubsetPass)
 

Function Documentation

TEST ( TLSTicketKeyManager  ,
TestSetGetTLSTicketKeySeeds   
)

Definition at line 47 of file TLSTicketKeyManagerTest.cpp.

References ASSERT_EQ, and cpp.ast::next().

47  {
48  std::vector<std::string> origOld = {"67"};
49  std::vector<std::string> origCurr = {"68"};
50  std::vector<std::string> origNext = {"69"};
51 
53  wangle::TLSTicketKeyManager manager(&ctx, nullptr);
54 
55  manager.setTLSTicketKeySeeds(origOld, origCurr, origNext);
56  std::vector<std::string> old;
57  std::vector<std::string> curr;
58  std::vector<std::string> next;
59  manager.getTLSTicketKeySeeds(old, curr, next);
60  ASSERT_EQ(origOld, old);
61  ASSERT_EQ(origCurr, curr);
62  ASSERT_EQ(origNext, next);
63 }
#define ASSERT_EQ(val1, val2)
Definition: gtest.h:1956
def next(obj)
Definition: ast.py:58
TEST ( TLSTicketKeyManager  ,
TestValidateTicketSeedsSuccess   
)

Definition at line 65 of file TLSTicketKeyManagerTest.cpp.

References EXPECT_CALL, and wangle::SSLStats::recordTLSTicketRotation().

65  {
66  MockSSLStats stats;
67  EXPECT_CALL(stats, recordTLSTicketRotation(true)).Times(2);
68 
69  std::vector<std::string> origOld = {"67", "77"};
70  std::vector<std::string> origCurr = {"68", "78"};
71  std::vector<std::string> origNext = {"69", "79"};
72 
73  // The new ticket seeds are compatible
74  std::vector<std::string> newOld = {"68", "78"};
75  std::vector<std::string> newCurr = {"69", "79"};
76  std::vector<std::string> newNext = {"70", "80"};
77 
79  wangle::TLSTicketKeyManager manager(&ctx, &stats);
80 
81  manager.setTLSTicketKeySeeds(origOld, origCurr, origNext);
82  manager.setTLSTicketKeySeeds(newOld, newCurr, newNext);
83 }
#define EXPECT_CALL(obj, call)
TEST ( TLSTicketKeyManager  ,
TestValidateTicketSeedsIdempotent   
)

Definition at line 85 of file TLSTicketKeyManagerTest.cpp.

References EXPECT_CALL, and wangle::SSLStats::recordTLSTicketRotation().

85  {
86  MockSSLStats stats;
87  EXPECT_CALL(stats, recordTLSTicketRotation(true)).Times(2);
88 
89  std::vector<std::string> origOld = {"67", "77"};
90  std::vector<std::string> origCurr = {"68", "78"};
91  std::vector<std::string> origNext = {"69", "79"};
92 
94  wangle::TLSTicketKeyManager manager(&ctx, &stats);
95 
96  manager.setTLSTicketKeySeeds(origOld, origCurr, origNext);
97  manager.setTLSTicketKeySeeds(origOld, origCurr, origNext);
98 }
#define EXPECT_CALL(obj, call)
TEST ( TLSTicketKeyManager  ,
TestValidateTicketSeedsFailure   
)

Definition at line 100 of file TLSTicketKeyManagerTest.cpp.

References EXPECT_CALL, and wangle::SSLStats::recordTLSTicketRotation().

100  {
101  MockSSLStats stats;
102  InSequence inSequence;
103  EXPECT_CALL(stats, recordTLSTicketRotation(true)).Times(1);
104  EXPECT_CALL(stats, recordTLSTicketRotation(false)).Times(1);
105 
106  std::vector<std::string> origOld = {"67", "77"};
107  std::vector<std::string> origCurr = {"68", "78"};
108  std::vector<std::string> origNext = {"69", "79"};
109 
110  // The new seeds are incompatible
111  std::vector<std::string> newOld = {"69", "79"};
112  std::vector<std::string> newCurr = {"70", "80"};
113  std::vector<std::string> newNext = {"71", "81"};
114 
115  folly::SSLContext ctx;
116  wangle::TLSTicketKeyManager manager(&ctx, &stats);
117 
118  manager.setTLSTicketKeySeeds(origOld, origCurr, origNext);
119  manager.setTLSTicketKeySeeds(newOld, newCurr, newNext);
120 }
#define EXPECT_CALL(obj, call)
TEST ( TLSTicketKeyManager  ,
TestValidateTicketSeedsSubsetPass   
)

Definition at line 122 of file TLSTicketKeyManagerTest.cpp.

References EXPECT_CALL, and wangle::SSLStats::recordTLSTicketRotation().

122  {
123  MockSSLStats stats;
124  InSequence inSequence;
125  EXPECT_CALL(stats, recordTLSTicketRotation(true)).Times(2);
126 
127  std::vector<std::string> origOld = {"67"};
128  std::vector<std::string> origCurr = {"68"};
129  std::vector<std::string> origNext = {"69"};
130 
131  // The new ticket seeds are compatible
132  std::vector<std::string> newOld = {"68", "78"};
133  std::vector<std::string> newCurr = {"69"};
134  std::vector<std::string> newNext = {"70", "80"};
135 
136  folly::SSLContext ctx;
137  wangle::TLSTicketKeyManager manager(&ctx, &stats);
138 
139  manager.setTLSTicketKeySeeds(origOld, origCurr, origNext);
140  manager.setTLSTicketKeySeeds(newOld, newCurr, newNext);
141 }
#define EXPECT_CALL(obj, call)