File size: 1,055 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
package smoke
import (
"testing"
"github.com/target/goalert/app"
"github.com/target/goalert/keyring"
"github.com/target/goalert/test/smoke/harness"
)
// TestDataEncKeyRotation tests that the data encryption key can be rotated.
func TestDataEncKeyRotation(t *testing.T) {
h := harness.NewStoppedHarnessWithFlags(t, "", nil, "", nil)
defer h.Close()
// first startup will generate keys using the provided key
h.StartWithAppCfgHook(func(c *app.Config) {
c.EncryptionKeys = keyring.Keys{[]byte("test-orig-key")}
})
// second startup will use the original key for existing data, and the new key for new data
h.RestartGoAlertWithAppCfgHook(func(c *app.Config) {
c.EncryptionKeys = keyring.Keys{[]byte("test-new-key"), []byte("test-orig-key")}
})
// ensure we re-encrypt _all_ data with the new key
h.GraphQLQuery2(`mutation{ reEncryptKeyringsAndConfig }`)
// Lastly, we should be able to startup with only the new key
h.RestartGoAlertWithAppCfgHook(func(c *app.Config) {
c.EncryptionKeys = keyring.Keys{[]byte("test-new-key")}
})
}
|