@@ -289,20 +289,23 @@ func TestNginxConfigParser_Parse(t *testing.T) {
289289 defer helpers .RemoveFileWithErrorCheck (t , allowedFile .Name ())
290290 fileMetaAllowedFiles , err := files .FileMeta (allowedFile .Name ())
291291 require .NoError (t , err )
292+ allowedFileWithMetas := mpi.File {FileMeta : fileMetaAllowedFiles }
292293
293294 _ , cert := helpers .GenerateSelfSignedCert (t )
294295 certContents := helpers.Cert {Name : "nginx.cert" , Type : "CERTIFICATE" , Contents : cert }
295296 certFile := helpers .WriteCertFiles (t , dir , certContents )
296297 require .NotNil (t , certFile )
297298 fileMetaCertFiles , err := files .FileMetaWithCertificate (certFile )
298299 require .NoError (t , err )
300+ certFileWithMetas := mpi.File {FileMeta : fileMetaCertFiles }
299301
300302 _ , diffCert := helpers .GenerateSelfSignedCert (t )
301303 diffCertContents := helpers.Cert {Name : "nginx1.cert" , Type : "CERTIFICATE" , Contents : diffCert }
302304 diffCertFile := helpers .WriteCertFiles (t , dir , diffCertContents )
303305 require .NotNil (t , diffCertFile )
304306 diffFileMetaCertFiles , err := files .FileMetaWithCertificate (diffCertFile )
305307 require .NoError (t , err )
308+ diffCertFileWithMetas := mpi.File {FileMeta : diffFileMetaCertFiles }
306309
307310 tests := []struct {
308311 instance * mpi.Instance
@@ -354,34 +357,13 @@ func TestNginxConfigParser_Parse(t *testing.T) {
354357 instance : protos .GetNginxPlusInstance ([]string {}),
355358 content : testconfig .GetNginxConfigWithNotAllowedDir (errorLog .Name (), allowedFile .Name (),
356359 notAllowedFile .Name (), accessLog .Name ()),
357- expectedConfigContext : & model.NginxConfigContext {
358- StubStatus : & model.APIDetails {},
359- PlusAPI : & model.APIDetails {},
360- InstanceID : protos .GetNginxPlusInstance ([]string {}).GetInstanceMeta ().GetInstanceId (),
361- Files : []* mpi.File {
362- {
363- FileMeta : fileMetaAllowedFiles ,
364- },
365- },
366- AccessLogs : []* model.AccessLog {
367- {
368- Name : accessLog .Name (),
369- Format : "$remote_addr - $remote_user [$time_local] \" $request\" $status $body_bytes_sent " +
370- "\" $http_referer\" \" $http_user_agent\" \" $http_x_forwarded_for\" \" $bytes_sent\" " +
371- "\" $request_length\" \" $request_time\" \" $gzip_ratio\" $server_protocol " ,
372- Permissions : "0600" ,
373- Readable : true ,
374- },
375- },
376- ErrorLogs : []* model.ErrorLog {
377- {
378- Name : errorLog .Name (),
379- Permissions : "0600" ,
380- Readable : true ,
381- },
382- },
383- NAPSysLogServers : nil ,
384- },
360+ expectedConfigContext : modelHelpers .GetConfigContextWithFiles (
361+ accessLog .Name (),
362+ errorLog .Name (),
363+ []* mpi.File {& allowedFileWithMetas },
364+ protos .GetNginxPlusInstance ([]string {}).GetInstanceMeta ().GetInstanceId (),
365+ nil ,
366+ ),
385367 allowedDirectories : []string {dir },
386368 },
387369 {
@@ -407,34 +389,13 @@ func TestNginxConfigParser_Parse(t *testing.T) {
407389 accessLog .Name (),
408390 certFile ,
409391 ),
410- expectedConfigContext : & model.NginxConfigContext {
411- StubStatus : & model.APIDetails {},
412- PlusAPI : & model.APIDetails {},
413- InstanceID : protos .GetNginxPlusInstance ([]string {}).GetInstanceMeta ().GetInstanceId (),
414- Files : []* mpi.File {
415- {
416- FileMeta : fileMetaCertFiles ,
417- },
418- },
419- AccessLogs : []* model.AccessLog {
420- {
421- Name : accessLog .Name (),
422- Format : "$remote_addr - $remote_user [$time_local] \" $request\" $status $body_bytes_sent " +
423- "\" $http_referer\" \" $http_user_agent\" \" $http_x_forwarded_for\" \" $bytes_sent\" " +
424- "\" $request_length\" \" $request_time\" \" $gzip_ratio\" $server_protocol " ,
425- Permissions : "0600" ,
426- Readable : true ,
427- },
428- },
429- ErrorLogs : []* model.ErrorLog {
430- {
431- Name : errorLog .Name (),
432- Permissions : "0600" ,
433- Readable : true ,
434- },
435- },
436- NAPSysLogServers : nil ,
437- },
392+ expectedConfigContext : modelHelpers .GetConfigContextWithFiles (
393+ accessLog .Name (),
394+ errorLog .Name (),
395+ []* mpi.File {& certFileWithMetas },
396+ protos .GetNginxPlusInstance ([]string {}).GetInstanceMeta ().GetInstanceId (),
397+ nil ,
398+ ),
438399 allowedDirectories : []string {dir },
439400 },
440401 {
@@ -446,37 +407,13 @@ func TestNginxConfigParser_Parse(t *testing.T) {
446407 certFile ,
447408 diffCertFile ,
448409 ),
449- expectedConfigContext : & model.NginxConfigContext {
450- StubStatus : & model.APIDetails {},
451- PlusAPI : & model.APIDetails {},
452- InstanceID : protos .GetNginxPlusInstance ([]string {}).GetInstanceMeta ().GetInstanceId (),
453- Files : []* mpi.File {
454- {
455- FileMeta : fileMetaCertFiles ,
456- },
457- {
458- FileMeta : diffFileMetaCertFiles ,
459- },
460- },
461- AccessLogs : []* model.AccessLog {
462- {
463- Name : accessLog .Name (),
464- Format : "$remote_addr - $remote_user [$time_local] \" $request\" $status $body_bytes_sent " +
465- "\" $http_referer\" \" $http_user_agent\" \" $http_x_forwarded_for\" \" $bytes_sent\" " +
466- "\" $request_length\" \" $request_time\" \" $gzip_ratio\" $server_protocol " ,
467- Permissions : "0600" ,
468- Readable : true ,
469- },
470- },
471- ErrorLogs : []* model.ErrorLog {
472- {
473- Name : errorLog .Name (),
474- Permissions : "0600" ,
475- Readable : true ,
476- },
477- },
478- NAPSysLogServers : nil ,
479- },
410+ expectedConfigContext : modelHelpers .GetConfigContextWithFiles (
411+ accessLog .Name (),
412+ errorLog .Name (),
413+ []* mpi.File {& certFileWithMetas , & diffCertFileWithMetas },
414+ protos .GetNginxPlusInstance ([]string {}).GetInstanceMeta ().GetInstanceId (),
415+ nil ,
416+ ),
480417 allowedDirectories : []string {dir },
481418 },
482419 {
@@ -488,34 +425,13 @@ func TestNginxConfigParser_Parse(t *testing.T) {
488425 certFile ,
489426 certFile ,
490427 ),
491- expectedConfigContext : & model.NginxConfigContext {
492- StubStatus : & model.APIDetails {},
493- PlusAPI : & model.APIDetails {},
494- InstanceID : protos .GetNginxPlusInstance ([]string {}).GetInstanceMeta ().GetInstanceId (),
495- Files : []* mpi.File {
496- {
497- FileMeta : fileMetaCertFiles ,
498- },
499- },
500- AccessLogs : []* model.AccessLog {
501- {
502- Name : accessLog .Name (),
503- Format : "$remote_addr - $remote_user [$time_local] \" $request\" $status $body_bytes_sent " +
504- "\" $http_referer\" \" $http_user_agent\" \" $http_x_forwarded_for\" \" $bytes_sent\" " +
505- "\" $request_length\" \" $request_time\" \" $gzip_ratio\" $server_protocol " ,
506- Permissions : "0600" ,
507- Readable : true ,
508- },
509- },
510- ErrorLogs : []* model.ErrorLog {
511- {
512- Name : errorLog .Name (),
513- Permissions : "0600" ,
514- Readable : true ,
515- },
516- },
517- NAPSysLogServers : nil ,
518- },
428+ expectedConfigContext : modelHelpers .GetConfigContextWithFiles (
429+ accessLog .Name (),
430+ errorLog .Name (),
431+ []* mpi.File {& certFileWithMetas },
432+ protos .GetNginxPlusInstance ([]string {}).GetInstanceMeta ().GetInstanceId (),
433+ nil ,
434+ ),
519435 allowedDirectories : []string {dir },
520436 },
521437 }
0 commit comments