fix: added console environment attribute for subscription service (#1620)

* fix: add subscription service url to console environment json

* fix: corrected missed unit-tests

* fix: show edit button on new orgs (#1606)

* fix: reset login_policy views (to ensure defaults) (#1605)

* fix: reset login_policy views (to ensure defaults)

* fix: migration 1.37

Co-authored-by: Max Peintner <max@caos.ch>
Co-authored-by: Livio Amstutz <livio.a@gmail.com>
This commit is contained in:
Stefan Benz 2021-04-20 07:33:52 +02:00 committed by GitHub
parent 2c20292b24
commit 1f72eaab82
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 30 additions and 25 deletions

View File

@ -1,8 +1,6 @@
package configuration package configuration
import ( import (
"time"
"github.com/caos/orbos/mntr" "github.com/caos/orbos/mntr"
"github.com/caos/orbos/pkg/kubernetes" "github.com/caos/orbos/pkg/kubernetes"
"github.com/caos/orbos/pkg/kubernetes/resources/configmap" "github.com/caos/orbos/pkg/kubernetes/resources/configmap"
@ -11,6 +9,7 @@ import (
"github.com/caos/zitadel/operator" "github.com/caos/zitadel/operator"
"github.com/caos/zitadel/operator/zitadel/kinds/iam/zitadel/configuration/users" "github.com/caos/zitadel/operator/zitadel/kinds/iam/zitadel/configuration/users"
"github.com/caos/zitadel/operator/zitadel/kinds/iam/zitadel/database" "github.com/caos/zitadel/operator/zitadel/kinds/iam/zitadel/database"
"time"
) )
type ConsoleEnv struct { type ConsoleEnv struct {
@ -18,6 +17,7 @@ type ConsoleEnv struct {
MgmtServiceURL string `json:"mgmtServiceUrl"` MgmtServiceURL string `json:"mgmtServiceUrl"`
Issuer string `json:"issuer"` Issuer string `json:"issuer"`
ClientID string `json:"clientid"` ClientID string `json:"clientid"`
SubServiceURL string `json:"subscriptionServiceUrl"`
} }
const ( const (

View File

@ -22,10 +22,11 @@ type DNS struct {
} }
type Subdomains struct { type Subdomains struct {
Accounts string `yaml:"accounts"` Accounts string `yaml:"accounts"`
API string `yaml:"api"` API string `yaml:"api"`
Console string `yaml:"console"` Console string `yaml:"console"`
Issuer string `yaml:"issuer"` Issuer string `yaml:"issuer"`
Subscription string `yaml:"subscription"`
} }
type Passwords struct { type Passwords struct {
Migration *secret.Secret `yaml:"migration"` Migration *secret.Secret `yaml:"migration"`

View File

@ -199,6 +199,7 @@ func literalsConsoleCM(
consoleEnv.Issuer = "https://" + dns.Subdomains.Issuer + "." + dns.Domain consoleEnv.Issuer = "https://" + dns.Subdomains.Issuer + "." + dns.Domain
consoleEnv.AuthServiceURL = "https://" + dns.Subdomains.API + "." + dns.Domain consoleEnv.AuthServiceURL = "https://" + dns.Subdomains.API + "." + dns.Domain
consoleEnv.MgmtServiceURL = "https://" + dns.Subdomains.API + "." + dns.Domain consoleEnv.MgmtServiceURL = "https://" + dns.Subdomains.API + "." + dns.Domain
consoleEnv.SubServiceURL = "https://" + dns.Subdomains.Subscription + "." + dns.Domain
data, err := json.Marshal(consoleEnv) data, err := json.Marshal(consoleEnv)
if err != nil { if err != nil {

View File

@ -62,10 +62,11 @@ var (
Domain: "", Domain: "",
TlsSecret: "", TlsSecret: "",
Subdomains: &Subdomains{ Subdomains: &Subdomains{
Accounts: "", Accounts: "",
API: "", API: "",
Console: "", Console: "",
Issuer: "", Issuer: "",
Subscription: "",
}, },
}, },
ClusterDNS: "", ClusterDNS: "",
@ -119,10 +120,11 @@ var (
Domain: "domain", Domain: "domain",
TlsSecret: "tls", TlsSecret: "tls",
Subdomains: &Subdomains{ Subdomains: &Subdomains{
Accounts: "accounts", Accounts: "accounts",
API: "api", API: "api",
Console: "console", Console: "console",
Issuer: "issuer", Issuer: "issuer",
Subscription: "sub",
}, },
}, },
ClusterDNS: "cluster", ClusterDNS: "cluster",
@ -175,10 +177,11 @@ var (
Domain: "domain", Domain: "domain",
TlsSecret: "tls", TlsSecret: "tls",
Subdomains: &Subdomains{ Subdomains: &Subdomains{
Accounts: "accounts", Accounts: "accounts",
API: "api", API: "api",
Console: "console", Console: "console",
Issuer: "issuer", Issuer: "issuer",
Subscription: "sub",
}, },
}, },
ClusterDNS: "cluster", ClusterDNS: "cluster",
@ -496,10 +499,10 @@ func TestConfiguration_LiteralsConsoleCM(t *testing.T) {
Namespace: namespace, Namespace: namespace,
Name: cmName, Name: cmName,
}, },
Data: map[string]string{"environment.json": "{\"authServiceUrl\":\"https://.\",\"mgmtServiceUrl\":\"https://.\",\"issuer\":\"https://.\",\"clientid\":\"\"}"}, Data: map[string]string{"environment.json": "{\"authServiceUrl\":\"https://.\",\"mgmtServiceUrl\":\"https://.\",\"issuer\":\"https://.\",\"clientid\":\"\",\"subscriptionServiceUrl\":\"https://.\"}"},
} }
equals := map[string]string{"environment.json": "{\"authServiceUrl\":\"https://.\",\"mgmtServiceUrl\":\"https://.\",\"issuer\":\"https://.\",\"clientid\":\"\"}"} equals := map[string]string{"environment.json": "{\"authServiceUrl\":\"https://.\",\"mgmtServiceUrl\":\"https://.\",\"issuer\":\"https://.\",\"clientid\":\"\",\"subscriptionServiceUrl\":\"https://.\"}"}
k8sClient.EXPECT().GetConfigMap(namespace, cmName).Times(1).Return(cm, nil) k8sClient.EXPECT().GetConfigMap(namespace, cmName).Times(1).Return(cm, nil)
literals := literalsConsoleCM(clientID, desiredEmpty.DNS, k8sClient, namespace, cmName) literals := literalsConsoleCM(clientID, desiredEmpty.DNS, k8sClient, namespace, cmName)
@ -521,7 +524,7 @@ func TestConfiguration_LiteralsConsoleCMFull(t *testing.T) {
} }
equals := map[string]string{ equals := map[string]string{
"environment.json": "{\"authServiceUrl\":\"https://api.domain\",\"mgmtServiceUrl\":\"https://api.domain\",\"issuer\":\"https://issuer.domain\",\"clientid\":\"test\"}", "environment.json": "{\"authServiceUrl\":\"https://api.domain\",\"mgmtServiceUrl\":\"https://api.domain\",\"issuer\":\"https://issuer.domain\",\"clientid\":\"test\",\"subscriptionServiceUrl\":\"https://sub.domain\"}",
} }
k8sClient.EXPECT().GetConfigMap(namespace, cmName).Times(1).Return(cm, nil) k8sClient.EXPECT().GetConfigMap(namespace, cmName).Times(1).Return(cm, nil)
@ -541,12 +544,12 @@ func TestConfiguration_LiteralsConsoleCMWithCM(t *testing.T) {
Name: cmName, Name: cmName,
}, },
Data: map[string]string{ Data: map[string]string{
"environment.json": "{\"authServiceUrl\":\"https://api.domain\",\"mgmtServiceUrl\":\"https://api.domain\",\"issuer\":\"https://issuer.domain\",\"clientid\":\"\"}", "environment.json": "{\"authServiceUrl\":\"https://api.domain\",\"mgmtServiceUrl\":\"https://api.domain\",\"issuer\":\"https://issuer.domain\",\"clientid\":\"\",\"subscriptionServiceUrl\":\"https://sub.domain\"}",
}, },
} }
equals := map[string]string{ equals := map[string]string{
"environment.json": "{\"authServiceUrl\":\"https://api.domain\",\"mgmtServiceUrl\":\"https://api.domain\",\"issuer\":\"https://issuer.domain\",\"clientid\":\"test\"}", "environment.json": "{\"authServiceUrl\":\"https://api.domain\",\"mgmtServiceUrl\":\"https://api.domain\",\"issuer\":\"https://issuer.domain\",\"clientid\":\"test\",\"subscriptionServiceUrl\":\"https://sub.domain\"}",
} }
k8sClient.EXPECT().GetConfigMap(namespace, cmName).Times(1).Return(cm, nil) k8sClient.EXPECT().GetConfigMap(namespace, cmName).Times(1).Return(cm, nil)
@ -566,12 +569,12 @@ func TestConfiguration_LiteralsConsoleCMWithCMFull(t *testing.T) {
Name: cmName, Name: cmName,
}, },
Data: map[string]string{ Data: map[string]string{
"environment.json": "{\"authServiceUrl\":\"https://api.domain\",\"mgmtServiceUrl\":\"https://api.domain\",\"issuer\":\"https://issuer.domain\",\"clientid\":\"test\"}", "environment.json": "{\"authServiceUrl\":\"https://api.domain\",\"mgmtServiceUrl\":\"https://api.domain\",\"issuer\":\"https://issuer.domain\",\"clientid\":\"test\",\"subscriptionServiceUrl\":\"https://sub.domain\"}",
}, },
} }
equals := map[string]string{ equals := map[string]string{
"environment.json": "{\"authServiceUrl\":\"https://api.domain\",\"mgmtServiceUrl\":\"https://api.domain\",\"issuer\":\"https://issuer.domain\",\"clientid\":\"test\"}", "environment.json": "{\"authServiceUrl\":\"https://api.domain\",\"mgmtServiceUrl\":\"https://api.domain\",\"issuer\":\"https://issuer.domain\",\"clientid\":\"test\",\"subscriptionServiceUrl\":\"https://sub.domain\"}",
} }
k8sClient.EXPECT().GetConfigMap(namespace, cmName).Times(1).Return(cm, nil) k8sClient.EXPECT().GetConfigMap(namespace, cmName).Times(1).Return(cm, nil)