Skip to content

Commit 92669de

Browse files
committed
fix: remove incorrect API key prefix validation
Remove the 'fk_' prefix requirement for API keys as it doesn't match the actual validation logic in fc-safari (which only checks length >= 10 and last 3 digits are numeric). - Remove prefix validation from Validate() method - Remove invalid_api_key_prefix test case - Update test data to use realistic API keys without 'fk_' prefix
1 parent 84c559a commit 92669de

2 files changed

Lines changed: 8 additions & 20 deletions

File tree

config/config.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,6 @@ func (c *Config) Validate() error {
128128
return fmt.Errorf("api_key is required")
129129
}
130130

131-
if !strings.HasPrefix(c.APIKey, "fk_") {
132-
return fmt.Errorf("api_key must start with 'fk_'")
133-
}
134-
135131
if c.APIURL == "" {
136132
return fmt.Errorf("API_url is required")
137133
}

config/config_test.go

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func TestConfigValidate(t *testing.T) {
2727
{
2828
name: "valid config",
2929
config: &Config{
30-
APIKey: "fk_test_key_12345",
30+
APIKey: "test_key_12345",
3131
APIURL: "wss://api.flashcat.cloud/runner/ws",
3232
},
3333
wantErr: "",
@@ -39,25 +39,17 @@ func TestConfigValidate(t *testing.T) {
3939
},
4040
wantErr: "api_key is required",
4141
},
42-
{
43-
name: "invalid api_key prefix",
44-
config: &Config{
45-
APIKey: "invalid_key",
46-
APIURL: "wss://api.flashcat.cloud/runner/ws",
47-
},
48-
wantErr: "api_key must start with 'fk_'",
49-
},
5042
{
5143
name: "missing API_url",
5244
config: &Config{
53-
APIKey: "fk_test_key",
45+
APIKey: "test_key",
5446
},
5547
wantErr: "API_url is required",
5648
},
5749
{
5850
name: "invalid API_url scheme",
5951
config: &Config{
60-
APIKey: "fk_test_key",
52+
APIKey: "test_key",
6153
APIURL: "http://invalid.url",
6254
},
6355
wantErr: "API_url must start with ws:// or wss://",
@@ -107,7 +99,7 @@ func TestLoadFromFile(t *testing.T) {
10799
configPath := filepath.Join(tmpDir, "config.yaml")
108100

109101
configContent := `
110-
api_key: "fk_test_key_12345"
102+
api_key: "test_key_12345"
111103
API_url: "wss://test.api.cloud/runner/ws"
112104
name: "test-runner"
113105
labels:
@@ -129,7 +121,7 @@ log:
129121
cfg, err := Load(configPath)
130122
require.NoError(t, err)
131123

132-
assert.Equal(t, "fk_test_key_12345", cfg.APIKey)
124+
assert.Equal(t, "test_key_12345", cfg.APIKey)
133125
assert.Equal(t, "wss://test.api.cloud/runner/ws", cfg.APIURL)
134126
assert.Equal(t, "test-runner", cfg.Name)
135127
assert.Contains(t, cfg.Labels, "k8s")
@@ -148,18 +140,18 @@ func TestLoadWithEnvOverride(t *testing.T) {
148140
configPath := filepath.Join(tmpDir, "config.yaml")
149141

150142
configContent := `
151-
api_key: "fk_file_key"
143+
api_key: "file_key_123"
152144
API_url: "wss://api.flashcat.cloud/runner/ws"
153145
`
154146
err := os.WriteFile(configPath, []byte(configContent), 0o600)
155147
require.NoError(t, err)
156148

157149
// Set environment variable
158-
t.Setenv("FLASHDUTY_RUNNER_API_KEY", "fk_env_key")
150+
t.Setenv("FLASHDUTY_RUNNER_API_KEY", "env_key_456")
159151

160152
cfg, err := Load(configPath)
161153
require.NoError(t, err)
162154

163155
// Environment variable should override file value
164-
assert.Equal(t, "fk_env_key", cfg.APIKey)
156+
assert.Equal(t, "env_key_456", cfg.APIKey)
165157
}

0 commit comments

Comments
 (0)