@@ -496,12 +496,12 @@ func Test_ActivityLog_MountDeduplication(t *testing.T) {
496496}
497497
498498// getJSONExport is used to fetch activity export records using json format.
499- // The records will returned as a map keyed by client ID.
500- func getJSONExport (t * testing.T , client * api.Client , monthsPreviousTo int , now time.Time ) (map [string ]vault.ActivityLogExportRecord , error ) {
499+ // The records will be returned as a map keyed by client ID.
500+ func getJSONExport (t * testing.T , client * api.Client , startTime time. Time , now time.Time ) (map [string ]vault.ActivityLogExportRecord , error ) {
501501 t .Helper ()
502502
503503 resp , err := client .Logical ().ReadRawWithData ("sys/internal/counters/activity/export" , map [string ][]string {
504- "start_time" : {timeutil . StartOfMonth ( timeutil . MonthsPreviousTo ( monthsPreviousTo , now )) .Format (time .RFC3339 )},
504+ "start_time" : {startTime .Format (time .RFC3339 )},
505505 "end_time" : {timeutil .EndOfMonth (now ).Format (time .RFC3339 )},
506506 "format" : {"json" },
507507 })
@@ -540,7 +540,7 @@ func getJSONExport(t *testing.T, client *api.Client, monthsPreviousTo int, now t
540540// getCSVExport fetches activity export records using csv format. All flattened
541541// map and slice fields will be unflattened so that the a proper ActivityLogExportRecord
542542// can be formed. The records will returned as a map keyed by client ID.
543- func getCSVExport (t * testing.T , client * api.Client , monthsPreviousTo int , now time.Time ) (map [string ]vault.ActivityLogExportRecord , error ) {
543+ func getCSVExport (t * testing.T , client * api.Client , startTime time. Time , now time.Time ) (map [string ]vault.ActivityLogExportRecord , error ) {
544544 t .Helper ()
545545
546546 boolFields := map [string ]struct {}{
@@ -559,7 +559,7 @@ func getCSVExport(t *testing.T, client *api.Client, monthsPreviousTo int, now ti
559559 }
560560
561561 resp , err := client .Logical ().ReadRawWithData ("sys/internal/counters/activity/export" , map [string ][]string {
562- "start_time" : {timeutil . StartOfMonth ( timeutil . MonthsPreviousTo ( monthsPreviousTo , now )) .Format (time .RFC3339 )},
562+ "start_time" : {startTime .Format (time .RFC3339 )},
563563 "end_time" : {timeutil .EndOfMonth (now ).Format (time .RFC3339 )},
564564 "format" : {"csv" },
565565 })
@@ -677,7 +677,8 @@ func Test_ActivityLog_Export_Sudo(t *testing.T) {
677677 require .NoError (t , err )
678678
679679 // Ensure access via root token
680- clients , err := getJSONExport (t , client , 1 , now )
680+ startTime := timeutil .StartOfMonth (timeutil .MonthsPreviousTo (1 , now ))
681+ clients , err := getJSONExport (t , client , startTime , now )
681682 require .NoError (t , err )
682683 require .Len (t , clients , 10 )
683684
@@ -696,7 +697,7 @@ path "sys/internal/counters/activity/export" {
696697 client .SetToken (nonSudoToken )
697698
698699 // Ensure no access via token without sudo access
699- clients , err = getJSONExport (t , client , 1 , now )
700+ clients , err = getJSONExport (t , client , startTime , now )
700701 require .ErrorContains (t , err , "permission denied" )
701702
702703 client .SetToken (rootToken )
@@ -715,7 +716,7 @@ path "sys/internal/counters/activity/export" {
715716 client .SetToken (sudoToken )
716717
717718 // Ensure access via token with sudo access
718- clients , err = getJSONExport (t , client , 1 , now )
719+ clients , err = getJSONExport (t , client , startTime , now )
719720 require .NoError (t , err )
720721 require .Len (t , clients , 10 )
721722}
0 commit comments