@@ -5059,12 +5059,11 @@ VOID TEST(ConfigEnvTest, CheckEnvValuesHooks)
5059
5059
}
5060
5060
5061
5061
if (true ) {
5062
- SrsSetEnvConfig (hooks, " SRS_VHOST_HTTP_HOOKS_ON_CONNECT" , " http://server/api/connect https://server2/api/connect2 " );
5062
+ SrsSetEnvConfig (hooks, " SRS_VHOST_HTTP_HOOKS_ON_CONNECT" , " http://server/api/connect" );
5063
5063
SrsConfDirective* dir = conf.get_vhost_on_connect (" __defaultVhost__" );
5064
5064
ASSERT_TRUE (dir != NULL );
5065
- ASSERT_EQ ((int )dir->args .size (), 2 );
5065
+ ASSERT_EQ ((int )dir->args .size (), 1 );
5066
5066
ASSERT_STREQ (" http://server/api/connect" , dir->arg0 ().c_str ());
5067
- ASSERT_STREQ (" https://server2/api/connect2" , dir->arg1 ().c_str ());
5068
5067
}
5069
5068
5070
5069
if (true ) {
@@ -5076,12 +5075,11 @@ VOID TEST(ConfigEnvTest, CheckEnvValuesHooks)
5076
5075
}
5077
5076
5078
5077
if (true ) {
5079
- SrsSetEnvConfig (hooks, " SRS_VHOST_HTTP_HOOKS_ON_PUBLISH" , " http://server/api/publish http://server/api/publish2 " );
5078
+ SrsSetEnvConfig (hooks, " SRS_VHOST_HTTP_HOOKS_ON_PUBLISH" , " http://server/api/publish" );
5080
5079
SrsConfDirective* dir = conf.get_vhost_on_publish (" __defaultVhost__" );
5081
5080
ASSERT_TRUE (dir != NULL );
5082
- ASSERT_EQ ((int )dir->args .size (), 2 );
5081
+ ASSERT_EQ ((int )dir->args .size (), 1 );
5083
5082
ASSERT_STREQ (" http://server/api/publish" , dir->arg0 ().c_str ());
5084
- ASSERT_STREQ (" http://server/api/publish2" , dir->arg1 ().c_str ());
5085
5083
}
5086
5084
5087
5085
if (true ) {
@@ -5132,3 +5130,132 @@ VOID TEST(ConfigEnvTest, CheckEnvValuesHooks)
5132
5130
ASSERT_STREQ (" http://server/api/hls_notify" , dir->arg0 ().c_str ());
5133
5131
}
5134
5132
}
5133
+
5134
+ VOID TEST (ConfigEnvTest, CheckEnvValuesHooksMultiValues)
5135
+ {
5136
+ MockSrsConfig conf;
5137
+
5138
+ if (true ) {
5139
+ SrsSetEnvConfig (hooks, " SRS_VHOST_HTTP_HOOKS_ON_CONNECT" , " http://server/api/connect https://server2/api/connect2" );
5140
+
5141
+ SrsConfDirective* dir = conf.get_vhost_on_connect (" __defaultVhost__" );
5142
+ ASSERT_TRUE (dir != NULL );
5143
+ ASSERT_EQ ((int )dir->args .size (), 2 );
5144
+ ASSERT_STREQ (" http://server/api/connect" , dir->arg0 ().c_str ());
5145
+ ASSERT_STREQ (" https://server2/api/connect2" , dir->arg1 ().c_str ());
5146
+ }
5147
+
5148
+ if (true ) {
5149
+ SrsSetEnvConfig (hooks, " SRS_VHOST_HTTP_HOOKS_ON_CLOSE" , " http://server/api/close close2 close3" );
5150
+ SrsConfDirective* dir = conf.get_vhost_on_close (" __defaultVhost__" );
5151
+ ASSERT_TRUE (dir != NULL );
5152
+ ASSERT_TRUE ((int )dir->args .size () == 3 );
5153
+ ASSERT_STREQ (" http://server/api/close" , dir->arg0 ().c_str ());
5154
+ ASSERT_STREQ (" close2" , dir->arg1 ().c_str ());
5155
+ ASSERT_STREQ (" close3" , dir->arg2 ().c_str ());
5156
+ }
5157
+
5158
+ if (true ) {
5159
+ SrsSetEnvConfig (hooks, " SRS_VHOST_HTTP_HOOKS_ON_PUBLISH" , " http://server/api/publish http://server/api/publish2" );
5160
+ SrsConfDirective* dir = conf.get_vhost_on_publish (" __defaultVhost__" );
5161
+ ASSERT_TRUE (dir != NULL );
5162
+ ASSERT_EQ ((int )dir->args .size (), 2 );
5163
+ ASSERT_STREQ (" http://server/api/publish" , dir->arg0 ().c_str ());
5164
+ ASSERT_STREQ (" http://server/api/publish2" , dir->arg1 ().c_str ());
5165
+ }
5166
+
5167
+ if (true ) {
5168
+ SrsSetEnvConfig (hooks, " SRS_VHOST_HTTP_HOOKS_ON_UNPUBLISH" , " http://server/api/unpublish 2" );
5169
+ SrsConfDirective* dir = conf.get_vhost_on_unpublish (" __defaultVhost__" );
5170
+ ASSERT_TRUE (dir != NULL );
5171
+ ASSERT_TRUE ((int )dir->args .size () == 2 );
5172
+ ASSERT_STREQ (" http://server/api/unpublish" , dir->arg0 ().c_str ());
5173
+ ASSERT_STREQ (" 2" , dir->arg1 ().c_str ());
5174
+ }
5175
+
5176
+ if (true ) {
5177
+ SrsSetEnvConfig (hooks, " SRS_VHOST_HTTP_HOOKS_ON_PLAY" , " http://server/api/play http://server/api/play2" );
5178
+ SrsConfDirective* dir = conf.get_vhost_on_play (" __defaultVhost__" );
5179
+ ASSERT_TRUE (dir != NULL );
5180
+ ASSERT_TRUE ((int )dir->args .size () == 2 );
5181
+ ASSERT_STREQ (" http://server/api/play" , dir->arg0 ().c_str ());
5182
+ ASSERT_STREQ (" http://server/api/play2" , dir->arg1 ().c_str ());
5183
+ }
5184
+
5185
+ if (true ) {
5186
+ SrsSetEnvConfig (hooks, " SRS_VHOST_HTTP_HOOKS_ON_STOP" , " http://server/api/stop http://server/api/stop2" );
5187
+ SrsConfDirective* dir = conf.get_vhost_on_stop (" __defaultVhost__" );
5188
+ ASSERT_TRUE (dir != NULL );
5189
+ ASSERT_TRUE ((int )dir->args .size () == 2 );
5190
+ ASSERT_STREQ (" http://server/api/stop" , dir->arg0 ().c_str ());
5191
+ ASSERT_STREQ (" http://server/api/stop2" , dir->arg1 ().c_str ());
5192
+ }
5193
+
5194
+ if (true ) {
5195
+ SrsSetEnvConfig (hooks, " SRS_VHOST_HTTP_HOOKS_ON_DVR" , " http://server/api/dvr http://server/api/dvr2" );
5196
+ SrsConfDirective* dir = conf.get_vhost_on_dvr (" __defaultVhost__" );
5197
+ ASSERT_TRUE (dir != NULL );
5198
+ ASSERT_TRUE ((int )dir->args .size () == 2 );
5199
+ ASSERT_STREQ (" http://server/api/dvr" , dir->arg0 ().c_str ());
5200
+ ASSERT_STREQ (" http://server/api/dvr2" , dir->arg1 ().c_str ());
5201
+ }
5202
+
5203
+ if (true ) {
5204
+ SrsSetEnvConfig (hooks, " SRS_VHOST_HTTP_HOOKS_ON_HLS" , " http://server/api/hls http://server/api/hls2" );
5205
+ SrsConfDirective* dir = conf.get_vhost_on_hls (" __defaultVhost__" );
5206
+ ASSERT_TRUE (dir != NULL );
5207
+ ASSERT_TRUE ((int )dir->args .size () == 2 );
5208
+ ASSERT_STREQ (" http://server/api/hls" , dir->arg0 ().c_str ());
5209
+ ASSERT_STREQ (" http://server/api/hls2" , dir->arg1 ().c_str ());
5210
+ }
5211
+
5212
+ if (true ) {
5213
+ SrsSetEnvConfig (hooks, " SRS_VHOST_HTTP_HOOKS_ON_HLS_NOTIFY" , " http://server/api/hls_notify http://server/api/hls_notify2" );
5214
+ SrsConfDirective* dir = conf.get_vhost_on_hls_notify (" __defaultVhost__" );
5215
+ ASSERT_TRUE (dir != NULL );
5216
+ ASSERT_TRUE ((int )dir->args .size () == 2 );
5217
+ ASSERT_STREQ (" http://server/api/hls_notify" , dir->arg0 ().c_str ());
5218
+ ASSERT_STREQ (" http://server/api/hls_notify2" , dir->arg1 ().c_str ());
5219
+ }
5220
+ }
5221
+
5222
+ VOID TEST (ConfigEnvTest, CheckEnvValuesHooksWithWhitespaces)
5223
+ {
5224
+ MockSrsConfig conf;
5225
+
5226
+ if (true ) {
5227
+ SrsSetEnvConfig (hooks, " SRS_VHOST_HTTP_HOOKS_ON_PUBLISH" , " http://server/api/publish http://server/api/publish2" );
5228
+ SrsConfDirective* dir = conf.get_vhost_on_publish (" __defaultVhost__" );
5229
+ ASSERT_TRUE (dir != NULL );
5230
+ ASSERT_EQ ((int )dir->args .size (), 2 );
5231
+ ASSERT_STREQ (" http://server/api/publish" , dir->arg0 ().c_str ());
5232
+ ASSERT_STREQ (" http://server/api/publish2" , dir->arg1 ().c_str ());
5233
+ }
5234
+
5235
+ if (true ) {
5236
+ SrsSetEnvConfig (hooks, " SRS_VHOST_HTTP_HOOKS_ON_UNPUBLISH" , " http://server/api/unpublish " );
5237
+ SrsConfDirective* dir = conf.get_vhost_on_unpublish (" __defaultVhost__" );
5238
+ ASSERT_TRUE (dir != NULL );
5239
+ ASSERT_TRUE ((int )dir->args .size () == 1 );
5240
+ ASSERT_STREQ (" http://server/api/unpublish" , dir->arg0 ().c_str ());
5241
+ }
5242
+
5243
+ if (true ) {
5244
+ SrsSetEnvConfig (hooks, " SRS_VHOST_HTTP_HOOKS_ON_PLAY" , " http://server/api/play play2 play3 " );
5245
+ SrsConfDirective* dir = conf.get_vhost_on_play (" __defaultVhost__" );
5246
+ ASSERT_TRUE (dir != NULL );
5247
+ ASSERT_TRUE ((int )dir->args .size () == 3 );
5248
+ ASSERT_STREQ (" http://server/api/play" , dir->arg0 ().c_str ());
5249
+ ASSERT_STREQ (" play2" , dir->arg1 ().c_str ());
5250
+ ASSERT_STREQ (" play3" , dir->arg2 ().c_str ());
5251
+ }
5252
+
5253
+ if (true ) {
5254
+ SrsSetEnvConfig (hooks, " SRS_VHOST_HTTP_HOOKS_ON_DVR" , " dvr" );
5255
+ SrsConfDirective* dir = conf.get_vhost_on_dvr (" __defaultVhost__" );
5256
+ ASSERT_TRUE (dir != NULL );
5257
+ ASSERT_TRUE ((int )dir->args .size () == 1 );
5258
+ ASSERT_STREQ (" dvr" , dir->arg0 ().c_str ());
5259
+ }
5260
+
5261
+ }
0 commit comments