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/integ tests notifications #1597

Merged
merged 27 commits into from
Dec 23, 2024
Merged

Feat/integ tests notifications #1597

merged 27 commits into from
Dec 23, 2024

Conversation

noah-paige
Copy link
Contributor

Feature or Bugfix

  • Feature

Detail

  • Integration Tests Notifications

Relates

Security

Please answer the questions below briefly where applicable, or write N/A. Based on
OWASP 10.

  • Does this PR introduce or modify any input fields or queries - this includes
    fetching data from storage outside the application (e.g. a database, an S3 bucket)?
    • Is the input sanitized?
    • What precautions are you taking before deserializing the data you consume?
    • Is injection prevented by parametrizing queries?
    • Have you ensured no eval or similar functions are used?
  • Does this PR introduce any functionality or component that requires authorization?
    • How have you ensured it respects the existing AuthN/AuthZ mechanisms?
    • Are you logging failed auth attempts?
  • Are you using or adding any cryptographic features?
    • Do you use a standard proven implementations?
    • Are the used keys controlled by the customer? Where are they stored?
  • Are you introducing any new policies/roles/users?
    • Have you used the least-privilege principle? How?

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@dlpzx dlpzx self-requested a review October 1, 2024 07:31
Copy link
Contributor

@dlpzx dlpzx left a comment

Choose a reason for hiding this comment

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

The part of notifications is fine, I am not approving because of the changes in shares; which I am not sure how they interact with other shares tests

@noah-paige
Copy link
Contributor Author

noah-paige commented Oct 4, 2024

The part of notifications is fine, I am not approving because of the changes in shares; which I am not sure how they interact with other shares tests

Is there another PR for shares that I should wait for on shares before testing once more that all shares tests + notification tests work in tandem? @dlpzx

Comment on lines 29 to 38
context = get_context()
with context.db_engine.scoped_session() as session:
notification = session.query(models.Notification).get(uri)
if notification and (notification.recipient in context.groups + [context.username]):
return f(*args, **kwds)
else:
raise exceptions.UnauthorizedOperation(
action='UPDATE NOTIFICATION',
message=f'User {context.username} is not the recipient user/group of the notification {uri}',
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Would you mind moving the check logic in a standalone static method so that we are able to mock/spy it from the tests? See here can_perform is the decorator and is_owner the implementation.

The reason we cannot mock it like that is that decorators are applied at module load time and we patch much later.
So to workaround it we would have to patch before we import the modules which works but is very strange.

Copy link
Contributor

@petrkalos petrkalos left a comment

Choose a reason for hiding this comment

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

could you split is_receipient decorator and implementation?

logger = logging.getLogger(__name__)


def _session():
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 _session is no longer used

Copy link
Contributor

@dlpzx dlpzx left a comment

Choose a reason for hiding this comment

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

Left one minor comment, otherwise good to go!

@dlpzx dlpzx merged commit 563d2e3 into main Dec 23, 2024
9 checks passed
dlpzx pushed a commit that referenced this pull request Dec 24, 2024
### Feature or Bugfix
<!-- please choose -->
- Bugfix

### Detail
- Change path to `global_conftest` for shares integ tests


### Relates
- #1597 

### Security
Please answer the questions below briefly where applicable, or write
`N/A`. Based on
[OWASP 10](https://owasp.org/Top10/en/).

- Does this PR introduce or modify any input fields or queries - this
includes
fetching data from storage outside the application (e.g. a database, an
S3 bucket)?
  - Is the input sanitized?
- What precautions are you taking before deserializing the data you
consume?
  - Is injection prevented by parametrizing queries?
  - Have you ensured no `eval` or similar functions are used?
- Does this PR introduce any functionality or component that requires
authorization?
- How have you ensured it respects the existing AuthN/AuthZ mechanisms?
  - Are you logging failed auth attempts?
- Are you using or adding any cryptographic features?
  - Do you use a standard proven implementations?
  - Are the used keys controlled by the customer? Where are they stored?
- Are you introducing any new policies/roles/users?
  - Have you used the least-privilege principle? How?


By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license.
dlpzx added a commit that referenced this pull request Dec 26, 2024
### Feature or Bugfix
<!-- please choose -->
- Feature

### Detail
- Integration Tests Notifications


### Relates
- #1220

### Security
Please answer the questions below briefly where applicable, or write
`N/A`. Based on
[OWASP 10](https://owasp.org/Top10/en/).

- Does this PR introduce or modify any input fields or queries - this
includes
fetching data from storage outside the application (e.g. a database, an
S3 bucket)?
  - Is the input sanitized?
- What precautions are you taking before deserializing the data you
consume?
  - Is injection prevented by parametrizing queries?
  - Have you ensured no `eval` or similar functions are used?
- Does this PR introduce any functionality or component that requires
authorization?
- How have you ensured it respects the existing AuthN/AuthZ mechanisms?
  - Are you logging failed auth attempts?
- Are you using or adding any cryptographic features?
  - Do you use a standard proven implementations?
  - Are the used keys controlled by the customer? Where are they stored?
- Are you introducing any new policies/roles/users?
  - Have you used the least-privilege principle? How?


By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license.

---------

Co-authored-by: Sofia Sazonova <[email protected]>
Co-authored-by: dlpzx <[email protected]>
dlpzx pushed a commit that referenced this pull request Dec 26, 2024
### Feature or Bugfix
<!-- please choose -->
- Bugfix

### Detail
- Change path to `global_conftest` for shares integ tests


### Relates
- #1597 

### Security
Please answer the questions below briefly where applicable, or write
`N/A`. Based on
[OWASP 10](https://owasp.org/Top10/en/).

- Does this PR introduce or modify any input fields or queries - this
includes
fetching data from storage outside the application (e.g. a database, an
S3 bucket)?
  - Is the input sanitized?
- What precautions are you taking before deserializing the data you
consume?
  - Is injection prevented by parametrizing queries?
  - Have you ensured no `eval` or similar functions are used?
- Does this PR introduce any functionality or component that requires
authorization?
- How have you ensured it respects the existing AuthN/AuthZ mechanisms?
  - Are you logging failed auth attempts?
- Are you using or adding any cryptographic features?
  - Do you use a standard proven implementations?
  - Are the used keys controlled by the customer? Where are they stored?
- Are you introducing any new policies/roles/users?
  - Have you used the least-privilege principle? How?


By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license.
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.

3 participants