Skip to content

Commit 01e5bb3

Browse files
authored
Merge pull request #132 from stackitcloud/feature/cert-manager_base-url
fix: add tests and fix small issue with the SA URL passing
2 parents fd9f92b + f0f5e42 commit 01e5bb3

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

internal/resolver/config_test.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,16 @@ func TestLoadConfig(t *testing.T) {
7979
require.Equal(t, "auth-token", cfg.AuthTokenSecretKey)
8080
require.Equal(t, int64(600), cfg.AcmeTxtRecordTTL)
8181
})
82+
83+
t.Run("custom service account base url", func(t *testing.T) {
84+
t.Parallel()
85+
86+
rawCfg := &v1.JSON{Raw: []byte(`{"projectId":"test", "authTokenSecretNamespace": "test", "serviceAccountBaseUrl": "https://custom.stackit.cloud/dns"}`)}
87+
cfg, err := d.LoadConfig(rawCfg)
88+
require.NoError(t, err)
89+
require.Equal(t, "test", cfg.ProjectId)
90+
require.Equal(t, "https://custom.stackit.cloud/dns", cfg.ServiceAccountBaseUrl)
91+
})
8292
}
8393

8494
func TestDefaultConfigProvider_LoadConfigNamespaceFile(t *testing.T) {
@@ -152,13 +162,15 @@ func TestGetRepositoryConfig_WithSaKeyPath(t *testing.T) {
152162
}
153163

154164
cfg := &StackitDnsProviderConfig{
155-
ApiBasePath: "https://api.stackit.cloud",
156-
ProjectId: "test-project",
165+
ApiBasePath: "https://api.stackit.cloud",
166+
ProjectId: "test-project",
167+
ServiceAccountBaseUrl: "https://sa-custom.stackit.cloud",
157168
}
158169

159170
config, err := r.getRepositoryConfig(cfg)
160171
require.NoError(t, err)
161172
require.Equal(t, saKeyPath, config.SaKeyPath)
173+
require.Equal(t, "https://sa-custom.stackit.cloud", config.ServiceAccountBaseUrl)
162174
require.True(t, config.UseSaKey)
163175
}
164176

internal/resolver/resolver.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -240,10 +240,11 @@ func (s *stackitDnsProviderResolver) getRepositoryConfig(
240240
cfg *StackitDnsProviderConfig,
241241
) (repository.Config, error) {
242242
config := repository.Config{
243-
ApiBasePath: cfg.ApiBasePath,
244-
ProjectId: cfg.ProjectId,
245-
HttpClient: s.httpClient,
246-
UseSaKey: false,
243+
ApiBasePath: cfg.ApiBasePath,
244+
ProjectId: cfg.ProjectId,
245+
HttpClient: s.httpClient,
246+
UseSaKey: false,
247+
ServiceAccountBaseUrl: cfg.ServiceAccountBaseUrl,
247248
}
248249

249250
switch {
@@ -253,6 +254,7 @@ func (s *stackitDnsProviderResolver) getRepositoryConfig(
253254
s.logger.Info(
254255
"Using service account key for authentication",
255256
zap.String("saKeyPath", config.SaKeyPath),
257+
zap.String("serviceAccountBaseUrl", config.ServiceAccountBaseUrl),
256258
)
257259
default:
258260
authToken, err := s.getAuthToken(cfg)

0 commit comments

Comments
 (0)