🧪 test: add JWT secret rotation BDD scenarios and step implementations #12
@@ -39,7 +39,7 @@ func waitForConfigReload(client *testserver.Client, timeout time.Duration) error
|
|||||||
// Get initial config state
|
// Get initial config state
|
||||||
var initialConfig string
|
var initialConfig string
|
||||||
if err := client.Request("GET", "/api/config", nil); err == nil {
|
if err := client.Request("GET", "/api/config", nil); err == nil {
|
||||||
initialConfig = string(client.LastBody())
|
initialConfig = string(client.GetLastBody())
|
||||||
}
|
}
|
||||||
|
|
||||||
ticker := time.NewTicker(500 * time.Millisecond)
|
ticker := time.NewTicker(500 * time.Millisecond)
|
||||||
@@ -52,7 +52,7 @@ func waitForConfigReload(client *testserver.Client, timeout time.Duration) error
|
|||||||
case <-ticker.C:
|
case <-ticker.C:
|
||||||
// Check if config has changed
|
// Check if config has changed
|
||||||
if err := client.Request("GET", "/api/config", nil); err == nil {
|
if err := client.Request("GET", "/api/config", nil); err == nil {
|
||||||
currentConfig := string(client.LastBody())
|
currentConfig := string(client.GetLastBody())
|
||||||
if currentConfig != initialConfig {
|
if currentConfig != initialConfig {
|
||||||
log.Debug().Msg("Config reload detected")
|
log.Debug().Msg("Config reload detected")
|
||||||
return nil
|
return nil
|
||||||
@@ -119,7 +119,7 @@ func waitForJWTToken(client *testserver.Client, timeout time.Duration) error {
|
|||||||
return fmt.Errorf("JWT token not received after %v: %w", timeout, ctx.Err())
|
return fmt.Errorf("JWT token not received after %v: %w", timeout, ctx.Err())
|
||||||
case <-ticker.C:
|
case <-ticker.C:
|
||||||
// Check if we have a valid token in the last response
|
// Check if we have a valid token in the last response
|
||||||
body := client.LastBody()
|
body := client.GetLastBody()
|
||||||
if len(body) > 0 && isValidJWTToken(string(body)) {
|
if len(body) > 0 && isValidJWTToken(string(body)) {
|
||||||
log.Debug().Msg("Valid JWT token received")
|
log.Debug().Msg("Valid JWT token received")
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
Reference in New Issue
Block a user