@@ -21,6 +21,7 @@ import (
2121 "sigs.k8s.io/controller-runtime/pkg/client"
2222 gateway_v1 "sigs.k8s.io/gateway-api/apis/v1"
2323
24+ "github.com/pomerium/pomerium/config"
2425 "github.com/pomerium/sdk-go/proto/pomerium"
2526
2627 icgv1alpha1 "github.com/pomerium/ingress-controller/apis/gateway/v1alpha1"
@@ -1028,6 +1029,9 @@ func TestAPIReconciler_SetConfig(t *testing.T) {
10281029 },
10291030 }
10301031
1032+ defaultSettings , err := convertProto [* pomerium.Settings ](config .NewDefaultOptions ().ToProto ().GetSettings ())
1033+ require .NoError (t , err )
1034+
10311035 t .Run ("settings changed" , func (t * testing.T ) {
10321036 apiClient , _ , r := setupReconciler (t )
10331037 ctx := t .Context ()
@@ -1042,16 +1046,20 @@ func TestAPIReconciler_SetConfig(t *testing.T) {
10421046 },
10431047 }, nil )
10441048
1049+ expectedSettings := proto .CloneOf (defaultSettings )
1050+ proto .Merge (expectedSettings , & pomerium.Settings {
1051+ Id : new ("settings - id - 123 "),
1052+ AuthenticateServiceUrl : new ("https ://authenticate.localhost.pomerium.io"),
1053+ IdpClientId : new ("CLIENT_ID "),
1054+ IdpClientSecret : new ("CLIENT_SECRET "),
1055+ IdpProvider : new ("oidc "),
1056+ IdpProviderUrl : new ("https ://idp.example.com"),
1057+ PassIdentityHeaders : new (true ),
1058+ })
1059+
10451060 // ...and then call UpdateSettings() once it knows there are changes to sync.
10461061 apiClient .EXPECT ().UpdateSettings (ctx , RequestEq (& pomerium.UpdateSettingsRequest {
1047- Settings : & pomerium.Settings {
1048- AuthenticateServiceUrl : new ("https ://authenticate.localhost.pomerium.io"),
1049- IdpClientId : new ("CLIENT_ID "),
1050- IdpClientSecret : new ("CLIENT_SECRET "),
1051- IdpProvider : new ("oidc "),
1052- IdpProviderUrl : new ("https ://idp.example.com"),
1053- PassIdentityHeaders : new (true ),
1054- },
1062+ Settings : expectedSettings ,
10551063 })).Return (& connect.Response [pomerium.UpdateSettingsResponse ]{
10561064 Msg : & pomerium.UpdateSettingsResponse {},
10571065 }, nil )
@@ -1065,19 +1073,25 @@ func TestAPIReconciler_SetConfig(t *testing.T) {
10651073 apiClient , _ , r := setupReconciler (t )
10661074 ctx := t .Context ()
10671075
1076+ existingSettings := proto .CloneOf (defaultSettings )
1077+ proto .Merge (existingSettings , & pomerium.Settings {
1078+ Id : new ("settings - id - 123 "),
1079+
1080+ AuthenticateServiceUrl : new ("https ://authenticate.localhost.pomerium.io"),
1081+ IdpClientId : new ("CLIENT_ID "),
1082+ IdpClientSecret : new ("CLIENT_SECRET "),
1083+ IdpProvider : new ("oidc "),
1084+ IdpProviderUrl : new ("https ://idp.example.com"),
1085+ PassIdentityHeaders : new (true ),
1086+
1087+ AutoApplyChangesets : new (true ), // this setting should be ignored
1088+ })
1089+
10681090 // If the settings already match, there should be no UpdateSettings() call.
10691091 apiClient .EXPECT ().GetSettings (ctx , connect .NewRequest (& pomerium.GetSettingsRequest {})).
10701092 Return (& connect.Response [pomerium.GetSettingsResponse ]{
10711093 Msg : & pomerium.GetSettingsResponse {
1072- Settings : & pomerium.Settings {
1073- Id : new ("settings - id - 123 "),
1074-
1075- AuthenticateServiceUrl : new ("https ://authenticate.localhost.pomerium.io"),
1076- IdpClientId : new ("CLIENT_ID "),
1077- IdpClientSecret : new ("CLIENT_SECRET "),
1078- IdpProvider : new ("oidc "),
1079- IdpProviderUrl : new ("https ://idp.example.com"),
1080- PassIdentityHeaders : new (true )},
1094+ Settings : existingSettings ,
10811095 },
10821096 }, nil )
10831097
0 commit comments