From fd625b8d70ca4de015bd6fd6d1e86ed654455b96 Mon Sep 17 00:00:00 2001 From: Cowan Macady Date: Fri, 4 Oct 2024 16:18:12 +0200 Subject: [PATCH] commit --- config/config_integration_test.go | 1681 +++++++++++++++++ .../cmd/external_data_resolver_config.go | 2 +- test/constants.go | 12 + 3 files changed, 1694 insertions(+), 1 deletion(-) create mode 100644 config/config_integration_test.go diff --git a/config/config_integration_test.go b/config/config_integration_test.go new file mode 100644 index 00000000..575be3bd --- /dev/null +++ b/config/config_integration_test.go @@ -0,0 +1,1681 @@ +// Copyright (c) 2024 IndyKite +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//go:build integration + +package config_test + +import ( + "context" + "log" + "time" + + "github.com/grpc-ecosystem/go-grpc-middleware/v2/interceptors/retry" + + "github.com/indykite/indykite-sdk-go/config" + configpb "github.com/indykite/indykite-sdk-go/gen/indykite/config/v1beta1" + "github.com/indykite/indykite-sdk-go/test" + integration "github.com/indykite/indykite-sdk-go/test" + + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + . "github.com/onsi/gomega/gstruct" +) + +var _ = Describe("Configuration", func() { + Describe("ExternalDataResolver", func() { + It("CreateExternalDataResolver", func() { + var err error + configClient, err := integration.InitConfigConfig() + Expect(err).To(Succeed()) + + createAppSpaceReq := &configpb.CreateApplicationSpaceRequest{ + CustomerId: "gid:like-real-customer-id", + Name: "like-real-appspace-name", + DisplayName: displayNamePb, + Region: "europe-west1", + } + respAppSpace, err := configClient.CreateApplicationSpace(ctx, req) + Expect(err).To(Succeed()) + Expect(resp).To(test.EqualProto(beResp)) + + configuration := &configpb.ExternalDataResolverConfig{ + Url: integration.Url, + Method: integration.Method1, + Headers: integration.Headers, + RequestType: integration.RequestType, + RequestPayload: integration.RequestPayload, + ResponseType: integration.ResponseType, + ResponseSelector: integration.ResponseSelector, + } + createReq, _ := config.NewCreate("like-real-config-node-name2") + createReq.ForLocation("gid:AAAAAvFyVpD_1kd8k2kpNY9rjFM") + createReq.WithDisplayName("Like real ConfigNode Name2") + createReq.WithExternalDataResolverConfig(configuration) + + resp, err := client.CreateConfigNode(context.Background(), createReq) + if err != nil { + log.Fatalf("failed to invoke operation on IndyKite Client %v", err) + } + + Expect(err).To(Succeed()) + Expect(resp).To(PointTo(MatchFields(IgnoreExtras, Fields{ + "RecordId": Not(BeNil()), + "Info": PointTo(MatchFields(IgnoreExtras, Fields{ + "Changes": ContainElement(PointTo(MatchFields(IgnoreExtras, Fields{ + "Id": Not(BeEmpty()), + "DataType": Equal(ingestpb.DataType_DATA_TYPE_NODE), + }))), + })), + }))) + id := resp.Info.Changes[0].Id + + delRecord := integration.DeleteRecord(externalID, "Individual") + del, err := ingestClient.IngestRecord( + context.Background(), + delRecord, + retry.WithMax(5), + ) + Expect(err).To(Succeed()) + Expect(del).To(PointTo(MatchFields(IgnoreExtras, Fields{ + "RecordId": Not(BeNil()), + "Info": PointTo(MatchFields(IgnoreExtras, Fields{ + "Changes": ContainElement(PointTo(MatchFields(IgnoreExtras, Fields{ + "Id": Equal(id), + "DataType": Equal(ingestpb.DataType_DATA_TYPE_NODE), + }))), + })), + }))) + }) + + It("UpsertNodeNoProperties", func() { + var err error + ingestClient, err := integration.InitConfigIngest() + Expect(err).To(Succeed()) + + externalID := integration.GenerateRandomString(10) + record := integration.CreateRecordNoProperty(externalID, "Individual") + resp, err := ingestClient.IngestRecord( + context.Background(), + record, + retry.WithMax(5), + ) + + Expect(err).To(Succeed()) + Expect(resp).To(PointTo(MatchFields(IgnoreExtras, Fields{ + "RecordId": Not(BeNil()), + "Info": PointTo(MatchFields(IgnoreExtras, Fields{ + "Changes": ContainElement(PointTo(MatchFields(IgnoreExtras, Fields{ + "Id": Not(BeEmpty()), + "DataType": Equal(ingestpb.DataType_DATA_TYPE_NODE), + }))), + })), + }))) + + id := resp.Info.Changes[0].Id + + delRecord := integration.DeleteRecord(externalID, "Individual") + del, err := ingestClient.IngestRecord( + context.Background(), + delRecord, + retry.WithMax(5), + ) + Expect(err).To(Succeed()) + Expect(del).To(PointTo(MatchFields(IgnoreExtras, Fields{ + "RecordId": Not(BeNil()), + "Info": PointTo(MatchFields(IgnoreExtras, Fields{ + "Changes": ContainElement(PointTo(MatchFields(IgnoreExtras, Fields{ + "Id": Equal(id), + "DataType": Equal(ingestpb.DataType_DATA_TYPE_NODE), + }))), + })), + }))) + }) + + It("UpsertNodeDuplicateSameType", func() { + var err error + ingestClient, err := integration.InitConfigIngest() + Expect(err).To(Succeed()) + + externalID := integration.GenerateRandomString(10) + record := integration.CreateRecordNoProperty(externalID, "Individual") + resp, err := ingestClient.IngestRecord( + context.Background(), + record, + retry.WithMax(5), + ) + + Expect(err).To(Succeed()) + Expect(resp).NotTo(BeNil()) + id := resp.Info.Changes[0].Id + + recordb := integration.CreateRecordNoProperty(externalID, "Individual") + resp2, err := ingestClient.IngestRecord( + context.Background(), + recordb, + retry.WithMax(5), + ) + Expect(err).To(Succeed()) + Expect(resp2).NotTo(BeNil()) + id2 := resp2.Info.Changes[0].Id + Expect(id2).To(Equal(id)) + + delRecord := integration.DeleteRecord(externalID, "Individual") + del, err := ingestClient.IngestRecord( + context.Background(), + delRecord, + retry.WithMax(5), + ) + Expect(err).To(Succeed()) + Expect(del).To(PointTo(MatchFields(IgnoreExtras, Fields{ + "RecordId": Not(BeNil()), + "Info": PointTo(MatchFields(IgnoreExtras, Fields{ + "Changes": ContainElement(PointTo(MatchFields(IgnoreExtras, Fields{ + "Id": Equal(id), + "DataType": Equal(ingestpb.DataType_DATA_TYPE_NODE), + }))), + })), + }))) + }) + + It("UpsertNodeDuplicateDifferentTypes", func() { + var err error + ingestClient, err := integration.InitConfigIngest() + Expect(err).To(Succeed()) + + externalID := integration.GenerateRandomString(10) + record := integration.CreateRecordNoProperty(externalID, "Individual") + resp, err := ingestClient.IngestRecord( + context.Background(), + record, + retry.WithMax(5), + ) + + Expect(err).To(Succeed()) + Expect(resp).NotTo(BeNil()) + id := resp.Info.Changes[0].Id + + recordb := integration.CreateRecordNoProperty(externalID, "Cat") + resp2, err := ingestClient.IngestRecord( + context.Background(), + recordb, + retry.WithMax(5), + ) + Expect(err).To(Succeed()) + Expect(resp2).NotTo(BeNil()) + id2 := resp2.Info.Changes[0].Id + Expect(id2).NotTo(Equal(id)) + + delRecord := integration.DeleteRecord(externalID, "Individual") + del, err := ingestClient.IngestRecord( + context.Background(), + delRecord, + retry.WithMax(5), + ) + Expect(err).To(Succeed()) + Expect(del).To(PointTo(MatchFields(IgnoreExtras, Fields{ + "RecordId": Not(BeNil()), + "Info": PointTo(MatchFields(IgnoreExtras, Fields{ + "Changes": ContainElement(PointTo(MatchFields(IgnoreExtras, Fields{ + "Id": Equal(id), + "DataType": Equal(ingestpb.DataType_DATA_TYPE_NODE), + }))), + })), + }))) + + delRecord2 := integration.DeleteRecord(externalID, "Cat") + del2, err := ingestClient.IngestRecord( + context.Background(), + delRecord2, + retry.WithMax(5), + ) + Expect(err).To(Succeed()) + Expect(del2).To(PointTo(MatchFields(IgnoreExtras, Fields{ + "RecordId": Not(BeNil()), + "Info": PointTo(MatchFields(IgnoreExtras, Fields{ + "Changes": ContainElement(PointTo(MatchFields(IgnoreExtras, Fields{ + "Id": Equal(id2), + "DataType": Equal(ingestpb.DataType_DATA_TYPE_NODE), + }))), + })), + }))) + }) + + It("UpsertNodeResource", func() { + var err error + ingestClient, err := integration.InitConfigIngest() + Expect(err).To(Succeed()) + + record, externalID := integration.UpsertRecordNodeAsset() + resp, err := ingestClient.IngestRecord( + context.Background(), + record, + retry.WithMax(5), + ) + + Expect(err).To(Succeed()) + Expect(resp).To(PointTo(MatchFields(IgnoreExtras, Fields{ + "RecordId": Not(BeNil()), + "Info": PointTo(MatchFields(IgnoreExtras, Fields{ + "Changes": ContainElement(PointTo(MatchFields(IgnoreExtras, Fields{ + "Id": Not(BeEmpty()), + "DataType": Equal(ingestpb.DataType_DATA_TYPE_NODE), + }))), + })), + }))) + + id := resp.Info.Changes[0].Id + delRecord := integration.DeleteRecord(externalID, "Asset") + del, err := ingestClient.IngestRecord( + context.Background(), + delRecord, + retry.WithMax(5), + ) + Expect(err).To(Succeed()) + Expect(del).To(PointTo(MatchFields(IgnoreExtras, Fields{ + "RecordId": Not(BeNil()), + "Info": PointTo(MatchFields(IgnoreExtras, Fields{ + "Changes": ContainElement(PointTo(MatchFields(IgnoreExtras, Fields{ + "Id": Equal(id), + "DataType": Equal(ingestpb.DataType_DATA_TYPE_NODE), + }))), + })), + }))) + }) + + It("UpsertNodeResourceNoProp", func() { + var err error + ingestClient, err := integration.InitConfigIngest() + Expect(err).To(Succeed()) + + externalID := integration.GenerateRandomString(10) + record := integration.CreateRecordResourceNoProperty(externalID, "Asset") + resp, err := ingestClient.IngestRecord( + context.Background(), + record, + retry.WithMax(5), + ) + + Expect(err).To(Succeed()) + Expect(resp).To(PointTo(MatchFields(IgnoreExtras, Fields{ + "RecordId": Not(BeNil()), + "Info": PointTo(MatchFields(IgnoreExtras, Fields{ + "Changes": ContainElement(PointTo(MatchFields(IgnoreExtras, Fields{ + "Id": Not(BeEmpty()), + "DataType": Equal(ingestpb.DataType_DATA_TYPE_NODE), + }))), + })), + }))) + + id := resp.Info.Changes[0].Id + delRecord := integration.DeleteRecord(externalID, "Asset") + del, err := ingestClient.IngestRecord( + context.Background(), + delRecord, + retry.WithMax(5), + ) + Expect(err).To(Succeed()) + Expect(del).To(PointTo(MatchFields(IgnoreExtras, Fields{ + "RecordId": Not(BeNil()), + "Info": PointTo(MatchFields(IgnoreExtras, Fields{ + "Changes": ContainElement(PointTo(MatchFields(IgnoreExtras, Fields{ + "Id": Equal(id), + "DataType": Equal(ingestpb.DataType_DATA_TYPE_NODE), + }))), + })), + }))) + }) + + It("UpsertNodeDuplicateResourceSameType", func() { + var err error + ingestClient, err := integration.InitConfigIngest() + Expect(err).To(Succeed()) + + externalID := integration.GenerateRandomString(10) + record := integration.CreateRecordResourceNoProperty(externalID, "Asset") + resp, err := ingestClient.IngestRecord( + context.Background(), + record, + retry.WithMax(5), + ) + + Expect(err).To(Succeed()) + Expect(resp).NotTo(BeNil()) + id := resp.Info.Changes[0].Id + + recordb := integration.CreateRecordResourceNoProperty(externalID, "Asset") + resp2, err := ingestClient.IngestRecord( + context.Background(), + recordb, + retry.WithMax(5), + ) + Expect(err).To(Succeed()) + Expect(resp2).NotTo(BeNil()) + id2 := resp2.Info.Changes[0].Id + Expect(id2).To(Equal(id)) + + Expect(resp).To(PointTo(MatchFields(IgnoreExtras, Fields{ + "RecordId": Not(BeNil()), + "Info": PointTo(MatchFields(IgnoreExtras, Fields{ + "Changes": ContainElement(PointTo(MatchFields(IgnoreExtras, Fields{ + "Id": Not(BeEmpty()), + "DataType": Equal(ingestpb.DataType_DATA_TYPE_NODE), + }))), + })), + }))) + + delRecord := integration.DeleteRecord(externalID, "Asset") + del, err := ingestClient.IngestRecord( + context.Background(), + delRecord, + retry.WithMax(5), + ) + Expect(err).To(Succeed()) + Expect(del).To(PointTo(MatchFields(IgnoreExtras, Fields{ + "RecordId": Not(BeNil()), + "Info": PointTo(MatchFields(IgnoreExtras, Fields{ + "Changes": ContainElement(PointTo(MatchFields(IgnoreExtras, Fields{ + "Id": Equal(id), + "DataType": Equal(ingestpb.DataType_DATA_TYPE_NODE), + }))), + })), + }))) + }) + + It("UpsertNodeDuplicateResourceDifferentTypes", func() { + var err error + ingestClient, err := integration.InitConfigIngest() + Expect(err).To(Succeed()) + + externalID := integration.GenerateRandomString(10) + record := integration.CreateRecordResourceNoProperty(externalID, "Asset") + resp, err := ingestClient.IngestRecord( + context.Background(), + record, + retry.WithMax(5), + ) + + Expect(err).To(Succeed()) + Expect(resp).NotTo(BeNil()) + id := resp.Info.Changes[0].Id + + recordb := integration.CreateRecordResourceNoProperty(externalID, "Cat") + resp2, err := ingestClient.IngestRecord( + context.Background(), + recordb, + retry.WithMax(5), + ) + + Expect(err).To(Succeed()) + Expect(resp2).NotTo(BeNil()) + id2 := resp2.Info.Changes[0].Id + Expect(id2).NotTo(Equal(id)) + + delRecord := integration.DeleteRecord(externalID, "Cat") + del, err := ingestClient.IngestRecord( + context.Background(), + delRecord, + retry.WithMax(5), + ) + Expect(err).To(Succeed()) + Expect(del).To(PointTo(MatchFields(IgnoreExtras, Fields{ + "RecordId": Not(BeNil()), + "Info": PointTo(MatchFields(IgnoreExtras, Fields{ + "Changes": ContainElement(PointTo(MatchFields(IgnoreExtras, Fields{ + "Id": Equal(id2), + "DataType": Equal(ingestpb.DataType_DATA_TYPE_NODE), + }))), + })), + }))) + }) + + It("UpsertNodeDuplicateDifferentNodes", func() { + var err error + ingestClient, err := integration.InitConfigIngest() + Expect(err).To(Succeed()) + + externalID := integration.GenerateRandomString(10) + record := integration.CreateRecordNoProperty(externalID, "Individual") + resp, err := ingestClient.IngestRecord( + context.Background(), + record, + retry.WithMax(5), + ) + + Expect(err).To(Succeed()) + Expect(resp).NotTo(BeNil()) + id := resp.Info.Changes[0].Id + + recordb := integration.CreateRecordResourceNoProperty(externalID, "Asset") + resp2, err := ingestClient.IngestRecord( + context.Background(), + recordb, + retry.WithMax(5), + ) + Expect(err).To(Succeed()) + Expect(resp2).NotTo(BeNil()) + id2 := resp2.Info.Changes[0].Id + Expect(id2).NotTo(Equal(id)) + + delRecord := integration.DeleteRecord(externalID, "Individual") + del, err := ingestClient.IngestRecord( + context.Background(), + delRecord, + retry.WithMax(5), + ) + Expect(err).To(Succeed()) + Expect(del).To(PointTo(MatchFields(IgnoreExtras, Fields{ + "RecordId": Not(BeNil()), + "Info": PointTo(MatchFields(IgnoreExtras, Fields{ + "Changes": ContainElement(PointTo(MatchFields(IgnoreExtras, Fields{ + "Id": Equal(id), + "DataType": Equal(ingestpb.DataType_DATA_TYPE_NODE), + }))), + })), + }))) + + delRecordb := integration.DeleteRecord(externalID, "Asset") + del2, err := ingestClient.IngestRecord( + context.Background(), + delRecordb, + retry.WithMax(5), + ) + Expect(err).To(Succeed()) + Expect(del2).To(PointTo(MatchFields(IgnoreExtras, Fields{ + "RecordId": Not(BeNil()), + "Info": PointTo(MatchFields(IgnoreExtras, Fields{ + "Changes": ContainElement(PointTo(MatchFields(IgnoreExtras, Fields{ + "Id": Equal(id2), + "DataType": Equal(ingestpb.DataType_DATA_TYPE_NODE), + }))), + })), + }))) + }) + + It("UpsertNodeDuplicateTypeNamedResource", func() { + var err error + ingestClient, err := integration.InitConfigIngest() + Expect(err).To(Succeed()) + + externalID := integration.GenerateRandomString(10) + record := integration.CreateRecordResourceNoProperty(externalID, "Resource") + resp, err := ingestClient.IngestRecord( + context.Background(), + record, + retry.WithMax(5), + ) + + Expect(externalID).NotTo(BeNil()) + Expect(err).To(MatchError(ContainSubstring("the type 'Resource' is reserved"))) + Expect(resp).To(BeNil()) + }) + + It("DeleteNodeResourceNotExist", func() { + var err error + ingestClient, err := integration.InitConfigIngest() + Expect(err).To(Succeed()) + + externalID := integration.GenerateRandomString(10) + delRecord := integration.DeleteRecord(externalID, "Asset") + del, err := ingestClient.IngestRecord( + context.Background(), + delRecord, + retry.WithMax(5), + ) + Expect(err).To(Succeed()) + Expect(del).To(PointTo(MatchFields(IgnoreExtras, Fields{ + "RecordId": Not(BeNil()), + "Info": PointTo(MatchFields(IgnoreExtras, Fields{ + "Changes": ContainElement(PointTo(MatchFields(IgnoreExtras, Fields{ + "Id": BeEmpty(), + "DataType": Equal(ingestpb.DataType_DATA_TYPE_NODE), + }))), + })), + }))) + }) + + It("UpsertNodeDelProperty", func() { + var err error + ingestClient, err := integration.InitConfigIngest() + Expect(err).To(Succeed()) + + record, externalID := integration.CreateRecordNodeIndividual("Employee") + resp, err := ingestClient.IngestRecord( + context.Background(), + record, + retry.WithMax(5), + ) + + Expect(err).To(Succeed()) + Expect(resp).To(PointTo(MatchFields(IgnoreExtras, Fields{ + "RecordId": Not(BeNil()), + "Info": PointTo(MatchFields(IgnoreExtras, Fields{ + "Changes": ContainElement(PointTo(MatchFields(IgnoreExtras, Fields{ + "Id": Not(BeEmpty()), + "DataType": Equal(ingestpb.DataType_DATA_TYPE_NODE), + }))), + })), + }))) + + id := resp.Info.Changes[0].Id + delRecord3 := integration.DeleteRecordWithProperty(externalID, "Individual", "first_name") + del3, err := ingestClient.IngestRecord( + context.Background(), + delRecord3, + retry.WithMax(5), + ) + Expect(err).To(Succeed()) + Expect(del3).To(PointTo(MatchFields(IgnoreExtras, Fields{ + "RecordId": Not(BeNil()), + "Info": PointTo(MatchFields(IgnoreExtras, Fields{ + "Changes": ContainElement(PointTo(MatchFields(IgnoreExtras, Fields{ + "Id": Equal(id), + "DataType": Equal(ingestpb.DataType_DATA_TYPE_NODE), + }))), + })), + }))) + + delRecord := integration.DeleteRecord(externalID, "Individual") + del, err := ingestClient.IngestRecord( + context.Background(), + delRecord, + retry.WithMax(5), + ) + Expect(err).To(Succeed()) + Expect(del).To(PointTo(MatchFields(IgnoreExtras, Fields{ + "RecordId": Not(BeNil()), + "Info": PointTo(MatchFields(IgnoreExtras, Fields{ + "Changes": ContainElement(PointTo(MatchFields(IgnoreExtras, Fields{ + "Id": Equal(id), + "DataType": Equal(ingestpb.DataType_DATA_TYPE_NODE), + }))), + })), + }))) + }) + + It("UpsertNodeResourceDelProperty", func() { + var err error + ingestClient, err := integration.InitConfigIngest() + Expect(err).To(Succeed()) + + record, externalID := integration.UpsertRecordNodeAsset() + resp, err := ingestClient.IngestRecord( + context.Background(), + record, + retry.WithMax(5), + ) + + Expect(err).To(Succeed()) + Expect(resp).To(PointTo(MatchFields(IgnoreExtras, Fields{ + "RecordId": Not(BeNil()), + "Info": PointTo(MatchFields(IgnoreExtras, Fields{ + "Changes": ContainElement(PointTo(MatchFields(IgnoreExtras, Fields{ + "Id": Not(BeEmpty()), + "DataType": Equal(ingestpb.DataType_DATA_TYPE_NODE), + }))), + })), + }))) + + delRecord3 := integration.DeleteRecordWithProperty(externalID, "Asset", "colour") + del3, err := ingestClient.IngestRecord( + context.Background(), + delRecord3, + retry.WithMax(5), + ) + Expect(err).To(Succeed()) + Expect(del3).To(PointTo(MatchFields(IgnoreExtras, Fields{ + "RecordId": Not(BeNil()), + "Info": PointTo(MatchFields(IgnoreExtras, Fields{ + "Changes": ContainElement(PointTo(MatchFields(IgnoreExtras, Fields{ + "Id": Not(BeEmpty()), + "DataType": Equal(ingestpb.DataType_DATA_TYPE_NODE), + }))), + })), + }))) + + id := resp.Info.Changes[0].Id + delRecord := integration.DeleteRecord(externalID, "Asset") + del, err := ingestClient.IngestRecord( + context.Background(), + delRecord, + retry.WithMax(5), + ) + Expect(err).To(Succeed()) + Expect(del).To(PointTo(MatchFields(IgnoreExtras, Fields{ + "RecordId": Not(BeNil()), + "Info": PointTo(MatchFields(IgnoreExtras, Fields{ + "Changes": ContainElement(PointTo(MatchFields(IgnoreExtras, Fields{ + "Id": Equal(id), + "DataType": Equal(ingestpb.DataType_DATA_TYPE_NODE), + }))), + })), + }))) + }) + + It("ResourceDelNotExistingProperty", func() { + var err error + ingestClient, err := integration.InitConfigIngest() + Expect(err).To(Succeed()) + + externalID := integration.GenerateRandomString(10) + delRecord3 := integration.DeleteRecordWithProperty(externalID, "Asset", "colour") + del3, err := ingestClient.IngestRecord( + context.Background(), + delRecord3, + retry.WithMax(5), + ) + Expect(err).To(Succeed()) + Expect(del3).To(PointTo(MatchFields(IgnoreExtras, Fields{ + "RecordId": Not(BeNil()), + "Info": PointTo(MatchFields(IgnoreExtras, Fields{ + "Changes": ContainElement(PointTo(MatchFields(IgnoreExtras, Fields{ + "Id": BeEmpty(), + "DataType": Equal(ingestpb.DataType_DATA_TYPE_NODE), + }))), + })), + }))) + }) + }) + + Describe("IngestRelationship", func() { + It("UpsertRelationship", func() { + var err error + ingestClient, err := integration.InitConfigIngest() + Expect(err).To(Succeed()) + + record, externalID := integration.CreateRecordNodeIndividual("Employee") + resp, err := ingestClient.IngestRecord( + context.Background(), + record, + retry.WithMax(5), + ) + + Expect(err).To(Succeed()) + Expect(resp).To(PointTo(MatchFields(IgnoreExtras, Fields{ + "RecordId": Not(BeNil()), + "Info": PointTo(MatchFields(IgnoreExtras, Fields{ + "Changes": ContainElement(PointTo(MatchFields(IgnoreExtras, Fields{ + "Id": Not(BeEmpty()), + "DataType": Equal(ingestpb.DataType_DATA_TYPE_NODE), + }))), + })), + }))) + + id := resp.Info.Changes[0].Id + externalID2 := integration.GenerateRandomString(10) + recordb := integration.CreateRecordResourceNoProperty(externalID2, "Asset") + resp2, err := ingestClient.IngestRecord( + context.Background(), + recordb, + retry.WithMax(5), + ) + + Expect(err).To(Succeed()) + Expect(resp2).To(PointTo(MatchFields(IgnoreExtras, Fields{ + "RecordId": Not(BeNil()), + "Info": PointTo(MatchFields(IgnoreExtras, Fields{ + "Changes": ContainElement(PointTo(MatchFields(IgnoreExtras, Fields{ + "Id": Not(BeEmpty()), + "DataType": Equal(ingestpb.DataType_DATA_TYPE_NODE), + }))), + })), + }))) + id2 := resp2.Info.Changes[0].Id + + record3 := integration.CreateRecordRelationship(externalID, "Individual", externalID2, "Asset", "CAN_SEE") + resp3, err := ingestClient.IngestRecord( + context.Background(), + record3, + retry.WithMax(5), + ) + + Expect(err).To(Succeed()) + Expect(resp3).To(PointTo(MatchFields(IgnoreExtras, Fields{ + "RecordId": Not(BeNil()), + "Info": PointTo(MatchFields(IgnoreExtras, Fields{ + "Changes": ContainElement(PointTo(MatchFields(IgnoreExtras, Fields{ + "Id": Not(BeEmpty()), + "DataType": Equal(ingestpb.DataType_DATA_TYPE_RELATIONSHIP), + }))), + })), + }))) + id3 := resp3.Info.Changes[0].Id + + match := integration.GetRelationship(externalID, "Individual", externalID2, "Asset", "CAN_SEE") + delRecord3 := integration.DeleteRecordRelationship(match) + del3, err := ingestClient.IngestRecord( + context.Background(), + delRecord3, + retry.WithMax(5), + ) + Expect(err).To(Succeed()) + Expect(del3).To(PointTo(MatchFields(IgnoreExtras, Fields{ + "RecordId": Not(BeNil()), + "Info": PointTo(MatchFields(IgnoreExtras, Fields{ + "Changes": ContainElement(PointTo(MatchFields(IgnoreExtras, Fields{ + "Id": Equal(id3), + "DataType": Equal(ingestpb.DataType_DATA_TYPE_RELATIONSHIP), + }))), + })), + }))) + + delRecord := integration.DeleteRecord(externalID, "Individual") + del, err := ingestClient.IngestRecord( + context.Background(), + delRecord, + retry.WithMax(5), + ) + Expect(err).To(Succeed()) + Expect(del).To(PointTo(MatchFields(IgnoreExtras, Fields{ + "RecordId": Not(BeNil()), + "Info": PointTo(MatchFields(IgnoreExtras, Fields{ + "Changes": ContainElement(PointTo(MatchFields(IgnoreExtras, Fields{ + "Id": Equal(id), + "DataType": Equal(ingestpb.DataType_DATA_TYPE_NODE), + }))), + })), + }))) + + delRecordb := integration.DeleteRecord(externalID2, "Asset") + del2, err := ingestClient.IngestRecord( + context.Background(), + delRecordb, + retry.WithMax(5), + ) + Expect(err).To(Succeed()) + Expect(del2).To(PointTo(MatchFields(IgnoreExtras, Fields{ + "RecordId": Not(BeNil()), + "Info": PointTo(MatchFields(IgnoreExtras, Fields{ + "Changes": ContainElement(PointTo(MatchFields(IgnoreExtras, Fields{ + "Id": Equal(id2), + "DataType": Equal(ingestpb.DataType_DATA_TYPE_NODE), + }))), + })), + }))) + }) + + It("UpsertRelationshipDeleteWrongSource", func() { + var err error + ingestClient, err := integration.InitConfigIngest() + Expect(err).To(Succeed()) + + record, externalID := integration.CreateRecordNodeIndividual("Employee") + resp, err := ingestClient.IngestRecord( + context.Background(), + record, + retry.WithMax(5), + ) + + Expect(err).To(Succeed()) + Expect(resp).To(PointTo(MatchFields(IgnoreExtras, Fields{ + "RecordId": Not(BeNil()), + "Info": PointTo(MatchFields(IgnoreExtras, Fields{ + "Changes": ContainElement(PointTo(MatchFields(IgnoreExtras, Fields{ + "Id": Not(BeEmpty()), + "DataType": Equal(ingestpb.DataType_DATA_TYPE_NODE), + }))), + })), + }))) + id := resp.Info.Changes[0].Id + + externalID2 := integration.GenerateRandomString(10) + recordb := integration.CreateRecordResourceNoProperty(externalID2, "Asset") + resp2, err := ingestClient.IngestRecord( + context.Background(), + recordb, + retry.WithMax(5), + ) + + Expect(err).To(Succeed()) + Expect(resp2).To(PointTo(MatchFields(IgnoreExtras, Fields{ + "RecordId": Not(BeNil()), + "Info": PointTo(MatchFields(IgnoreExtras, Fields{ + "Changes": ContainElement(PointTo(MatchFields(IgnoreExtras, Fields{ + "Id": Not(BeEmpty()), + "DataType": Equal(ingestpb.DataType_DATA_TYPE_NODE), + }))), + })), + }))) + id2 := resp2.Info.Changes[0].Id + + record3 := integration.CreateRecordRelationship(externalID, "Individual", externalID2, "Asset", "CAN_SEE") + resp3, err := ingestClient.IngestRecord( + context.Background(), + record3, + retry.WithMax(5), + ) + + Expect(err).To(Succeed()) + Expect(resp3).To(PointTo(MatchFields(IgnoreExtras, Fields{ + "RecordId": Not(BeNil()), + "Info": PointTo(MatchFields(IgnoreExtras, Fields{ + "Changes": ContainElement(PointTo(MatchFields(IgnoreExtras, Fields{ + "Id": Not(BeEmpty()), + "DataType": Equal(ingestpb.DataType_DATA_TYPE_RELATIONSHIP), + }))), + })), + }))) + + match := integration.GetRelationship("whatever", "Individual", externalID2, "Asset", "CAN_SEE") + delRecord3 := integration.DeleteRecordRelationship(match) + del3, err := ingestClient.IngestRecord( + context.Background(), + delRecord3, + retry.WithMax(5), + ) + Expect(err).To(Succeed()) + Expect(del3).To(PointTo(MatchFields(IgnoreExtras, Fields{ + "RecordId": Not(BeNil()), + "Info": PointTo(MatchFields(IgnoreExtras, Fields{ + "Changes": ContainElement(PointTo(MatchFields(IgnoreExtras, Fields{ + "DataType": Equal(ingestpb.DataType_DATA_TYPE_RELATIONSHIP), + }))), + })), + }))) + + delRecord := integration.DeleteRecord(externalID, "Individual") + del, err := ingestClient.IngestRecord( + context.Background(), + delRecord, + retry.WithMax(5), + ) + Expect(err).To(Succeed()) + Expect(del).To(PointTo(MatchFields(IgnoreExtras, Fields{ + "RecordId": Not(BeNil()), + "Info": PointTo(MatchFields(IgnoreExtras, Fields{ + "Changes": ContainElement(PointTo(MatchFields(IgnoreExtras, Fields{ + "Id": Equal(id), + "DataType": Equal(ingestpb.DataType_DATA_TYPE_NODE), + }))), + })), + }))) + + delRecordb := integration.DeleteRecord(externalID2, "Asset") + del2, err := ingestClient.IngestRecord( + context.Background(), + delRecordb, + retry.WithMax(5), + ) + Expect(err).To(Succeed()) + Expect(del2).To(PointTo(MatchFields(IgnoreExtras, Fields{ + "RecordId": Not(BeNil()), + "Info": PointTo(MatchFields(IgnoreExtras, Fields{ + "Changes": ContainElement(PointTo(MatchFields(IgnoreExtras, Fields{ + "Id": Equal(id2), + "DataType": Equal(ingestpb.DataType_DATA_TYPE_NODE), + }))), + })), + }))) + }) + + It("UpsertRelationshipDeleteWrongSourceType", func() { + var err error + ingestClient, err := integration.InitConfigIngest() + Expect(err).To(Succeed()) + + record, externalID := integration.CreateRecordNodeIndividual("Employee") + resp, err := ingestClient.IngestRecord( + context.Background(), + record, + retry.WithMax(5), + ) + + Expect(err).To(Succeed()) + Expect(resp).To(PointTo(MatchFields(IgnoreExtras, Fields{ + "RecordId": Not(BeNil()), + "Info": PointTo(MatchFields(IgnoreExtras, Fields{ + "Changes": ContainElement(PointTo(MatchFields(IgnoreExtras, Fields{ + "Id": Not(BeEmpty()), + "DataType": Equal(ingestpb.DataType_DATA_TYPE_NODE), + }))), + })), + }))) + id := resp.Info.Changes[0].Id + + externalID2 := integration.GenerateRandomString(10) + recordb := integration.CreateRecordResourceNoProperty(externalID2, "Asset") + resp2, err := ingestClient.IngestRecord( + context.Background(), + recordb, + retry.WithMax(5), + ) + + Expect(err).To(Succeed()) + Expect(resp2).To(PointTo(MatchFields(IgnoreExtras, Fields{ + "RecordId": Not(BeNil()), + "Info": PointTo(MatchFields(IgnoreExtras, Fields{ + "Changes": ContainElement(PointTo(MatchFields(IgnoreExtras, Fields{ + "Id": Not(BeEmpty()), + "DataType": Equal(ingestpb.DataType_DATA_TYPE_NODE), + }))), + })), + }))) + id2 := resp2.Info.Changes[0].Id + + record3 := integration.CreateRecordRelationship(externalID, "Individual", externalID2, "Asset", "CAN_SEE") + resp3, err := ingestClient.IngestRecord( + context.Background(), + record3, + retry.WithMax(5), + ) + + Expect(err).To(Succeed()) + Expect(resp3).To(PointTo(MatchFields(IgnoreExtras, Fields{ + "RecordId": Not(BeNil()), + "Info": PointTo(MatchFields(IgnoreExtras, Fields{ + "Changes": ContainElement(PointTo(MatchFields(IgnoreExtras, Fields{ + "Id": Not(BeEmpty()), + "DataType": Equal(ingestpb.DataType_DATA_TYPE_RELATIONSHIP), + }))), + })), + }))) + + match := integration.GetRelationship(externalID2, "Whatever", externalID2, "Asset", "CAN_SEE") + delRecord3 := integration.DeleteRecordRelationship(match) + del3, err := ingestClient.IngestRecord( + context.Background(), + delRecord3, + retry.WithMax(5), + ) + Expect(err).To(Succeed()) + Expect(del3).To(PointTo(MatchFields(IgnoreExtras, Fields{ + "RecordId": Not(BeNil()), + "Info": PointTo(MatchFields(IgnoreExtras, Fields{ + "Changes": ContainElement(PointTo(MatchFields(IgnoreExtras, Fields{ + "DataType": Equal(ingestpb.DataType_DATA_TYPE_RELATIONSHIP), + }))), + })), + }))) + + delRecord := integration.DeleteRecord(externalID, "Individual") + del, err := ingestClient.IngestRecord( + context.Background(), + delRecord, + retry.WithMax(5), + ) + Expect(err).To(Succeed()) + Expect(del).To(PointTo(MatchFields(IgnoreExtras, Fields{ + "RecordId": Not(BeNil()), + "Info": PointTo(MatchFields(IgnoreExtras, Fields{ + "Changes": ContainElement(PointTo(MatchFields(IgnoreExtras, Fields{ + "Id": Equal(id), + "DataType": Equal(ingestpb.DataType_DATA_TYPE_NODE), + }))), + })), + }))) + + delRecordb := integration.DeleteRecord(externalID2, "Asset") + del2, err := ingestClient.IngestRecord( + context.Background(), + delRecordb, + retry.WithMax(5), + ) + Expect(err).To(Succeed()) + Expect(del2).To(PointTo(MatchFields(IgnoreExtras, Fields{ + "RecordId": Not(BeNil()), + "Info": PointTo(MatchFields(IgnoreExtras, Fields{ + "Changes": ContainElement(PointTo(MatchFields(IgnoreExtras, Fields{ + "Id": Equal(id2), + "DataType": Equal(ingestpb.DataType_DATA_TYPE_NODE), + }))), + })), + }))) + }) + + It("UpsertRelationshipWrongSourceType", func() { + var err error + ingestClient, err := integration.InitConfigIngest() + Expect(err).To(Succeed()) + + record, externalID := integration.CreateRecordNodeIndividual("Employee") + resp, err := ingestClient.IngestRecord( + context.Background(), + record, + retry.WithMax(5), + ) + + Expect(err).To(Succeed()) + Expect(resp).To(PointTo(MatchFields(IgnoreExtras, Fields{ + "RecordId": Not(BeNil()), + "Info": PointTo(MatchFields(IgnoreExtras, Fields{ + "Changes": ContainElement(PointTo(MatchFields(IgnoreExtras, Fields{ + "Id": Not(BeEmpty()), + "DataType": Equal(ingestpb.DataType_DATA_TYPE_NODE), + }))), + })), + }))) + id := resp.Info.Changes[0].Id + + externalID2 := integration.GenerateRandomString(10) + recordb := integration.CreateRecordResourceNoProperty(externalID2, "Asset") + resp2, err := ingestClient.IngestRecord( + context.Background(), + recordb, + retry.WithMax(5), + ) + + Expect(err).To(Succeed()) + Expect(resp2).To(PointTo(MatchFields(IgnoreExtras, Fields{ + "RecordId": Not(BeNil()), + "Info": PointTo(MatchFields(IgnoreExtras, Fields{ + "Changes": ContainElement(PointTo(MatchFields(IgnoreExtras, Fields{ + "Id": Not(BeEmpty()), + "DataType": Equal(ingestpb.DataType_DATA_TYPE_NODE), + }))), + })), + }))) + id2 := resp2.Info.Changes[0].Id + + record3 := integration.CreateRecordRelationship(externalID, "Whatever", externalID2, "Asset", "CAN_SEE") + resp3, err := ingestClient.IngestRecord( + context.Background(), + record3, + retry.WithMax(5), + ) + + Expect(err).To(Succeed()) + Expect(resp3).To(PointTo(MatchFields(IgnoreExtras, Fields{ + "RecordId": Not(BeNil()), + "Info": PointTo(MatchFields(IgnoreExtras, Fields{ + "Changes": ContainElement(PointTo(MatchFields(IgnoreExtras, Fields{ + "Id": Not(BeEmpty()), + "DataType": Equal(ingestpb.DataType_DATA_TYPE_RELATIONSHIP), + }))), + })), + }))) + + match := integration.GetRelationship(externalID, "Whatever", externalID2, "Asset", "CAN_SEE") + delRecord3 := integration.DeleteRecordRelationship(match) + del3, err := ingestClient.IngestRecord( + context.Background(), + delRecord3, + retry.WithMax(5), + ) + Expect(err).To(Succeed()) + Expect(del3).NotTo(BeNil()) + + delRecord := integration.DeleteRecord(externalID, "Individual") + del, err := ingestClient.IngestRecord( + context.Background(), + delRecord, + retry.WithMax(5), + ) + Expect(err).To(Succeed()) + Expect(del).To(PointTo(MatchFields(IgnoreExtras, Fields{ + "RecordId": Not(BeNil()), + "Info": PointTo(MatchFields(IgnoreExtras, Fields{ + "Changes": ContainElement(PointTo(MatchFields(IgnoreExtras, Fields{ + "Id": Equal(id), + "DataType": Equal(ingestpb.DataType_DATA_TYPE_NODE), + }))), + })), + }))) + + delRecordb := integration.DeleteRecord(externalID2, "Asset") + del2, err := ingestClient.IngestRecord( + context.Background(), + delRecordb, + retry.WithMax(5), + ) + Expect(err).To(Succeed()) + Expect(del2).To(PointTo(MatchFields(IgnoreExtras, Fields{ + "RecordId": Not(BeNil()), + "Info": PointTo(MatchFields(IgnoreExtras, Fields{ + "Changes": ContainElement(PointTo(MatchFields(IgnoreExtras, Fields{ + "Id": Equal(id2), + "DataType": Equal(ingestpb.DataType_DATA_TYPE_NODE), + }))), + })), + }))) + }) + + It("UpsertRelationshipWrongSource", func() { + var err error + ingestClient, err := integration.InitConfigIngest() + Expect(err).To(Succeed()) + + record, externalID := integration.CreateRecordNodeIndividual("Employee") + resp, err := ingestClient.IngestRecord( + context.Background(), + record, + retry.WithMax(5), + ) + + Expect(err).To(Succeed()) + Expect(resp).To(PointTo(MatchFields(IgnoreExtras, Fields{ + "RecordId": Not(BeNil()), + "Info": PointTo(MatchFields(IgnoreExtras, Fields{ + "Changes": ContainElement(PointTo(MatchFields(IgnoreExtras, Fields{ + "Id": Not(BeEmpty()), + "DataType": Equal(ingestpb.DataType_DATA_TYPE_NODE), + }))), + })), + }))) + id := resp.Info.Changes[0].Id + + externalID2 := integration.GenerateRandomString(10) + recordb := integration.CreateRecordResourceNoProperty(externalID2, "Asset") + resp2, err := ingestClient.IngestRecord( + context.Background(), + recordb, + retry.WithMax(5), + ) + + Expect(err).To(Succeed()) + Expect(resp2).To(PointTo(MatchFields(IgnoreExtras, Fields{ + "RecordId": Not(BeNil()), + "Info": PointTo(MatchFields(IgnoreExtras, Fields{ + "Changes": ContainElement(PointTo(MatchFields(IgnoreExtras, Fields{ + "Id": Not(BeEmpty()), + "DataType": Equal(ingestpb.DataType_DATA_TYPE_NODE), + }))), + })), + }))) + id2 := resp2.Info.Changes[0].Id + rel := integration.GenerateRandomString(10) + + record3 := integration.CreateRecordRelationship(rel, "Individual", externalID2, "Asset", "CAN_SEE") + resp3, err := ingestClient.IngestRecord( + context.Background(), + record3, + retry.WithMax(5), + ) + Expect(err).To(Succeed()) + Expect(resp3).NotTo(BeNil()) + + match := integration.GetRelationship(rel, "Individual", externalID2, "Asset", "CAN_SEE") + delRecord3 := integration.DeleteRecordRelationship(match) + del3, err := ingestClient.IngestRecord( + context.Background(), + delRecord3, + retry.WithMax(5), + ) + Expect(err).To(Succeed()) + Expect(del3).NotTo(BeNil()) + + delRecord := integration.DeleteRecord(externalID, "Individual") + del, err := ingestClient.IngestRecord( + context.Background(), + delRecord, + retry.WithMax(5), + ) + Expect(err).To(Succeed()) + Expect(del).To(PointTo(MatchFields(IgnoreExtras, Fields{ + "RecordId": Not(BeNil()), + "Info": PointTo(MatchFields(IgnoreExtras, Fields{ + "Changes": ContainElement(PointTo(MatchFields(IgnoreExtras, Fields{ + "Id": Equal(id), + "DataType": Equal(ingestpb.DataType_DATA_TYPE_NODE), + }))), + })), + }))) + + delRecordb := integration.DeleteRecord(externalID2, "Asset") + del2, err := ingestClient.IngestRecord( + context.Background(), + delRecordb, + retry.WithMax(5), + ) + Expect(err).To(Succeed()) + Expect(del2).To(PointTo(MatchFields(IgnoreExtras, Fields{ + "RecordId": Not(BeNil()), + "Info": PointTo(MatchFields(IgnoreExtras, Fields{ + "Changes": ContainElement(PointTo(MatchFields(IgnoreExtras, Fields{ + "Id": Equal(id2), + "DataType": Equal(ingestpb.DataType_DATA_TYPE_NODE), + }))), + })), + }))) + }) + + It("UpsertRelationshipActionLowercase", func() { + var err error + ingestClient, err := integration.InitConfigIngest() + Expect(err).To(Succeed()) + + record, externalID := integration.CreateRecordNodeIndividual("Employee") + resp, err := ingestClient.IngestRecord( + context.Background(), + record, + retry.WithMax(5), + ) + + Expect(err).To(Succeed()) + Expect(resp).To(PointTo(MatchFields(IgnoreExtras, Fields{ + "RecordId": Not(BeNil()), + "Info": PointTo(MatchFields(IgnoreExtras, Fields{ + "Changes": ContainElement(PointTo(MatchFields(IgnoreExtras, Fields{ + "Id": Not(BeEmpty()), + "DataType": Equal(ingestpb.DataType_DATA_TYPE_NODE), + }))), + })), + }))) + id := resp.Info.Changes[0].Id + + externalID2 := integration.GenerateRandomString(10) + recordb := integration.CreateRecordResourceNoProperty(externalID2, "Asset") + resp2, err := ingestClient.IngestRecord( + context.Background(), + recordb, + retry.WithMax(5), + ) + + Expect(err).To(Succeed()) + Expect(resp2).To(PointTo(MatchFields(IgnoreExtras, Fields{ + "RecordId": Not(BeNil()), + "Info": PointTo(MatchFields(IgnoreExtras, Fields{ + "Changes": ContainElement(PointTo(MatchFields(IgnoreExtras, Fields{ + "Id": Not(BeEmpty()), + "DataType": Equal(ingestpb.DataType_DATA_TYPE_NODE), + }))), + })), + }))) + id2 := resp2.Info.Changes[0].Id + + record3 := integration.CreateRecordRelationship(externalID, "Individual", externalID2, "Asset", "can_see") + resp3, err := ingestClient.IngestRecord( + context.Background(), + record3, + retry.WithMax(5), + ) + Expect(err).To(MatchError(ContainSubstring( + "invalid Relationship.Type: value does not match regex pattern \"^[A-Z]+(?:_[A-Z]+)*$\""))) + Expect(resp3).To(BeNil()) + + delRecord := integration.DeleteRecord(externalID, "Individual") + del, err := ingestClient.IngestRecord( + context.Background(), + delRecord, + retry.WithMax(5), + ) + Expect(err).To(Succeed()) + Expect(del).To(PointTo(MatchFields(IgnoreExtras, Fields{ + "RecordId": Not(BeNil()), + "Info": PointTo(MatchFields(IgnoreExtras, Fields{ + "Changes": ContainElement(PointTo(MatchFields(IgnoreExtras, Fields{ + "Id": Equal(id), + "DataType": Equal(ingestpb.DataType_DATA_TYPE_NODE), + }))), + })), + }))) + + delRecordb := integration.DeleteRecord(externalID2, "Asset") + del2, err := ingestClient.IngestRecord( + context.Background(), + delRecordb, + retry.WithMax(5), + ) + Expect(err).To(Succeed()) + Expect(del2).To(PointTo(MatchFields(IgnoreExtras, Fields{ + "RecordId": Not(BeNil()), + "Info": PointTo(MatchFields(IgnoreExtras, Fields{ + "Changes": ContainElement(PointTo(MatchFields(IgnoreExtras, Fields{ + "Id": Equal(id2), + "DataType": Equal(ingestpb.DataType_DATA_TYPE_NODE), + }))), + })), + }))) + }) + + It("UpsertRelationshipDelProperty", func() { + var err error + ingestClient, err := integration.InitConfigIngest() + Expect(err).To(Succeed()) + + record, externalID := integration.CreateRecordNodeIndividual("Employee") + resp, err := ingestClient.IngestRecord( + context.Background(), + record, + retry.WithMax(5), + ) + + Expect(err).To(Succeed()) + Expect(resp).To(PointTo(MatchFields(IgnoreExtras, Fields{ + "RecordId": Not(BeNil()), + "Info": PointTo(MatchFields(IgnoreExtras, Fields{ + "Changes": ContainElement(PointTo(MatchFields(IgnoreExtras, Fields{ + "Id": Not(BeEmpty()), + "DataType": Equal(ingestpb.DataType_DATA_TYPE_NODE), + }))), + })), + }))) + id := resp.Info.Changes[0].Id + + externalID2 := integration.GenerateRandomString(10) + recordb := integration.CreateRecordResourceNoProperty(externalID2, "Asset") + resp2, err := ingestClient.IngestRecord( + context.Background(), + recordb, + retry.WithMax(5), + ) + Expect(err).To(Succeed()) + Expect(resp2).To(PointTo(MatchFields(IgnoreExtras, Fields{ + "RecordId": Not(BeNil()), + "Info": PointTo(MatchFields(IgnoreExtras, Fields{ + "Changes": ContainElement(PointTo(MatchFields(IgnoreExtras, Fields{ + "Id": Not(BeEmpty()), + "DataType": Equal(ingestpb.DataType_DATA_TYPE_NODE), + }))), + })), + }))) + id2 := resp2.Info.Changes[0].Id + + record3 := integration.CreateRecordRelationship(externalID, "Individual", externalID2, "Asset", "CAN_SEE") + resp3, err := ingestClient.IngestRecord( + context.Background(), + record3, + retry.WithMax(5), + ) + + Expect(err).To(Succeed()) + Expect(resp3).To(PointTo(MatchFields(IgnoreExtras, Fields{ + "RecordId": Not(BeNil()), + "Info": PointTo(MatchFields(IgnoreExtras, Fields{ + "Changes": ContainElement(PointTo(MatchFields(IgnoreExtras, Fields{ + "Id": Not(BeEmpty()), + "DataType": Equal(ingestpb.DataType_DATA_TYPE_RELATIONSHIP), + }))), + })), + }))) + + delRecord3 := integration.DeleteRecordRelationshipProperty( + externalID, + "Individual", + externalID2, + "Asset", + "CAN_SEE", + "property1", + ) + del3, err := ingestClient.IngestRecord( + context.Background(), + delRecord3, + retry.WithMax(5), + ) + Expect(err).To(Succeed()) + Expect(del3).To(PointTo(MatchFields(IgnoreExtras, Fields{ + "RecordId": Not(BeNil()), + "Info": PointTo(MatchFields(IgnoreExtras, Fields{ + "Changes": ContainElement(PointTo(MatchFields(IgnoreExtras, Fields{ + "DataType": Equal(ingestpb.DataType_DATA_TYPE_RELATIONSHIP), + }))), + })), + }))) + + delRecord := integration.DeleteRecord(externalID, "Individual") + del, err := ingestClient.IngestRecord( + context.Background(), + delRecord, + retry.WithMax(5), + ) + Expect(err).To(Succeed()) + Expect(del).To(PointTo(MatchFields(IgnoreExtras, Fields{ + "RecordId": Not(BeNil()), + "Info": PointTo(MatchFields(IgnoreExtras, Fields{ + "Changes": ContainElement(PointTo(MatchFields(IgnoreExtras, Fields{ + "Id": Equal(id), + "DataType": Equal(ingestpb.DataType_DATA_TYPE_NODE), + }))), + })), + }))) + + delRecordb := integration.DeleteRecord(externalID2, "Asset") + del2, err := ingestClient.IngestRecord( + context.Background(), + delRecordb, + retry.WithMax(5), + ) + Expect(err).To(Succeed()) + Expect(del2).To(PointTo(MatchFields(IgnoreExtras, Fields{ + "RecordId": Not(BeNil()), + "Info": PointTo(MatchFields(IgnoreExtras, Fields{ + "Changes": ContainElement(PointTo(MatchFields(IgnoreExtras, Fields{ + "Id": Equal(id2), + "DataType": Equal(ingestpb.DataType_DATA_TYPE_NODE), + }))), + })), + }))) + }) + + It("RelationshipDelNotExistingProperty", func() { + var err error + ingestClient, err := integration.InitConfigIngest() + Expect(err).To(Succeed()) + + externalID := integration.GenerateRandomString(10) + externalID2 := integration.GenerateRandomString(10) + delRecord3 := integration.DeleteRecordRelationshipProperty( + externalID, + "Individual", + externalID2, + "Asset", + "CAN_SEE", + "property1", + ) + del3, err := ingestClient.IngestRecord( + context.Background(), + delRecord3, + retry.WithMax(5), + ) + Expect(err).To(Succeed()) + Expect(del3).To(PointTo(MatchFields(IgnoreExtras, Fields{ + "RecordId": Not(BeNil()), + "Info": PointTo(MatchFields(IgnoreExtras, Fields{ + "Changes": ContainElement(PointTo(MatchFields(IgnoreExtras, Fields{ + "DataType": Equal(ingestpb.DataType_DATA_TYPE_RELATIONSHIP), + }))), + })), + }))) + }) + }) + + Describe("Stream", func() { + It("StreamSendRecord", func() { + var err, err2 error + + ingestClient, err := integration.InitConfigIngest() + Expect(err).To(Succeed()) + + externalID := integration.GenerateRandomString(10) + record := integration.CreateRecordNoProperty(externalID, "Individual") + externalID2 := integration.GenerateRandomString(10) + recordb := integration.CreateRecordNoProperty(externalID2, "Individual") + + records := []*ingestpb.Record{ + record, recordb, + } + + ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second) + defer cancel() + + err2 = ingestClient.OpenStreamClient(ctx) + Expect(err2).To(Succeed()) + + for _, record := range records { + err3 := ingestClient.SendRecord(record) + Expect(err3).To(Succeed()) + resp, err4 := ingestClient.ReceiveResponse() + Expect(err4).To(Succeed()) + Expect(resp).To(PointTo(MatchFields(IgnoreExtras, Fields{ + "RecordId": Not(BeNil()), + "Info": PointTo(MatchFields(IgnoreExtras, Fields{ + "Changes": ContainElement(PointTo(MatchFields(IgnoreExtras, Fields{ + "Id": Not(BeEmpty()), + "DataType": Equal(ingestpb.DataType_DATA_TYPE_NODE), + }))), + })), + }))) + } + + delRecord := integration.DeleteRecord(externalID, "Individual") + del, err := ingestClient.IngestRecord( + context.Background(), + delRecord, + retry.WithMax(5), + ) + Expect(err).To(Succeed()) + Expect(del).To(PointTo(MatchFields(IgnoreExtras, Fields{ + "RecordId": Not(BeNil()), + "Info": PointTo(MatchFields(IgnoreExtras, Fields{ + "Changes": ContainElement(PointTo(MatchFields(IgnoreExtras, Fields{ + "Id": Not(BeEmpty()), + "DataType": Equal(ingestpb.DataType_DATA_TYPE_NODE), + }))), + })), + }))) + + delRecordb := integration.DeleteRecord(externalID2, "Individual") + del2, err := ingestClient.IngestRecord( + context.Background(), + delRecordb, + retry.WithMax(5), + ) + Expect(err).To(Succeed()) + Expect(del2).To(PointTo(MatchFields(IgnoreExtras, Fields{ + "RecordId": Not(BeNil()), + "Info": PointTo(MatchFields(IgnoreExtras, Fields{ + "Changes": ContainElement(PointTo(MatchFields(IgnoreExtras, Fields{ + "Id": Not(BeEmpty()), + "DataType": Equal(ingestpb.DataType_DATA_TYPE_NODE), + }))), + })), + }))) + }) + + It("StreamRecords", func() { + var err error + ingestClient, err := integration.InitConfigIngest() + Expect(err).To(Succeed()) + + externalID := integration.GenerateRandomString(10) + record := integration.CreateRecordNoProperty(externalID, "Individual") + externalID2 := integration.GenerateRandomString(10) + recordb := integration.CreateRecordNoProperty(externalID2, "Individual") + + records := []*ingestpb.Record{ + record, recordb, + } + responses, err := ingestClient.StreamRecords(records) + Expect(err).To(Succeed()) + for _, response := range responses { + Expect(response).To(PointTo(MatchFields(IgnoreExtras, Fields{ + "RecordId": Not(BeNil()), + "Error": BeNil(), + "Info": PointTo(MatchFields(IgnoreExtras, Fields{ + "Changes": ContainElement(PointTo(MatchFields(IgnoreExtras, Fields{ + "Id": Not(BeEmpty()), + "DataType": Equal(ingestpb.DataType_DATA_TYPE_NODE), + }))), + })), + }))) + } + + delRecord := integration.DeleteRecord(externalID, "Individual") + del, err := ingestClient.IngestRecord( + context.Background(), + delRecord, + retry.WithMax(5), + ) + Expect(err).To(Succeed()) + Expect(del).To(PointTo(MatchFields(IgnoreExtras, Fields{ + "RecordId": Not(BeNil()), + "Info": PointTo(MatchFields(IgnoreExtras, Fields{ + "Changes": ContainElement(PointTo(MatchFields(IgnoreExtras, Fields{ + "Id": Not(BeEmpty()), + "DataType": Equal(ingestpb.DataType_DATA_TYPE_NODE), + }))), + })), + }))) + + delRecordb := integration.DeleteRecord(externalID2, "Individual") + del2, err := ingestClient.IngestRecord( + context.Background(), + delRecordb, + retry.WithMax(5), + ) + Expect(err).To(Succeed()) + Expect(del2).To(PointTo(MatchFields(IgnoreExtras, Fields{ + "RecordId": Not(BeNil()), + "Info": PointTo(MatchFields(IgnoreExtras, Fields{ + "Changes": ContainElement(PointTo(MatchFields(IgnoreExtras, Fields{ + "Id": Not(BeEmpty()), + "DataType": Equal(ingestpb.DataType_DATA_TYPE_NODE), + }))), + })), + }))) + }) + + It("StreamRecordsRetry", func() { + var err error + ingestClient, err := integration.InitConfigIngestRetry() + Expect(err).To(Succeed()) + + externalID := integration.GenerateRandomString(10) + record := integration.CreateRecordNoProperty(externalID, "Individual") + externalID2 := integration.GenerateRandomString(10) + recordb := integration.CreateRecordNoProperty(externalID2, "Individual") + + records := []*ingestpb.Record{ + record, recordb, + } + responses, err := ingestClient.StreamRecords(records) + Expect(err).To(Succeed()) + for _, response := range responses { + Expect(response).To(PointTo(MatchFields(IgnoreExtras, Fields{ + "RecordId": Not(BeNil()), + "Error": BeNil(), + "Info": PointTo(MatchFields(IgnoreExtras, Fields{ + "Changes": ContainElement(PointTo(MatchFields(IgnoreExtras, Fields{ + "Id": Not(BeEmpty()), + "DataType": Equal(ingestpb.DataType_DATA_TYPE_NODE), + }))), + })), + }))) + } + + delRecord := integration.DeleteRecord(externalID, "Individual") + del, err := ingestClient.IngestRecord( + context.Background(), + delRecord, + retry.WithMax(5), + ) + Expect(err).To(Succeed()) + Expect(del).To(PointTo(MatchFields(IgnoreExtras, Fields{ + "RecordId": Not(BeNil()), + "Info": PointTo(MatchFields(IgnoreExtras, Fields{ + "Changes": ContainElement(PointTo(MatchFields(IgnoreExtras, Fields{ + "Id": Not(BeEmpty()), + "DataType": Equal(ingestpb.DataType_DATA_TYPE_NODE), + }))), + })), + }))) + + delRecordb := integration.DeleteRecord(externalID2, "Individual") + del2, err := ingestClient.IngestRecord( + context.Background(), + delRecordb, + retry.WithMax(5), + ) + Expect(err).To(Succeed()) + Expect(del2).To(PointTo(MatchFields(IgnoreExtras, Fields{ + "RecordId": Not(BeNil()), + "Info": PointTo(MatchFields(IgnoreExtras, Fields{ + "Changes": ContainElement(PointTo(MatchFields(IgnoreExtras, Fields{ + "Id": Not(BeEmpty()), + "DataType": Equal(ingestpb.DataType_DATA_TYPE_NODE), + }))), + })), + }))) + }) + }) +}) diff --git a/examples/config/cmd/external_data_resolver_config.go b/examples/config/cmd/external_data_resolver_config.go index ffc71189..01c6591a 100644 --- a/examples/config/cmd/external_data_resolver_config.go +++ b/examples/config/cmd/external_data_resolver_config.go @@ -47,7 +47,7 @@ var createExternalDataResolverConfigCmd = &cobra.Command{ ResponseSelector: ".", } createReq, _ := config.NewCreate("like-real-config-node-name2") - createReq.ForLocation("gid:AAAAAvFyVpD_1kd8k2kpNY9rjFM") + createReq.ForLocation("gid:AAAAABBBBB_uiuiu144KNUI1245") createReq.WithDisplayName("Like real ConfigNode Name2") createReq.WithExternalDataResolverConfig(configuration) diff --git a/test/constants.go b/test/constants.go index 64562ce2..552f0268 100644 --- a/test/constants.go +++ b/test/constants.go @@ -22,6 +22,7 @@ import ( "google.golang.org/protobuf/types/known/timestamppb" authorizationpb "github.com/indykite/indykite-sdk-go/gen/indykite/authorization/v1beta1" + configpb "github.com/indykite/indykite-sdk-go/gen/indykite/config/v1beta1" ingestpb "github.com/indykite/indykite-sdk-go/gen/indykite/ingest/v1beta3" knowledgeobjects "github.com/indykite/indykite-sdk-go/gen/indykite/knowledge/objects/v1beta1" objects "github.com/indykite/indykite-sdk-go/gen/indykite/objects/v1beta2" @@ -191,6 +192,17 @@ var ( ConsentAllow = "gid:AAAAHf5ZnwufDUK-tnCjoSsw-cQ" Resolver = "gid:AAAAIcrOChFSj0R5sFm1V8JXhiE" + Url = "https://example.com/source2" + Method1 = "GET" + Method2 = "POST" + Headers = map[string]*configpb.ExternalDataResolverConfig_Header{ + "Authorization": {Values: []string{"Bearer edolkUTY"}}, + "Content-Type": {Values: []string{"application/json"}}, + } + RequestType = configpb.ExternalDataResolverConfig_CONTENT_TYPE_JSON + RequestPayload = []byte(`{"key": "value"}`) + ResponseType = configpb.ExternalDataResolverConfig_CONTENT_TYPE_JSON + ResponseSelector = "." ) func GenerateRandomString(length int) string {