Last active
May 30, 2025 06:51
-
-
Save cb109/f480e6890b543d4a6614f8776a9b8a9a to your computer and use it in GitHub Desktop.
Revisions
-
cb109 revised this gist
May 30, 2025 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,5 @@ @api_view(("GET",)) @permission_classes(()) def e2e_env_lookup(request): if not is_testrun(): raise PermissionDenied() -
cb109 revised this gist
May 30, 2025 . 2 changed files with 3 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,6 @@ ... if is_testrun(): urlpatterns.extend( [ # This view takes an env_var GET parameter and returns its value from os.environ. This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,8 +1,8 @@ @api_view(("GET",)) @permission_classes((IsAuthenticated,)) def e2e_env_lookup(request): if not is_testrun(): raise PermissionDenied() env_var = request.GET["env_var"] value = os.environ.get(env_var, None) -
cb109 revised this gist
May 28, 2025 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,5 +6,5 @@ def e2e_my_test(db): my_object = ... # Note: We may have to make this URL relative or replace its domain # with live_server.url to avoid running into same-origin constraints # in the browser. Though cypress v12 upwards is fine with that! os.environ["MY_DYNAMIC_URL"] = my_object.url -
cb109 revised this gist
May 28, 2025 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,6 +5,6 @@ def e2e_my_test(db): """We assume this fixture is run before launching the cypress spec using the same name.""" my_object = ... # Note: We may have to make this URL relative or replace its domain # with live_server.url to avoid running into same-origin constraints # in the browser. os.environ["MY_DYNAMIC_URL"] = my_object.url -
cb109 revised this gist
May 28, 2025 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,4 +4,7 @@ def e2e_my_test(db): """We assume this fixture is run before launching the cypress spec using the same name.""" my_object = ... # Note: We may have to make this URL relative or replace its domain # with live_server.url to avoid running into same-origin constraints # in the browser. os.environ["MY_DYNAMIC_URL"] = my_object.url -
cb109 revised this gist
May 28, 2025 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ ... # Enable this view only during test runs. if os.environ["IS_TEST_RUN"]: urlpatterns.extend( [ -
cb109 revised this gist
May 28, 2025 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,5 +2,6 @@ def e2e_my_test(db): """We assume this fixture is run before launching the cypress spec using the same name.""" my_object = ... os.environ["MY_DYNAMIC_URL"] = my_object.url -
cb109 revised this gist
May 28, 2025 . 1 changed file with 9 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,9 @@ @api_view(("GET",)) @permission_classes((IsAuthenticated,)) def e2e_env_lookup(request): if request.user.username != "e2e": raise PermissionDenied("Access allowed only for e2e User") env_var = request.GET["env_var"] value = os.environ.get(env_var, None) return Response(value) -
cb109 revised this gist
May 28, 2025 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,6 +5,6 @@ urlpatterns.extend( [ # This view takes an env_var GET parameter and returns its value from os.environ. re_path(r"^e2e/env$", e2e_env_lookup), ] ) -
cb109 created this gist
May 28, 2025 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,6 @@ import os def e2e_my_test(db): my_object = ... os.environ["MY_DYNAMIC_URL"] = my_object.url This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,15 @@ describe('Test against a dynamic URL', () => { it('should visit the dynamic URL', () => { const envLookupURL = Cypress.env('apiBaseUrl') + 'e2e/env' + '?env_var=MY_DYNAMIC_URL'; cy.request({ method: 'GET', url: envLookupURL, }) .then((response) => { const dynamicURL = response.body; cy.visit(dynamicURL); }); }); }); This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,10 @@ ... # Enable this lookup only during test runs. if os.environ["IS_TEST_RUN"]: urlpatterns.extend( [ # This view takes an env_var GET parameter and returns its value from os.environ. re_path(r"^e2e/env$", client_views.e2e_env_lookup), ] )