github.com/kyma-incubator/compass/components/director@v0.0.0-20230623144113-d764f56ff805/internal/domain/apptemplate/fixtures_test.go (about) 1 package apptemplate_test 2 3 import ( 4 "database/sql/driver" 5 "encoding/json" 6 "errors" 7 "fmt" 8 "testing" 9 10 "github.com/kyma-incubator/compass/components/director/pkg/str" 11 12 "github.com/kyma-incubator/compass/components/director/internal/domain/apptemplate" 13 "github.com/kyma-incubator/compass/components/director/internal/model" 14 "github.com/kyma-incubator/compass/components/director/internal/repo" 15 "github.com/kyma-incubator/compass/components/director/pkg/graphql" 16 "github.com/kyma-incubator/compass/components/director/pkg/pagination" 17 18 "github.com/DATA-DOG/go-sqlmock" 19 "github.com/stretchr/testify/require" 20 ) 21 22 const ( 23 testTenant = "tnt" 24 testExternalTenant = "external-tnt" 25 testID = "foo" 26 testAppID = "app-id" 27 testConsumerID = "consumer-id" 28 testLabelInputKey = "applicationType" 29 30 testWebhookID = "webhook-id-1" 31 testName = "bar" 32 testAppName = "app-name" 33 updatedAppTemplateTestName = "new-app-template-test-name" 34 testNameOtherSystemType = "Other System Type" 35 testPageSize = 3 36 testCursor = "" 37 appInputJSONString = `{"name":"foo","providerName":"compass","description":"Lorem ipsum","labels":{"displayName":"bar","test":["val","val2"]},"healthCheckURL":"https://foo.bar","webhooks":[{"type":"","url":"webhook1.foo.bar","auth":null},{"type":"","url":"webhook2.foo.bar","auth":null}],"integrationSystemID":"iiiiiiiii-iiii-iiii-iiii-iiiiiiiiiiii"}` 38 appInputJSONWithoutDisplayNameLabelString = `{"name":"foo","providerName":"compass","description":"Lorem ipsum","labels":{"test":["val","val2"]},"healthCheckURL":"https://foo.bar","webhooks":[{"type":"","url":"webhook1.foo.bar","auth":null},{"type":"","url":"webhook2.foo.bar","auth":null}],"integrationSystemID":"iiiiiiiii-iiii-iiii-iiii-iiiiiiiiiiii"}` 39 appInputJSONWithAppTypeLabelString = `{"name":"foo","providerName":"compass","description":"Lorem ipsum","labels":{"applicationType":"%s","test":["val","val2"]},"healthCheckURL":"https://foo.bar","webhooks":[{"type":"","url":"webhook1.foo.bar","auth":null},{"type":"","url":"webhook2.foo.bar","auth":null}],"integrationSystemID":"iiiiiiiii-iiii-iiii-iiii-iiiiiiiiiiii"}` 40 appInputJSONNonStringDisplayNameLabelString = `{"name":"foo","providerName":"compass","description":"Lorem ipsum","labels":{"displayName":false,"test":["val","val2"]},"healthCheckURL":"https://foo.bar","webhooks":[{"type":"","url":"webhook1.foo.bar","auth":null},{"type":"","url":"webhook2.foo.bar","auth":null}],"integrationSystemID":"iiiiiiiii-iiii-iiii-iiii-iiiiiiiiiiii"}` 41 42 appInputGQLString = `{name: "foo",providerName: "compass",description: "Lorem ipsum",labels: {displayName:"bar",test:["val","val2"],},webhooks: [ {type: ,url: "webhook1.foo.bar",}, {type: ,url: "webhook2.foo.bar",} ],healthCheckURL: "https://foo.bar",integrationSystemID: "iiiiiiiii-iiii-iiii-iiii-iiiiiiiiiiii",}` 43 ) 44 45 var ( 46 testUUID = "b3ea1977-582e-4d61-ae12-b3a837a3858e" 47 testDescription = "Lorem ipsum" 48 testJSONPath = "$.test" 49 testDescriptionWithPlaceholder = "Lorem ipsum {{test}}" 50 testProviderName = "provider-display-name" 51 testURL = "http://valid.url" 52 testError = errors.New("test error") 53 testTableColumns = []string{"id", "name", "description", "application_namespace", "application_input", "placeholders", "access_level"} 54 newTestLabels = map[string]interface{}{"label1": "test"} 55 ) 56 57 func fixModelApplicationTemplate(id, name string, webhooks []*model.Webhook) *model.ApplicationTemplate { 58 desc := testDescription 59 out := model.ApplicationTemplate{ 60 ID: id, 61 Name: name, 62 Description: &desc, 63 ApplicationNamespace: str.Ptr("ns"), 64 ApplicationInputJSON: appInputJSONString, 65 Placeholders: fixModelPlaceholders(), 66 Webhooks: modelPtrsToWebhooks(webhooks), 67 AccessLevel: model.GlobalApplicationTemplateAccessLevel, 68 } 69 70 return &out 71 } 72 73 func fixModelApplicationTemplateWithPlaceholdersPayload(id, name string, webhooks []*model.Webhook) *model.ApplicationTemplate { 74 desc := testDescription 75 out := model.ApplicationTemplate{ 76 ID: id, 77 Name: name, 78 Description: &desc, 79 ApplicationNamespace: str.Ptr("ns"), 80 ApplicationInputJSON: appInputJSONString, 81 Placeholders: fixModelPlaceholdersWithPayload(), 82 Webhooks: modelPtrsToWebhooks(webhooks), 83 AccessLevel: model.GlobalApplicationTemplateAccessLevel, 84 } 85 86 return &out 87 } 88 89 func fixModelAppTemplateWithAppInputJSON(id, name, appInputJSON string, webhooks []*model.Webhook) *model.ApplicationTemplate { 90 out := fixModelApplicationTemplate(id, name, webhooks) 91 out.ApplicationInputJSON = appInputJSON 92 93 return out 94 } 95 96 func fixModelAppTemplateWithAppInputJSONAndLabels(id, name, appInputJSON string, webhooks []*model.Webhook, labels map[string]interface{}) *model.ApplicationTemplate { 97 out := fixModelApplicationTemplate(id, name, webhooks) 98 out.Labels = labels 99 out.ApplicationInputJSON = appInputJSON 100 101 return out 102 } 103 104 func fixModelAppTemplateWithAppInputJSONAndPlaceholders(id, name, appInputJSON string, webhooks []*model.Webhook, placeholders []model.ApplicationTemplatePlaceholder) *model.ApplicationTemplate { 105 out := fixModelAppTemplateWithAppInputJSON(id, name, appInputJSON, webhooks) 106 out.Placeholders = placeholders 107 108 return out 109 } 110 111 func fixGQLAppTemplate(id, name string, webhooks []*graphql.Webhook) *graphql.ApplicationTemplate { 112 desc := testDescription 113 114 return &graphql.ApplicationTemplate{ 115 ID: id, 116 Name: name, 117 Description: &desc, 118 ApplicationNamespace: str.Ptr("ns"), 119 ApplicationInput: appInputGQLString, 120 Placeholders: fixGQLPlaceholders(), 121 Webhooks: gqlPtrsToWebhooks(webhooks), 122 AccessLevel: graphql.ApplicationTemplateAccessLevelGlobal, 123 } 124 } 125 126 func fixModelAppTemplatePage(appTemplates []*model.ApplicationTemplate) model.ApplicationTemplatePage { 127 return model.ApplicationTemplatePage{ 128 Data: appTemplates, 129 PageInfo: &pagination.Page{ 130 StartCursor: "start", 131 EndCursor: "end", 132 HasNextPage: false, 133 }, 134 TotalCount: len(appTemplates), 135 } 136 } 137 138 func fixGQLAppTemplatePage(appTemplates []*graphql.ApplicationTemplate) graphql.ApplicationTemplatePage { 139 return graphql.ApplicationTemplatePage{ 140 Data: appTemplates, 141 PageInfo: &graphql.PageInfo{ 142 StartCursor: "start", 143 EndCursor: "end", 144 HasNextPage: false, 145 }, 146 TotalCount: len(appTemplates), 147 } 148 } 149 150 func fixModelAppTemplateInput(name string, appInputString string) *model.ApplicationTemplateInput { 151 desc := testDescription 152 153 return &model.ApplicationTemplateInput{ 154 Name: name, 155 Description: &desc, 156 ApplicationNamespace: str.Ptr("ns"), 157 ApplicationInputJSON: appInputString, 158 Placeholders: fixModelPlaceholders(), 159 Labels: map[string]interface{}{"test": "test"}, 160 AccessLevel: model.GlobalApplicationTemplateAccessLevel, 161 } 162 } 163 164 func fixModelAppTemplateWithIDInput(name, appInputString string, id *string) *model.ApplicationTemplateInput { 165 model := fixModelAppTemplateInput(name, appInputString) 166 model.ID = id 167 168 return model 169 } 170 171 func fixModelAppTemplateUpdateInput(name string, appInputString string) *model.ApplicationTemplateUpdateInput { 172 desc := testDescription 173 174 return &model.ApplicationTemplateUpdateInput{ 175 Name: name, 176 Description: &desc, 177 ApplicationNamespace: str.Ptr("ns"), 178 ApplicationInputJSON: appInputString, 179 Placeholders: fixModelPlaceholders(), 180 AccessLevel: model.GlobalApplicationTemplateAccessLevel, 181 } 182 } 183 184 func fixModelAppTemplateUpdateInputWithPlaceholders(name string, appInputString string, placeholders []model.ApplicationTemplatePlaceholder) *model.ApplicationTemplateUpdateInput { 185 out := fixModelAppTemplateUpdateInput(name, appInputString) 186 out.Placeholders = placeholders 187 188 return out 189 } 190 191 func fixModelAppTemplateUpdateInputWithLabels(name string, appInputString string, labels map[string]interface{}) *model.ApplicationTemplateUpdateInput { 192 out := fixModelAppTemplateUpdateInput(name, appInputString) 193 out.Labels = labels 194 195 return out 196 } 197 198 func fixGQLAppTemplateInput(name string) *graphql.ApplicationTemplateInput { 199 desc := testDescription 200 201 return &graphql.ApplicationTemplateInput{ 202 Name: name, 203 Description: &desc, 204 ApplicationNamespace: str.Ptr("ns"), 205 ApplicationInput: &graphql.ApplicationJSONInput{ 206 Name: "foo", 207 Description: &desc, 208 }, 209 Placeholders: fixGQLPlaceholderDefinitionInput(), 210 Labels: map[string]interface{}{"test": "test"}, 211 AccessLevel: graphql.ApplicationTemplateAccessLevelGlobal, 212 } 213 } 214 215 func fixGQLAppTemplateInputWithPlaceholder(name string) *graphql.ApplicationTemplateInput { 216 desc := testDescriptionWithPlaceholder 217 218 return &graphql.ApplicationTemplateInput{ 219 Name: name, 220 Description: &desc, 221 ApplicationNamespace: str.Ptr("ns"), 222 ApplicationInput: &graphql.ApplicationJSONInput{ 223 Name: "foo", 224 Description: &desc, 225 }, 226 Placeholders: fixGQLPlaceholderDefinitionInput(), 227 AccessLevel: graphql.ApplicationTemplateAccessLevelGlobal, 228 } 229 } 230 231 func fixGQLAppTemplateInputWithPlaceholderAndProvider(name string) *graphql.ApplicationTemplateInput { 232 desc := testDescriptionWithPlaceholder 233 234 return &graphql.ApplicationTemplateInput{ 235 Name: name, 236 Description: &desc, 237 ApplicationNamespace: str.Ptr("ns"), 238 ApplicationInput: &graphql.ApplicationJSONInput{ 239 Name: "foo", 240 Description: &desc, 241 ProviderName: str.Ptr("SAP"), 242 }, 243 Placeholders: fixGQLPlaceholderDefinitionInput(), 244 AccessLevel: graphql.ApplicationTemplateAccessLevelGlobal, 245 } 246 } 247 248 func fixGQLAppTemplateInputInvalidAppInputURLTemplateMethod(name string) *graphql.ApplicationTemplateInput { 249 desc := testDescriptionWithPlaceholder 250 251 return &graphql.ApplicationTemplateInput{ 252 Name: name, 253 Description: &desc, 254 ApplicationNamespace: str.Ptr("ns"), 255 ApplicationInput: &graphql.ApplicationJSONInput{ 256 Name: "foo", 257 Description: &desc, 258 Webhooks: []*graphql.WebhookInput{ 259 { 260 Type: graphql.WebhookTypeUnregisterApplication, 261 URLTemplate: str.Ptr(`{"path": "https://target.url", "method":"invalid method"}`), 262 }, 263 }, 264 }, 265 Placeholders: fixGQLPlaceholderDefinitionInput(), 266 AccessLevel: graphql.ApplicationTemplateAccessLevelGlobal, 267 } 268 } 269 270 func fixGQLAppTemplateUpdateInput(name string) *graphql.ApplicationTemplateUpdateInput { 271 desc := testDescription 272 273 return &graphql.ApplicationTemplateUpdateInput{ 274 Name: name, 275 Description: &desc, 276 ApplicationNamespace: str.Ptr("ns"), 277 ApplicationInput: &graphql.ApplicationJSONInput{ 278 Name: "foo", 279 Description: &desc, 280 }, 281 Placeholders: fixGQLPlaceholderDefinitionInput(), 282 Labels: map[string]interface{}{"label1": "test"}, 283 AccessLevel: graphql.ApplicationTemplateAccessLevelGlobal, 284 } 285 } 286 287 func fixGQLAppTemplateUpdateInputWithPlaceholder(name string) *graphql.ApplicationTemplateUpdateInput { 288 desc := testDescriptionWithPlaceholder 289 290 return &graphql.ApplicationTemplateUpdateInput{ 291 Name: name, 292 Description: &desc, 293 ApplicationNamespace: str.Ptr("ns"), 294 ApplicationInput: &graphql.ApplicationJSONInput{ 295 Name: "foo", 296 Description: &desc, 297 Labels: graphql.Labels{ 298 "displayName": "test", 299 }, 300 }, 301 Placeholders: fixGQLPlaceholderDefinitionInput(), 302 AccessLevel: graphql.ApplicationTemplateAccessLevelGlobal, 303 } 304 } 305 306 func fixGQLAppTemplateUpdateInputWithPlaceholderAndProvider(name string) *graphql.ApplicationTemplateUpdateInput { 307 desc := testDescriptionWithPlaceholder 308 309 return &graphql.ApplicationTemplateUpdateInput{ 310 Name: name, 311 Description: &desc, 312 ApplicationNamespace: str.Ptr("ns"), 313 ApplicationInput: &graphql.ApplicationJSONInput{ 314 Name: "foo", 315 Description: &desc, 316 ProviderName: str.Ptr("SAP"), 317 }, 318 Placeholders: fixGQLPlaceholderDefinitionInput(), 319 AccessLevel: graphql.ApplicationTemplateAccessLevelGlobal, 320 } 321 } 322 323 func fixGQLAppTemplateUpdateInputInvalidAppInput(name string) *graphql.ApplicationTemplateUpdateInput { 324 desc := testDescriptionWithPlaceholder 325 326 return &graphql.ApplicationTemplateUpdateInput{ 327 Name: name, 328 Description: &desc, 329 ApplicationNamespace: str.Ptr("ns"), 330 ApplicationInput: &graphql.ApplicationJSONInput{ 331 Name: "foo", 332 Description: &desc, 333 Webhooks: []*graphql.WebhookInput{ 334 { 335 Type: graphql.WebhookTypeUnregisterApplication, 336 URLTemplate: str.Ptr(`{"path": "https://target.url", "method":"invalid method"}`), 337 }, 338 }, 339 }, 340 Placeholders: fixGQLPlaceholderDefinitionInput(), 341 AccessLevel: graphql.ApplicationTemplateAccessLevelGlobal, 342 } 343 } 344 345 func fixEntityApplicationTemplate(t *testing.T, id, name string) *apptemplate.Entity { 346 marshalledAppInput := `{"name":"foo","providerName":"compass","description":"Lorem ipsum","labels":{"displayName":"bar","test":["val","val2"]},"healthCheckURL":"https://foo.bar","webhooks":[{"type":"","url":"webhook1.foo.bar","auth":null},{"type":"","url":"webhook2.foo.bar","auth":null}],"integrationSystemID":"iiiiiiiii-iiii-iiii-iiii-iiiiiiiiiiii"}` 347 348 placeholders := fixModelPlaceholders() 349 marshalledPlaceholders, err := json.Marshal(placeholders) 350 require.NoError(t, err) 351 352 return &apptemplate.Entity{ 353 ID: id, 354 Name: name, 355 Description: repo.NewValidNullableString(testDescription), 356 ApplicationNamespace: repo.NewValidNullableString("ns"), 357 ApplicationInputJSON: marshalledAppInput, 358 PlaceholdersJSON: repo.NewValidNullableString(string(marshalledPlaceholders)), 359 AccessLevel: string(model.GlobalApplicationTemplateAccessLevel), 360 } 361 } 362 363 func fixModelPlaceholders() []model.ApplicationTemplatePlaceholder { 364 placeholderDesc := testDescription 365 placeholderJSONPath := testJSONPath 366 isOptional := false 367 return []model.ApplicationTemplatePlaceholder{ 368 { 369 Name: "test", 370 Description: &placeholderDesc, 371 JSONPath: &placeholderJSONPath, 372 Optional: &isOptional, 373 }, 374 } 375 } 376 377 func fixModelPlaceholdersWithPayload() []model.ApplicationTemplatePlaceholder { 378 placeholderTestDesc := testDescription 379 placeholderTestJSONPath := testJSONPath 380 placeholderNameDesc := "Application Name placeholder" 381 placeholderNameJSONPath := "$.name" 382 return []model.ApplicationTemplatePlaceholder{ 383 { 384 Name: "test", 385 Description: &placeholderTestDesc, 386 JSONPath: &placeholderTestJSONPath, 387 }, 388 { 389 Name: "name", 390 Description: &placeholderNameDesc, 391 JSONPath: &placeholderNameJSONPath, 392 }, 393 } 394 } 395 396 func fixModelApplicationWebhooks(webhookID, applicationID string) []*model.Webhook { 397 return []*model.Webhook{ 398 { 399 ObjectID: applicationID, 400 ObjectType: model.ApplicationWebhookReference, 401 ID: webhookID, 402 Type: model.WebhookTypeConfigurationChanged, 403 URL: str.Ptr("foourl"), 404 Auth: &model.Auth{}, 405 }, 406 } 407 } 408 409 func fixModelApplicationTemplateWebhooks(webhookID, applicationTemplateID string) []*model.Webhook { 410 return []*model.Webhook{ 411 { 412 ObjectID: applicationTemplateID, 413 ObjectType: model.ApplicationTemplateWebhookReference, 414 ID: webhookID, 415 Type: model.WebhookTypeConfigurationChanged, 416 URL: str.Ptr("foourl"), 417 Auth: &model.Auth{}, 418 }, 419 } 420 } 421 422 func fixGQLPlaceholderDefinitionInput() []*graphql.PlaceholderDefinitionInput { 423 placeholderDesc := testDescription 424 placeholderJSONPath := testJSONPath 425 isOptional := false 426 return []*graphql.PlaceholderDefinitionInput{ 427 { 428 Name: "test", 429 Description: &placeholderDesc, 430 JSONPath: &placeholderJSONPath, 431 Optional: &isOptional, 432 }, 433 } 434 } 435 436 func fixGQLPlaceholders() []*graphql.PlaceholderDefinition { 437 placeholderDesc := testDescription 438 placeholderJSONPath := testJSONPath 439 isOptional := false 440 return []*graphql.PlaceholderDefinition{ 441 { 442 Name: "test", 443 Description: &placeholderDesc, 444 JSONPath: &placeholderJSONPath, 445 Optional: &isOptional, 446 }, 447 } 448 } 449 450 func fixGQLApplicationWebhooks(webhookID, applicationID string) []*graphql.Webhook { 451 return []*graphql.Webhook{ 452 { 453 ID: webhookID, 454 ApplicationID: str.Ptr(applicationID), 455 Type: graphql.WebhookTypeConfigurationChanged, 456 URL: str.Ptr("foourl"), 457 Auth: &graphql.Auth{}, 458 }, 459 } 460 } 461 462 func fixGQLApplicationTemplateWebhooks(webhookID, applicationTemplateID string) []*graphql.Webhook { 463 return []*graphql.Webhook{ 464 { 465 ID: webhookID, 466 ApplicationTemplateID: str.Ptr(applicationTemplateID), 467 Type: graphql.WebhookTypeConfigurationChanged, 468 URL: str.Ptr("foourl"), 469 Auth: &graphql.Auth{}, 470 }, 471 } 472 } 473 474 func fixGQLApplicationFromTemplateInput(name string) graphql.ApplicationFromTemplateInput { 475 return graphql.ApplicationFromTemplateInput{ 476 TemplateName: name, 477 Values: []*graphql.TemplateValueInput{ 478 {Placeholder: "a", Value: "b"}, 479 {Placeholder: "c", Value: "d"}, 480 }, 481 Labels: map[string]interface{}{ 482 "key": "value", 483 }, 484 } 485 } 486 487 func fixModelApplicationFromTemplateInput(name string) model.ApplicationFromTemplateInput { 488 return model.ApplicationFromTemplateInput{ 489 TemplateName: name, 490 Values: []*model.ApplicationTemplateValueInput{ 491 {Placeholder: "a", Value: "b"}, 492 {Placeholder: "c", Value: "d"}, 493 }, 494 Labels: map[string]interface{}{ 495 "key": "value", 496 }, 497 } 498 } 499 500 func fixGQLApplicationFromTemplateInputWithPlaceholderPayload(name string) graphql.ApplicationFromTemplateInput { 501 placeholdersPayload := `{"name": "appName", "test":"testValue"}` 502 return graphql.ApplicationFromTemplateInput{ 503 TemplateName: name, 504 PlaceholdersPayload: &placeholdersPayload, 505 } 506 } 507 508 func fixModelApplicationFromTemplateInputWithPlaceholderPayload(name string) model.ApplicationFromTemplateInput { 509 return model.ApplicationFromTemplateInput{ 510 TemplateName: name, 511 Values: []*model.ApplicationTemplateValueInput{ 512 {Placeholder: "test", Value: "testValue"}, 513 {Placeholder: "name", Value: "appName"}, 514 }, 515 } 516 } 517 518 func fixAppTemplateCreateArgs(entity apptemplate.Entity) []driver.Value { 519 return []driver.Value{entity.ID, entity.Name, entity.Description, entity.ApplicationNamespace, entity.ApplicationInputJSON, entity.PlaceholdersJSON, entity.AccessLevel} 520 } 521 522 func fixSQLRows(entities []apptemplate.Entity) *sqlmock.Rows { 523 out := sqlmock.NewRows(testTableColumns) 524 for _, entity := range entities { 525 out.AddRow(entity.ID, entity.Name, entity.Description, entity.ApplicationNamespace, entity.ApplicationInputJSON, entity.PlaceholdersJSON, entity.AccessLevel) 526 } 527 return out 528 } 529 530 func fixJSONApplicationCreateInput(name string) string { 531 return fmt.Sprintf(`{"name": "%s", "providerName": "%s", "description": "%s", "healthCheckURL": "%s"}`, name, testProviderName, testDescription, testURL) 532 } 533 534 func fixModelApplicationCreateInput(name string) model.ApplicationRegisterInput { 535 return model.ApplicationRegisterInput{ 536 Name: name, 537 Description: &testDescription, 538 HealthCheckURL: &testURL, 539 } 540 } 541 542 func fixModelApplicationWithLabelCreateInput(name string) model.ApplicationRegisterInput { 543 return model.ApplicationRegisterInput{ 544 Name: name, 545 Description: &testDescription, 546 HealthCheckURL: &testURL, 547 Labels: map[string]interface{}{"managed": "false", "key": "value"}, 548 } 549 } 550 551 func fixGQLApplicationCreateInput(name string) graphql.ApplicationRegisterInput { 552 return graphql.ApplicationRegisterInput{ 553 Name: name, 554 ProviderName: &testProviderName, 555 Description: &testDescription, 556 HealthCheckURL: &testURL, 557 } 558 } 559 560 func fixModelApplication(id, name string) model.Application { 561 return model.Application{ 562 Name: name, 563 Description: &testDescription, 564 HealthCheckURL: &testURL, 565 BaseEntity: &model.BaseEntity{ID: id}, 566 } 567 } 568 569 func fixGQLApplication(id, name string) graphql.Application { 570 return graphql.Application{ 571 BaseEntity: &graphql.BaseEntity{ 572 ID: id, 573 }, 574 Name: name, 575 Description: &testDescription, 576 HealthCheckURL: &testURL, 577 } 578 } 579 580 func modelPtrsToWebhooks(in []*model.Webhook) []model.Webhook { 581 if in == nil { 582 return nil 583 } 584 webhookPtrs := []model.Webhook{} 585 for i := range in { 586 webhookPtrs = append(webhookPtrs, *in[i]) 587 } 588 return webhookPtrs 589 } 590 591 func gqlPtrsToWebhooks(in []*graphql.Webhook) (webhookPtrs []graphql.Webhook) { 592 for i := range in { 593 webhookPtrs = append(webhookPtrs, *in[i]) 594 } 595 return 596 } 597 598 func fixColumns() []string { 599 return []string{"id", "name", "description", "application_namespace", "application_input", "placeholders", "access_level"} 600 } 601 602 func fixEnrichedTenantMappedWebhooks() []*graphql.WebhookInput { 603 syncMode := graphql.WebhookModeSync 604 605 return []*graphql.WebhookInput{ 606 { 607 Type: graphql.WebhookTypeConfigurationChanged, 608 Auth: nil, 609 Mode: &syncMode, 610 URLTemplate: &testURL, 611 InputTemplate: str.Ptr("input template"), 612 HeaderTemplate: str.Ptr("header template"), 613 OutputTemplate: str.Ptr("output template"), 614 }, 615 { 616 Type: graphql.WebhookTypeOpenResourceDiscovery, 617 URL: &testURL, 618 Auth: nil, 619 }, 620 } 621 } 622 623 func fixLabelInput(key string, value string, objectID string, objectType model.LabelableObject) *model.LabelInput { 624 return &model.LabelInput{ 625 Key: key, 626 Value: value, 627 ObjectID: objectID, 628 ObjectType: objectType, 629 } 630 }