-
Notifications
You must be signed in to change notification settings - Fork 429
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Feature id in mv-option request is undefined (#2751)
- Loading branch information
1 parent
9b4fdd0
commit 3c3b1d7
Showing
3 changed files
with
75 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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 characters
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,12 @@ | |
from django.urls import reverse | ||
from pytest_lazyfixture import lazy_fixture | ||
from rest_framework import status | ||
from rest_framework.test import APIClient | ||
|
||
from features.models import Feature | ||
from organisations.models import Organisation | ||
from projects.models import Project | ||
from users.models import FFAdminUser | ||
|
||
|
||
@pytest.mark.parametrize( | ||
|
@@ -34,6 +40,68 @@ def test_can_create_mv_option(client, project, mv_option_50_percent, feature): | |
assert set(data.items()).issubset(set(response.json().items())) | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"client, feature_id", | ||
[ | ||
(lazy_fixture("admin_client"), "undefined"), | ||
(lazy_fixture("admin_client"), "89809"), | ||
], | ||
) | ||
def test_cannot_create_mv_option_when_feature_id_invalid(client, feature_id, project): | ||
# Given | ||
url = reverse( | ||
"api-v1:projects:feature-mv-options-list", | ||
args=[project, feature_id], | ||
) | ||
|
||
data = { | ||
"type": "unicode", | ||
"feature": feature_id, | ||
"string_value": "bigger", | ||
"default_percentage_allocation": 50, | ||
} | ||
# When | ||
response = client.post( | ||
url, | ||
data=json.dumps(data), | ||
content_type="application/json", | ||
) | ||
# Then | ||
assert response.status_code == status.HTTP_404_NOT_FOUND | ||
|
||
|
||
def test_cannot_create_mv_option_when_user_is_not_owner_of_the_feature(project): | ||
# Given | ||
new_user = FFAdminUser.objects.create(email="[email protected]") | ||
organisation = Organisation.objects.create(name="Test Org") | ||
new_project = Project.objects.create(name="Test project", organisation=organisation) | ||
feature = Feature.objects.create( | ||
name="New_feature", | ||
project=new_project, | ||
) | ||
url = reverse( | ||
"api-v1:projects:feature-mv-options-list", | ||
args=[project, feature.id], | ||
) | ||
|
||
data = { | ||
"type": "unicode", | ||
"feature": feature.id, | ||
"string_value": "bigger", | ||
"default_percentage_allocation": 50, | ||
} | ||
client = APIClient() | ||
client.force_authenticate(user=new_user) | ||
# When | ||
response = client.post( | ||
url, | ||
data=json.dumps(data), | ||
content_type="application/json", | ||
) | ||
# Then | ||
assert response.status_code == status.HTTP_403_FORBIDDEN | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"client", | ||
[lazy_fixture("admin_master_api_key_client"), lazy_fixture("admin_client")], | ||
|
This file contains 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 characters
3c3b1d7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
flagsmith-frontend-preview – ./frontend
flagsmith-frontend-preview-flagsmith.vercel.app
flagsmith-frontend-production-native.vercel.app
flagsmith-frontend-preview-git-main-flagsmith.vercel.app
3c3b1d7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
docs – ./docs
docs-flagsmith.vercel.app
docs-git-main-flagsmith.vercel.app
docs.bullet-train.io
docs.flagsmith.com
3c3b1d7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
flagsmith-frontend-staging – ./frontend
flagsmith-staging-frontend.vercel.app
flagsmith-frontend-staging-flagsmith.vercel.app
flagsmith-frontend-staging-git-main-flagsmith.vercel.app
staging.flagsmith.com