Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion splitio/commitversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 1 addition & 1 deletion splitio/producer/conf/sections.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion splitio/producer/initialization.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 16 additions & 7 deletions splitio/producer/initialization_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)
Expand All @@ -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)

Expand All @@ -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)
Expand All @@ -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)

Expand Down
1 change: 1 addition & 0 deletions splitio/proxy/conf/sections.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions splitio/proxy/initialization.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down