@@ -21,12 +21,16 @@ import (
2121 "github.com/stretchr/testify/require"
2222)
2323
24- func TestNotificationChannels_RequireActiveLicense (t * testing.T ) {
24+ func TestNotificationChannels_AvailableWithoutLicense (t * testing.T ) {
2525 t .Parallel ()
2626
2727 server := test .SetupServer (t )
28- server .Client ().Get ("/api/v1/notification-channels" ).
29- ExpectStatus (http .StatusForbidden ).Send (t )
28+ resp := server .Client ().Get ("/api/v1/notification-channels" ).
29+ ExpectStatus (http .StatusOK ).Send (t )
30+
31+ var result api.NotificationChannelListResponse
32+ resp .Unmarshal (t , & result )
33+ assert .Empty (t , result .Channels )
3034}
3135
3236func TestNotificationChannels_AcceptExistingLicenseWithoutFeatureClaim (t * testing.T ) {
@@ -43,20 +47,22 @@ func TestNotificationChannels_AcceptExistingLicenseWithoutFeatureClaim(t *testin
4347 assert .Empty (t , result .Channels )
4448}
4549
46- func TestNotificationRoutes_RequireActiveLicense (t * testing.T ) {
50+ func TestNotificationRoutes_AvailableWithoutLicense (t * testing.T ) {
4751 t .Parallel ()
4852
4953 server := test .SetupServer (t )
50- server .Client ().Get ("/api/v1/notification-routes/global" ).
51- ExpectStatus (http .StatusForbidden ).Send (t )
54+ resp := server .Client ().Get ("/api/v1/notification-routes/global" ).
55+ ExpectStatus (http .StatusOK ).Send (t )
56+
57+ var result api.NotificationRouteSet
58+ resp .Unmarshal (t , & result )
59+ assert .Equal (t , api .NotificationRouteScopeGlobal , result .Scope )
5260}
5361
5462func TestNotificationRoutes_GlobalAndWorkspaceRouteSets (t * testing.T ) {
5563 t .Parallel ()
5664
57- server := test .SetupServer (t ,
58- test .WithServerOptions (frontend .WithLicenseManager (license .NewTestManager ())),
59- )
65+ server := test .SetupServer (t )
6066
6167 channelResp := server .Client ().Post ("/api/v1/notification-channels" , api.NotificationChannelInput {
6268 Name : "Ops Webhook" ,
@@ -172,35 +178,34 @@ func testValue[T any](value *T) T {
172178 return * value
173179}
174180
175- func TestDAGNotifications_UnlicensedSubscriptionUpdates (t * testing.T ) {
181+ func TestDAGNotifications_SubscriptionUpdatesWithoutLicense (t * testing.T ) {
176182 t .Parallel ()
177183
178184 tests := []struct {
179- name string
180- subscriptions * []api.NotificationSubscriptionInput
181- wantStatus int
182- wantSubscriptions int
185+ name string
186+ subscriptions * []api.NotificationSubscriptionInput
187+ wantSubscriptionIDs [] string
188+ wantSubscriptionRefs [] string
183189 }{
184190 {
185- name : "omitted subscriptions preserves existing reusable subscription" ,
186- subscriptions : nil ,
187- wantStatus : http . StatusOK ,
188- wantSubscriptions : 1 ,
191+ name : "omitted subscriptions preserves existing reusable subscription" ,
192+ subscriptions : nil ,
193+ wantSubscriptionIDs : [] string { "subscription-1" } ,
194+ wantSubscriptionRefs : [] string { "channel-1" } ,
189195 },
190196 {
191- name : "empty subscriptions is still gated" ,
192- subscriptions : & []api.NotificationSubscriptionInput {},
193- wantStatus : http .StatusForbidden ,
194- wantSubscriptions : 1 ,
197+ name : "empty subscriptions clears existing reusable subscriptions" ,
198+ subscriptions : & []api.NotificationSubscriptionInput {},
195199 },
196200 {
197- name : "non-empty subscriptions is gated " ,
201+ name : "non-empty subscriptions replaces reusable subscriptions " ,
198202 subscriptions : & []api.NotificationSubscriptionInput {{
203+ Id : new ("subscription - 2 "),
199204 ChannelId : "channel-1" ,
200205 Enabled : true ,
201206 }},
202- wantStatus : http . StatusForbidden ,
203- wantSubscriptions : 1 ,
207+ wantSubscriptionIDs : [] string { "subscription-2" } ,
208+ wantSubscriptionRefs : [] string { "channel-1" } ,
204209 },
205210 }
206211
@@ -217,21 +222,26 @@ func TestDAGNotifications_UnlicensedSubscriptionUpdates(t *testing.T) {
217222 Enabled : true ,
218223 Events : []api.NotificationEventType {api .NotificationEventTypeDagRunFailed },
219224 Targets : []api.NotificationTargetInput {},
220- // nil means an older/unlicensed client is not managing reusable
221- // subscriptions; non-nil means it is trying to replace them.
225+ // nil means an older client is not managing reusable subscriptions;
226+ // non-nil means it is trying to replace them.
222227 Subscriptions : tt .subscriptions ,
223- }).ExpectStatus (tt .wantStatus ).Send (t )
224-
225- if tt .wantStatus == http .StatusOK {
226- var settings api.DAGNotificationSettings
227- response .Unmarshal (t , & settings )
228- require .Len (t , settings .Subscriptions , tt .wantSubscriptions )
228+ }).ExpectStatus (http .StatusOK ).Send (t )
229+
230+ var apiSettings api.DAGNotificationSettings
231+ response .Unmarshal (t , & apiSettings )
232+ require .Len (t , apiSettings .Subscriptions , len (tt .wantSubscriptionIDs ))
233+ for i , wantID := range tt .wantSubscriptionIDs {
234+ assert .Equal (t , wantID , apiSettings .Subscriptions [i ].Id )
235+ assert .Equal (t , tt .wantSubscriptionRefs [i ], apiSettings .Subscriptions [i ].ChannelId )
229236 }
230237
231238 settings , err := store .GetByDAGName (context .Background (), dagName )
232239 require .NoError (t , err )
233- require .Len (t , settings .Subscriptions , tt .wantSubscriptions )
234- assert .Equal (t , "subscription-1" , settings .Subscriptions [0 ].ID )
240+ require .Len (t , settings .Subscriptions , len (tt .wantSubscriptionIDs ))
241+ for i , wantID := range tt .wantSubscriptionIDs {
242+ assert .Equal (t , wantID , settings .Subscriptions [i ].ID )
243+ assert .Equal (t , tt .wantSubscriptionRefs [i ], settings .Subscriptions [i ].ChannelID )
244+ }
235245 })
236246 }
237247}
0 commit comments