diff --git a/splitio/commitversion.go b/splitio/commitversion.go index c10965dc..dfb3f8ed 100644 --- a/splitio/commitversion.go +++ b/splitio/commitversion.go @@ -5,4 +5,4 @@ This file is created automatically, please do not edit */ // CommitVersion is the version of the last commit previous to release -const CommitVersion = "59410e1" +const CommitVersion = "eb1a57b" diff --git a/splitio/producer/conf/sections.go b/splitio/producer/conf/sections.go index 0436ae5d..139225d5 100644 --- a/splitio/producer/conf/sections.go +++ b/splitio/producer/conf/sections.go @@ -17,7 +17,7 @@ type Main struct { Integrations conf.Integrations `json:"integrations" s-nested:"true"` Logging conf.Logging `json:"logging" s-nested:"true"` Healthcheck Healthcheck `json:"healthcheck" s-nested:"true"` - SpecVersion string + SpecVersion string `json:"specVersion" s-cli:"spec-version" s-def:"1.1" s-desc:"Spec version for flags"` } // BuildAdvancedConfig generates a commons-compatible advancedconfig with default + overriden parameters diff --git a/splitio/producer/initialization.go b/splitio/producer/initialization.go index 3cd5b5f8..9c238f5b 100644 --- a/splitio/producer/initialization.go +++ b/splitio/producer/initialization.go @@ -46,7 +46,6 @@ const ( // Start initialize the producer mode func Start(logger logging.LoggerInterface, cfg *conf.Main) error { // Getting initial config data - cfg.SpecVersion = "1.0" // @TODO Until is implemented advanced := cfg.BuildAdvancedConfig() advanced.AuthSpecVersion = cfg.SpecVersion advanced.FlagsSpecVersion = cfg.SpecVersion diff --git a/splitio/producer/initialization_test.go b/splitio/producer/initialization_test.go index d2e1221e..12554bca 100644 --- a/splitio/producer/initialization_test.go +++ b/splitio/producer/initialization_test.go @@ -126,7 +126,8 @@ func TestSanitizeRedisWithForcedCleanup(t *testing.T) { func TestSanitizeRedisWithRedisEqualApiKey(t *testing.T) { cfg := getDefaultConf() - cfg.Apikey = "djasghdhjasfganyr73dsah9" + cfg.Apikey = "983564etyrudhijfgknf9i08euh" + cfg.SpecVersion = "1.0" logger := logging.NewLogger(nil) @@ -139,9 +140,10 @@ func TestSanitizeRedisWithRedisEqualApiKey(t *testing.T) { if err != nil { t.Error("It should be nil") } + hash := util.HashAPIKey(cfg.Apikey + cfg.SpecVersion + strings.Join(cfg.FlagSetsFilter, "::")) redisClient.Set("SPLITIO.test1", "123", 0) - redisClient.Set("SPLITIO.hash", "3376912823", 0) + redisClient.Set("SPLITIO.hash", hash, 0) miscStorage := predis.NewMiscStorage(redisClient, logger) err = sanitizeRedis(cfg, miscStorage, logger) @@ -155,16 +157,18 @@ func TestSanitizeRedisWithRedisEqualApiKey(t *testing.T) { } val, _ = redisClient.Get("SPLITIO.hash") - if val != "3376912823" { + if val != strconv.FormatUint(uint64(hash), 10) { t.Error("Incorrect apikey hash set in redis after sanitization operation.") } + redisClient.Del("SPLITIO.hash") redisClient.Del("SPLITIO.test1") } func TestSanitizeRedisWithRedisDifferentApiKey(t *testing.T) { cfg := getDefaultConf() cfg.Apikey = "983564etyrudhijfgknf9i08euh" + cfg.SpecVersion = "1.0" logger := logging.NewLogger(nil) @@ -177,9 +181,12 @@ func TestSanitizeRedisWithRedisDifferentApiKey(t *testing.T) { if err != nil { t.Error("It should be nil") } + hash := util.HashAPIKey("djasghdhjasfganyr73dsah9" + cfg.SpecVersion + strings.Join(cfg.FlagSetsFilter, "::")) redisClient.Set("SPLITIO.test1", "123", 0) - redisClient.Set("SPLITIO.hash", "3376912823", 0) + redisClient.Set("SPLITIO.hash", "3216514561", 0) + + hash = util.HashAPIKey(cfg.Apikey + cfg.SpecVersion + strings.Join(cfg.FlagSetsFilter, "::")) miscStorage := predis.NewMiscStorage(redisClient, logger) err = sanitizeRedis(cfg, miscStorage, logger) @@ -193,20 +200,22 @@ func TestSanitizeRedisWithRedisDifferentApiKey(t *testing.T) { } val, _ = redisClient.Get("SPLITIO.hash") - if val != "1497926959" { - t.Error("Incorrect apikey hash set in redis after sanitization operation.") + if val != strconv.FormatUint(uint64(hash), 10) { + t.Error("Incorrect apikey hash set in redis after sanitization operation.", val) } + redisClient.Del("SPLITIO.hash") redisClient.Del("SPLITIO.test1") } func TestSanitizeRedisWithForcedCleanupByFlagSets(t *testing.T) { cfg := getDefaultConf() + cfg.SpecVersion = "1.0" cfg.Apikey = "983564etyrudhijfgknf9i08euh" cfg.Initialization.ForceFreshStartup = true cfg.FlagSetsFilter = []string{"flagset1", "flagset2"} - hash := util.HashAPIKey(cfg.Apikey + strings.Join(cfg.FlagSetsFilter, "::")) + hash := util.HashAPIKey(cfg.Apikey + cfg.SpecVersion + strings.Join(cfg.FlagSetsFilter, "::")) logger := logging.NewLogger(nil) diff --git a/splitio/proxy/conf/sections.go b/splitio/proxy/conf/sections.go index 3f7d796a..7c9d13e6 100644 --- a/splitio/proxy/conf/sections.go +++ b/splitio/proxy/conf/sections.go @@ -20,6 +20,7 @@ type Main struct { Logging conf.Logging `json:"logging" s-nested:"true"` Healthcheck Healthcheck `json:"healthcheck" s-nested:"true"` Observability Observability `json:"observability" s-nested:"true"` + SpecVersion string `json:"specVersion" s-cli:"spec-version" s-def:"1.1" s-desc:"Spec version for flags"` } // BuildAdvancedConfig generates a commons-compatible advancedconfig with default + overriden parameters diff --git a/splitio/proxy/initialization.go b/splitio/proxy/initialization.go index 80254925..9e0f8c06 100644 --- a/splitio/proxy/initialization.go +++ b/splitio/proxy/initialization.go @@ -72,6 +72,8 @@ func Start(logger logging.LoggerInterface, cfg *pconf.Main) error { // Getting initial config data advanced := cfg.BuildAdvancedConfig() advanced.FlagSetsFilter = cfg.FlagSetsFilter + advanced.AuthSpecVersion = cfg.SpecVersion + advanced.FlagsSpecVersion = cfg.SpecVersion metadata := util.GetMetadata(cfg.IPAddressEnabled, true) // FlagSetsFilter