Skip to content

Commit

Permalink
feat: add tda and update outdated tests
Browse files Browse the repository at this point in the history
implement ENG-3351
  • Loading branch information
cowan-macady committed Apr 25, 2024
1 parent 61a96d4 commit 90ef7d8
Show file tree
Hide file tree
Showing 92 changed files with 4,224 additions and 4,964 deletions.
5 changes: 5 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,14 @@ omit =
indykite_sdk/ingest.py
indykite_sdk/indykite/*
indykite_sdk/validate/*
indykite_sdk/buf/*
indykite_sdk/gnostic/*
indykite_sdk/identity/helper.py
indykite_sdk/model/unique_name_identifier.py
indykite_sdk/model/data_access.py
indykite_sdk/model/email_attachment.py
indykite_sdk/identity/consent.py
indykite_sdk/tda/*
indykite_sdk/utils/*
tests/*
examples/*
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/commitlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: wagoid/commitlint-github-action@v5
- uses: wagoid/commitlint-github-action@v6
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ share/python-wheels/
*.egg
MANIFEST
indykite_sdk/ingest.py
indykite_sdk/api.py
*.api.py

# PyInstaller
# Usually these files are written by a python script from a template
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ import argparse
```

:four: Close a GRPC channel
You simple call the `close()` function on the channel (The `IdentityClient()` function below represents the def in the previous step)
You simply call the `close()` function on the channel (The `IdentityClient()` function below represents the def in the previous step)
```python
from indykite_sdk.identity import IdentityClient

Expand All @@ -267,7 +267,7 @@ To display code coverage, enter
https://indykite.github.io/indykite-sdk-python/


### Examples
## Examples

https://github.com/indykite/indykite-sdk-python/tree/master/indykite_sdk

Expand Down
2 changes: 1 addition & 1 deletion buf.gen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: v1
managed:
enabled: true
plugins:
- plugin: buf.build/protocolbuffers/python:v23.4
- plugin: buf.build/protocolbuffers/python:v26.1
out: indykite_sdk
- plugin: buf.build/grpc/python:v1.56.2
out: indykite_sdk
Expand Down
8 changes: 8 additions & 0 deletions buf.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Generated by buf. DO NOT EDIT.
version: v1
deps:
- remote: buf.build
owner: bufbuild
repository: protovalidate
commit: b983156c5e994cc9892e0ce3e64e17e0
digest: shake256:fb47a62989d38c2529bcc5cd86ded43d800eb84cee82b42b9e8a9e815d4ee8134a0fb9d0ce8299b27c2d2bbb7d6ade0c4ad5a8a4d467e1e2c7ca619ae9f634e2
4 changes: 4 additions & 0 deletions buf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
version: v1
deps:
- buf.build/bufbuild/protovalidate
- buf.build/gnostic/gnostic
5 changes: 5 additions & 0 deletions codecov.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,14 @@ ignore:
- "indykite_sdk/ingest.py"
- "indykite_sdk/indykite"
- "indykite_sdk/validate"
- "indykite_sdk/buf"
"indykite_sdk/gnostic"
- "indykite_sdk/identity/helper.py"
- "indykite_sdk/model/unique_name_identifier.py"
- "indykite_sdk/model/email_attachment.py"
- "indykite_sdk/model/data_access.py"
- "indykite_sdk/identity/consent.py"
- "indykite_sdk/tda"
- "indykite_sdk/utils"
- "tests"
- "examples"
Expand Down
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"],
rules: {
// 0 - Disabled, 1 - Warning, 2 - Error
Expand Down
6 changes: 5 additions & 1 deletion gen_proto.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
echo "Generating protobufs..."
buf generate buf.build/indykite/indykiteapis
buf generate buf.build/envoyproxy/protoc-gen-validate
buf generate buf.build/bufbuild/protovalidate
buf generate buf.build/gnostic/gnostic

echo "Rewriting imports..."
packages=("indykite" "validate")
packages=("indykite" "validate" "buf" "gnostic")

if [[ $OSTYPE == 'darwin'* ]]; then
for package in ${packages[@]}; do
Expand All @@ -13,6 +15,8 @@ if [[ $OSTYPE == 'darwin'* ]]; then
else
for package in ${packages[@]}; do
find indykite_sdk/indykite/. -name '*.py' -exec sed -i -e "s/from ${package}/from indykite_sdk.${package}/g" {} \;
find indykite_sdk/buf/validate/. -name '*.py' -exec sed -i -e "s/from ${package}/from indykite_sdk.${package}/g" {} \;
find indykite_sdk/gnostic/. -name '*.py' -exec sed -i -e "s/from ${package}/from indykite_sdk.${package}/g" {} \;
done
fi

Expand Down
2,525 changes: 0 additions & 2,525 deletions indykite_sdk/api.py

This file was deleted.

31 changes: 31 additions & 0 deletions indykite_sdk/buf/validate/expression_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions indykite_sdk/buf/validate/expression_pb2_grpc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
"""Client and server classes corresponding to protobuf-defined services."""
import grpc

30 changes: 30 additions & 0 deletions indykite_sdk/buf/validate/priv/private_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions indykite_sdk/buf/validate/priv/private_pb2_grpc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
"""Client and server classes corresponding to protobuf-defined services."""
import grpc

402 changes: 402 additions & 0 deletions indykite_sdk/buf/validate/validate_pb2.py

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions indykite_sdk/buf/validate/validate_pb2_grpc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
"""Client and server classes corresponding to protobuf-defined services."""
import grpc

3 changes: 2 additions & 1 deletion indykite_sdk/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ def __init__(self, token_source=None):
create_authorization_policy_config_node, update_authorization_policy_config_node, \
validate_authenticator_attachment, validate_authorization_policy_status, \
validate_user_verification, validate_conveyance, authorization_policy_config, webauthn_provider_config, \
auth_flow_config, list_config_node_versions
auth_flow_config, list_config_node_versions, \
consent_config, create_consent_config_node, update_consent_config_node, validate_data_points
from .oauth2_provider import create_oauth2_provider, read_oauth2_provider, update_oauth2_provider, \
delete_oauth2_provider
from .oauth2_application import create_oauth2_application, read_oauth2_application, update_oauth2_application, \
Expand Down
111 changes: 111 additions & 0 deletions indykite_sdk/config/config_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,104 @@ def authorization_policy_config(self, policy, status, tags=[]):
return logger.logger_error(exception)


def create_consent_config_node(self,
location,
name,
display_name,
description,
consent_config,
bookmarks=[]):
"""
create consent configuration
:param self:
:param location: string gid id
:param name: string pattern: ^[a-z](?:[-a-z0-9]{0,61}[a-z0-9])$
:param display_name: string
:param description: string
:param consent_config: ConsentConfiguration object
:param bookmarks: list of strings with pattern: ^[a-zA-Z0-9_-]{40,}$
:return: deserialized CreateConfigNode instance
"""
sys.excepthook = logger.handle_excepthook
try:
response = self.stub.CreateConfigNode(
pb2.CreateConfigNodeRequest(
location=location,
name=name,
display_name=wrappers.StringValue(value=display_name),
description=wrappers.StringValue(value=description),
consent_config=consent_config,
bookmarks=bookmarks
)
)
except Exception as exception:
return logger.logger_error(exception)

if not response:
return None
return CreateConfigNode.deserialize(response)


def update_consent_config_node(self,
config_node_id,
etag,
display_name,
description,
consent_config,
bookmarks=[]):
"""
update consent configuration
:param self:
:param config_node_id: string gid id
:param etag: string
:param display_name: string
:param description: string
:param consent_config: ConsentConfiguration object
:param bookmarks: list of strings with pattern: ^[a-zA-Z0-9_-]{40,}$
:return: deserialized UpdateConfigNode instance
"""
sys.excepthook = logger.handle_excepthook
try:
response = self.stub.UpdateConfigNode(
pb2.UpdateConfigNodeRequest(
id=config_node_id,
etag=wrappers.StringValue(value=etag),
display_name=wrappers.StringValue(value=display_name),
description=wrappers.StringValue(value=description),
consent_config= consent_config,
bookmarks=bookmarks
)
)
except Exception as exception:
return logger.logger_error(exception)

if not response:
return None
return UpdateConfigNode.deserialize(response)


def consent_config(self, purpose, data_points, application_id):
"""
create ConsentConfiguration
:param self:
:param purpose: string
:param data_points: list
:param application_id: gid
:return: ConsentConfiguration object
"""
sys.excepthook = logger.handle_excepthook
try:
if data_points:
data_points = self.validate_data_points(data_points)
return model_pb2.ConsentConfiguration(
purpose=purpose,
data_points=data_points,
application_id=application_id
)
except Exception as exception:
return logger.logger_error(exception)


def validate_conveyance(self, conveyance):
"""
validate conveyance
Expand Down Expand Up @@ -590,6 +688,19 @@ def validate_authenticator_attachment(self, authenticator_attachment):
return logger.logger_error(exception)


def validate_data_points(self, data_points):
"""
validate data_points requirement
:param self:
:param data_points: array
:return: reduces to unique list
"""
try:
return list(dict.fromkeys(data_points))
except Exception as exception:
return logger.logger_error(exception)


def validate_authorization_policy_status(self, status):
"""
validate status
Expand Down

0 comments on commit 90ef7d8

Please sign in to comment.