Skip to content

Commit

Permalink
Merge pull request #29 from 7or2ga/info-return-seconds
Browse files Browse the repository at this point in the history
Update GetQuotaJson() to return quota windows measured in seconds
  • Loading branch information
jshufro authored Oct 10, 2024
2 parents 852254e + 7cb0af6 commit 6165f57
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions services/credentials.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ func AuthValidityWindow(ot credentials.OperatorType) time.Duration {
func GetQuotaJSON(ot credentials.OperatorType) (json.RawMessage, error) {
quotaData := map[string]interface{}{
"count": uint(credsQuota(ot)),
"window": credsQuotaWindow(ot),
"authValidityWindow": AuthValidityWindow(ot),
"window": int64(credsQuotaWindow(ot).Seconds()),
"authValidityWindow": int64(AuthValidityWindow(ot).Seconds()),
}

quotaJson, err := json.Marshal(quotaData)
Expand Down
4 changes: 2 additions & 2 deletions services/credentials_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ func TestGetQuotaJson(t *testing.T) {
t.Fatalf("Error parsing window from quota json")
}
window := int64(fWindow)
if window != int64(credsQuotaWindow(pb.OperatorType_OT_ROCKETPOOL)) {
if window != int64(credsQuotaWindow(pb.OperatorType_OT_ROCKETPOOL).Seconds()) {
t.Fatalf("Incorrect quota window. Expected %d, got %d", int64(credsQuotaWindow(pb.OperatorType_OT_ROCKETPOOL)), window)
}

Expand All @@ -360,7 +360,7 @@ func TestGetQuotaJson(t *testing.T) {
if !ok {
t.Fatalf("Error parsing authValidityWindow from quota json")
}
if authValidityWindow != int64(AuthValidityWindow(pb.OperatorType_OT_ROCKETPOOL)) {
if authValidityWindow != int64(AuthValidityWindow(pb.OperatorType_OT_ROCKETPOOL).Seconds()) {
t.Fatalf("Incorrect quota authValidityWindow. Expected %d, got %d", AuthValidityWindow(pb.OperatorType_OT_ROCKETPOOL), authValidityWindow)
}
}

0 comments on commit 6165f57

Please sign in to comment.