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

Blueprints: Support nested custom tags in !Find and !Format tags #4127

Merged

Conversation

sdimovv
Copy link
Contributor

@sdimovv sdimovv commented Nov 30, 2022

Details

  • Does this resolve an issue?
    N/A

Changes

New Features

  • Adds support for nested custom tags to the !Find and !Format tags.
    This allows usages like these:
version: 1
context:
  flow_property: slug
  flow_property_value: my-flow
  stage_suffix: my-stage
entries:
- model: authentik_stages_password.passwordstage
  identifiers:
    name: !Format [prefixed-%s, !Context stage_suffix]
  attrs:
    configure_flow: !Find [authentik_flows.flow, [!Context flow_property, !Context flow_property_value]]

Breaking Changes

N/A

Additional

Incidentally, this also fixed a bug in the !Format tag, which was previously taking the name of the context variable of a !Context tag, rather than resolving the tag and taking its value. The test for this functionality was also broken.

You can see the test here:

def test_import_yaml_tags(self):
"""Test some yaml tags"""
ExpressionPolicy.objects.filter(name="foo-foo-bar").delete()
importer = Importer(load_yaml_fixture("fixtures/tags.yaml"), {"bar": "baz"})
self.assertTrue(importer.validate()[0])
self.assertTrue(importer.apply())
self.assertTrue(ExpressionPolicy.objects.filter(name="foo-foo-bar"))

And the fixture here:

version: 1
context:
foo: bar
entries:
- attrs:
expression: return True
identifiers:
name: !Format [foo-%s-%s, !Context foo, !Context bar]
id: default-source-enrollment-if-username
model: authentik_policies_expression.expressionpolicy

The correct name according to the context variables should have been: foo-bar-baz, not foo-foo-bar

@codecov
Copy link

codecov bot commented Nov 30, 2022

Codecov Report

Base: 92.77% // Head: 92.82% // Increases project coverage by +0.06% 🎉

Coverage data is based on head (c05bab5) compared to base (d532943).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4127      +/-   ##
==========================================
+ Coverage   92.77%   92.82%   +0.06%     
==========================================
  Files         474      474              
  Lines       23207    23222      +15     
==========================================
+ Hits        21528    21554      +26     
+ Misses       1679     1668      -11     
Flag Coverage Δ
e2e 53.91% <25.00%> (-0.01%) ⬇️
integration 27.54% <0.00%> (-0.01%) ⬇️
unit 89.39% <100.00%> (+0.06%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
authentik/blueprints/tests/test_v1.py 100.00% <100.00%> (ø)
authentik/blueprints/v1/common.py 96.67% <100.00%> (+5.55%) ⬆️
authentik/blueprints/v1/importer.py 88.05% <0.00%> (+1.09%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@netlify
Copy link

netlify bot commented Nov 30, 2022

Deploy Preview for authentik ready!

Name Link
🔨 Latest commit c05bab5
🔍 Latest deploy log https://app.netlify.com/sites/authentik/deploys/638897c1cf9e810008e2039c
😎 Deploy Preview https://deploy-preview-4127--authentik.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

authentik/blueprints/v1/common.py Show resolved Hide resolved
website/developer-docs/blueprints/v1/tags.md Outdated Show resolved Hide resolved
@BeryJu BeryJu merged commit 1f7d52c into goauthentik:main Dec 1, 2022
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