Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: minimal implementation of Auth and WebApp clients #51

Open
wants to merge 21 commits into
base: master
Choose a base branch
from

Conversation

santhoshramaraj
Copy link
Member

What does this Pull Request accomplish?

Adds support for Auth and WebApp services with limited scope

Why should this Pull Request be merged?

Auth and WebApp clients are a dependency for DataSpace client

What testing has been done?

Tested with main-test using Pytest

@mure mure changed the title Minimal implementation of Auth and WebApp clients feat: minimal implementation of Auth and WebApp clients Nov 8, 2023
@mure
Copy link
Contributor

mure commented Nov 8, 2023

FYI I updated your PR title to match the commit format needed for our automated release workflow.

nisystemlink/clients/auth/models/_additional_models.py Outdated Show resolved Hide resolved
nisystemlink/clients/auth/models/_additional_models.py Outdated Show resolved Hide resolved
nisystemlink/clients/auth/models/__init__.py Outdated Show resolved Hide resolved
nisystemlink/clients/auth/models/_additional_models.py Outdated Show resolved Hide resolved
The login name of the user. This the "username" or equivalent entered when
the user authenticates with the identity provider.
"""
accepted_to_s: Optional[bool] = Field(None, alias="acceptedToS", example=True)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know we're not using this model for anything yet, but accepted_to_s is a weird name. Probably should just be accepted_tos

nisystemlink/clients/webapp/_webapp_client.py Outdated Show resolved Hide resolved
nisystemlink/clients/webapp/models/_additional_models.py Outdated Show resolved Hide resolved
tests/integration/auth/test_auth.py Outdated Show resolved Hide resolved
nisystemlink/clients/auth/_auth_client.py Outdated Show resolved Hide resolved
from . import models


class AuthClient(BaseClient):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's very likely we'll want to combine the /niuser and /niauth methods into a single client. There's not really a meaningful distinction between them and they're both implemented in the same service anyway. With that in mind, is AuthClient the name we want to go with? I could see UserClient, AdminClient, AccessControlClient off the top of my head.

@spanglerco, @kjohn1922 , @cameronwaterman any opinions?

Comment on lines +14 to +23
user: Optional[User]
"""Details of authenticated caller"""
org: Optional[Org]
"""Organization of authenticated caller"""
workspaces: Optional[List[Workspace]]
"""List of workspaces the authenticated caller has access"""
policies: Optional[List[AuthPolicy]]
"""List of policies for the authenticated caller"""
properties: Optional[Dict[str, str]] = Field(None, example={"key1": "value1"})
"""A map of key value properties"""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these fields actually Optional? They should only be optional if it's possible for the JSON response to have null for a property. Now that I'm looking at the rest of the models, it looks like the generator is overly pessimistic and marks every field as optional. Is this something we can configure?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like the Swagger doc has modeled these as optional fields.

https://test-api.lifecyclesolutions.ni.com/niapis/?urls.primaryName=Auth%20Service
https://test-api.lifecyclesolutions.ni.com/niauth/swagger/v1/niauth.yaml

  AuthResponse:
    description: Auth Response
    schema:
      type: object
      title: Auth Response
      properties:
        user:
          $ref: '#/definitions/User'
        org:
          $ref: '#/definitions/Org'
        workspaces:
          type: array
          items:
            $ref: '#/definitions/Workspace'
        policies:
          type: array
          items:
            $ref: '#/definitions/AuthPolicy'
        properties:
          type: object
          description: A map of key value properties
          additionalProperties:
            type: string
          example:
            key1: value1

Comment on lines +16 to +22
def test_webapps(client: WebappClient) -> List[str]:
"""Fixture to return the pre-created WebApp IDs for testing."""
webapp_ids = [
"452bc11b-6a8a-4c3e-8eb1-721270157eb8", # 'PyAPI_Test1' dataspace
"0345a956-3747-42e1-9296-6ed06545bd0d", # 'PyAPI_Test2' dataspace
]
return webapp_ids
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought I had left a comment on this, but I can't seem to find it anymore 😕 These tests should be able to create the fake webapps if they don't exist. We wouldn't want the tests to break if the cluster's data gets wiped. Here's an example fixture from the data frame tests:

def create_table(client: DataFrameClient):

tests/integration/webapp/test_webapp.py Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants