Skip to content

Commit

Permalink
feat: add tda and consent config node
Browse files Browse the repository at this point in the history
implement ENG-3351
  • Loading branch information
cowan-macady committed Apr 29, 2024
1 parent 5a2cef9 commit 846a5cd
Show file tree
Hide file tree
Showing 83 changed files with 16,688 additions and 15,345 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/commitlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: wagoid/commitlint-github-action@v5
- uses: wagoid/commitlint-github-action@v6

strict-commitlint:
name: Strict commit lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: wagoid/commitlint-github-action@v5
- uses: wagoid/commitlint-github-action@v6
with:
failOnWarnings: true
- name: Check amount of commits
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ repos:
# exclude: ^(CHANGELOG|responsible_disclosure).md$

- repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook
rev: v9.11.0
rev: v9.13.0
hooks:
- id: commitlint
stages: [commit-msg]
Expand Down
1 change: 1 addition & 0 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ install-tools:
@go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
@go install github.com/onsi/ginkgo/v2/ginkgo@latest
@go install golang.org/x/tools/go/analysis/passes/fieldalignment/cmd/fieldalignment@latest
@go install github.com/sudorandom/protoc-gen-connect-openapi@main
@echo Installation completed

test:
Expand Down
16 changes: 12 additions & 4 deletions authorization/is_authorized_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,12 @@ var _ = Describe("IsAuthorized", func() {
Subject: &authorizationpb.Subject{
Subject: &authorizationpb.Subject_DigitalTwinProperty{
DigitalTwinProperty: &authorizationpb.Property{
Type: "email_for_example",
Value: objectpb.String("[email protected]"),
Type: "email_for_example",
Value: &objectpb.Value{
Value: &objectpb.Value_StringValue{
StringValue: "[email protected]",
},
},
},
},
},
Expand All @@ -170,8 +174,12 @@ var _ = Describe("IsAuthorized", func() {
resp, err := authorizationClient.IsAuthorizedByProperty(
ctx,
&authorizationpb.Property{
Type: "email_for_example",
Value: objectpb.String("[email protected]"),
Type: "email_for_example",
Value: &objectpb.Value{
Value: &objectpb.Value_StringValue{
StringValue: "[email protected]",
},
},
},
resourceExample,
inputParam,
Expand Down
16 changes: 12 additions & 4 deletions authorization/what_authorized_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,12 @@ var _ = Describe("WhatAuthorized", func() {
Subject: &authorizationpb.Subject{
Subject: &authorizationpb.Subject_DigitalTwinProperty{
DigitalTwinProperty: &authorizationpb.Property{
Type: "email_for_example",
Value: objectpb.String("[email protected]"),
Type: "email_for_example",
Value: &objectpb.Value{
Value: &objectpb.Value_StringValue{
StringValue: "[email protected]",
},
},
},
},
},
Expand All @@ -170,8 +174,12 @@ var _ = Describe("WhatAuthorized", func() {
resp, err := authorizationClient.WhatAuthorizedByProperty(
ctx,
&authorizationpb.Property{
Type: "email_for_example",
Value: objectpb.String("[email protected]"),
Type: "email_for_example",
Value: &objectpb.Value{
Value: &objectpb.Value_StringValue{
StringValue: "[email protected]",
},
},
},
resourceTypeExample,
inputParam,
Expand Down
2 changes: 2 additions & 0 deletions buf.gen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ managed:
except:
- buf.build/googleapis/googleapis
- buf.build/envoyproxy/protoc-gen-validate
- buf.build/bufbuild/protovalidate
- buf.build/gnostic/gnostic
plugins:
- plugin: buf.build/protocolbuffers/go
out: gen
Expand Down
7 changes: 7 additions & 0 deletions buf.openapi.gen.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
version: v1
plugins:
- plugin: connect-openapi
out: doc/openapi
opt:
- content-types=json
2 changes: 1 addition & 1 deletion commitlint.config.js → commitlint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
export default {
extends: ["@commitlint/config-conventional"],
defaultIgnores: false,
rules: {
Expand Down
121 changes: 121 additions & 0 deletions config/config_node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,46 @@ var _ = Describe("ConfigNode", func() {
Expect(resp).To(test.EqualProto(beResp))
})

It("ReadSuccessConsentConfiguration", func() {
configNodeRequest, err := config.NewRead("gid:like-real-config-node-id")
Ω(err).To(Succeed())
configNodeRequest.WithBookmarks([]string{"something-like-bookmark-which-is-long-enough"})
configNodeRequest.WithVersion(int64(0))
beResp := &configpb.ReadConfigNodeResponse{
ConfigNode: &configpb.ConfigNode{
Id: "gid:like-real-config-node-id",
Name: "like-real-config-node-name",
DisplayName: "Like Real Config-Node Name",
CreatedBy: "creator",
CreateTime: timestamppb.Now(),
CustomerId: "gid:like-real-customer-id",
AppSpaceId: "gid:like-real-app-space-id",
TenantId: "gid:like-real-tenant-id",
Etag: "123qwe",
Version: 0,
Config: &configpb.ConfigNode_ConsentConfig{
ConsentConfig: &configpb.ConsentConfiguration{
Purpose: "Taking control",
DataPoints: []string{"lastname", "firstname", "email"},
ApplicationId: "gid:like-real-application-id",
},
},
},
}
mockClient.EXPECT().
ReadConfigNode(
gomock.Any(),
test.WrapMatcher(PointTo(MatchFields(IgnoreExtras, Fields{
"Id": Equal("gid:like-real-config-node-id"),
}))),
gomock.Any(),
).Return(beResp, nil)

resp, err := configClient.ReadConfigNode(ctx, configNodeRequest)
Expect(err).To(Succeed())
Expect(resp).To(test.EqualProto(beResp))
})

It("ReadSuccessOAuth2Client", func() {
configNodeRequest, err := config.NewRead("gid:like-real-config-node-id")
Ω(err).To(Succeed())
Expand Down Expand Up @@ -466,6 +506,47 @@ var _ = Describe("ConfigNode", func() {
Expect(resp).To(test.EqualProto(beResp))
})

It("CreateConsentConfiguration", func() {
configuration := &configpb.ConsentConfiguration{
Purpose: "Taking control",
DataPoints: []string{"lastname", "firstname", "email"},
ApplicationId: "gid:like-real-application-id",
}

configNodeRequest, err := config.NewCreate("like-real-config-node-name")
Ω(err).To(Succeed())
configNodeRequest.ForLocation("gid:like-real-customer-id")
configNodeRequest.WithDisplayName("Like real ConfigNode Name")
configNodeRequest.WithConsentConfig(configuration)

beResp := &configpb.CreateConfigNodeResponse{
Id: "gid:like-real-config-node-id",
Etag: "123qwe",
CreatedBy: "creator",
CreateTime: timestamppb.Now(),
Bookmark: "something-like-bookmark-which-is-long-enough",
}

mockClient.EXPECT().CreateConfigNode(
gomock.Any(),
test.WrapMatcher(PointTo(MatchFields(IgnoreExtras, Fields{
"Name": Equal("like-real-config-node-name"),
"Location": Equal("gid:like-real-customer-id"),
"Config": PointTo(MatchFields(IgnoreExtras, Fields{
"ConsentConfig": PointTo(MatchFields(IgnoreExtras, Fields{
"Purpose": Equal("Taking control"),
"ApplicationId": Equal("gid:like-real-application-id"),
})),
})),
}))),
gomock.Any(),
).Return(beResp, nil)

resp, err := configClient.CreateConfigNode(ctx, configNodeRequest)
Expect(err).To(Succeed())
Expect(resp).To(test.EqualProto(beResp))
})

It("CreateNonValid", func() {
configuration := &configpb.OAuth2ClientConfig{
ProviderType: configpb.ProviderType_PROVIDER_TYPE_GOOGLE_COM,
Expand Down Expand Up @@ -792,6 +873,46 @@ var _ = Describe("ConfigNode", func() {
Expect(resp).To(test.EqualProto(beResp))
})

It("UpdateConsentConfiguration", func() {
configuration := &configpb.ConsentConfiguration{
Purpose: "Taking control",
DataPoints: []string{"lastname", "firstname", "email"},
ApplicationId: "gid:like-real-application-id",
}

configNodeRequest, err := config.NewUpdate("gid:like-real-config-node-id")
Ω(err).To(Succeed())
configNodeRequest.EmptyDisplayName()
configNodeRequest.WithDisplayName("Like real ConfigNode Name Update")
configNodeRequest.WithConsentConfig(configuration)

beResp := &configpb.UpdateConfigNodeResponse{
Id: "gid:like-real-config-node-id",
Etag: "123qwert",
UpdatedBy: "creator",
UpdateTime: timestamppb.Now(),
Bookmark: "something-like-bookmark-which-is-long-enough",
}

mockClient.EXPECT().UpdateConfigNode(
gomock.Any(),
test.WrapMatcher(PointTo(MatchFields(IgnoreExtras, Fields{
"Id": Equal("gid:like-real-config-node-id"),
"Config": PointTo(MatchFields(IgnoreExtras, Fields{
"ConsentConfig": PointTo(MatchFields(IgnoreExtras, Fields{
"Purpose": Equal("Taking control"),
"ApplicationId": Equal("gid:like-real-application-id"),
})),
})),
}))),
gomock.Any(),
).Return(beResp, nil)

resp, err := configClient.UpdateConfigNode(ctx, configNodeRequest)
Expect(err).To(Succeed())
Expect(resp).To(test.EqualProto(beResp))
})

It("UpdateNonValid", func() {
configNodeRequest, err := config.NewUpdate("12345")
Ω(err).To(Succeed())
Expand Down
16 changes: 16 additions & 0 deletions config/config_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,22 @@ func (x *NodeRequest) WithAuthorizationPolicyConfig(v *configpb.AuthorizationPol
return x
}

func (x *NodeRequest) WithConsentConfig(v *configpb.ConsentConfiguration) *NodeRequest {
switch {
case x.create != nil:
x.create.Config = nil
if v != nil {
x.create.Config = &configpb.CreateConfigNodeRequest_ConsentConfig{ConsentConfig: v}
}
case x.update != nil:
x.update.Config = nil
if v != nil {
x.update.Config = &configpb.UpdateConfigNodeRequest_ConsentConfig{ConsentConfig: v}
}
}
return x
}

func (x *NodeRequest) WithWebauthnProviderConfig(v *configpb.WebAuthnProviderConfig) *NodeRequest {
switch {
case x.create != nil:
Expand Down
1 change: 1 addition & 0 deletions doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
//go:generate mockgen -copyright_file ./doc/LICENSE -package ingest -destination ./test/ingest/v1beta3/ingest_api_mock.go github.com/indykite/indykite-sdk-go/gen/indykite/ingest/v1beta3 IngestAPIClient,IngestAPI_StreamRecordsClient
//go:generate mockgen -copyright_file ./doc/LICENSE -package authorization -destination ./test/authorization/v1beta1/authorization_api_mock.go github.com/indykite/indykite-sdk-go/gen/indykite/authorization/v1beta1 AuthorizationAPIClient
//go:generate mockgen -copyright_file ./doc/LICENSE -package knowledge -destination ./test/knowledge/v1beta2/identity_knowledge_api_mock.go github.com/indykite/indykite-sdk-go/gen/indykite/knowledge/v1beta2 IdentityKnowledgeAPIClient
//go:generate mockgen -copyright_file ./doc/LICENSE -package tda -destination ./test/tda/v1beta1/trusted_data_access_api_mock.go github.com/indykite/indykite-sdk-go/gen/indykite/tda/v1beta1 TrustedDataAccessAPIClient

/*
Package indykite is the root of the packages used to access IndyKite Platform.
Expand Down
8 changes: 6 additions & 2 deletions examples/authorization/cmd/is_authorized.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,12 @@ var withPropertyCmd = &cobra.Command{
var policyTags []string

property := &authorizationpb.Property{
Type: propertyType,
Value: objects.String(propertyValue),
Type: propertyType,
Value: &objects.Value{
Value: &objects.Value_StringValue{
StringValue: propertyValue,
},
},
}

resp, err := client.IsAuthorizedByProperty(
Expand Down
8 changes: 6 additions & 2 deletions examples/authorization/cmd/what_authorized.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,12 @@ var whatWithPropertyCmd = &cobra.Command{
}

property := &authorizationpb.Property{
Type: propertyType,
Value: objects.String(propertyValue),
Type: propertyType,
Value: &objects.Value{
Value: &objects.Value_StringValue{
StringValue: propertyValue,
},
},
}
inputParams := map[string]*authorizationpb.InputParam{}
var policyTags []string
Expand Down
Loading

0 comments on commit 846a5cd

Please sign in to comment.