Skip to content

Commit caf534b

Browse files
committed
test: restructure code for test
1 parent 3e59683 commit caf534b

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

path_config_rotate.go

+7-11
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,14 @@ func pathConfigTokenRotate(b *Backend) *framework.Path {
4343
func (b *Backend) checkAndRotateConfigToken(ctx context.Context, request *logical.Request, config *EntryConfig) error {
4444
var err error
4545
b.Logger().Debug("Running check and rotate config token")
46-
47-
if time.Until(config.TokenExpiresAt) > config.AutoRotateBefore {
48-
b.Logger().Debug("Nothing to do it's not yet time to rotate the token")
49-
return nil
46+
if time.Until(config.TokenExpiresAt) <= config.AutoRotateBefore {
47+
_, err = b.pathConfigTokenRotate(ctx, request, &framework.FieldData{
48+
Raw: map[string]interface{}{
49+
"config_name": cmp.Or(config.Name, TypeConfigDefault),
50+
},
51+
Schema: FieldSchemaConfig,
52+
})
5053
}
51-
52-
_, err = b.pathConfigTokenRotate(ctx, request, &framework.FieldData{
53-
Raw: map[string]interface{}{
54-
"config_name": cmp.Or(config.Name, TypeConfigDefault),
55-
},
56-
Schema: FieldSchemaConfig,
57-
})
5854
return err
5955
}
6056

0 commit comments

Comments
 (0)