-
Notifications
You must be signed in to change notification settings - Fork 207
Bug 2074690 - BMO REST API cannot set any DATE-type custom field #2755
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
Open
dklawren
wants to merge
6
commits into
mozilla:master
Choose a base branch
from
dklawren:2074690
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+155
−6
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
cb916c8
Bug 2060932 - Support GitHub-style collapsible sections in comments
suhaibmujahid 9be7224
Merge remote-tracking branch 'upstream/master'
dklawren 279bde1
Merge remote-tracking branch 'upstream/master'
dklawren 38ea5c2
Bug 2074690 - BMO REST API cannot set any DATE-type custom field
dklawren 0054326
Copilot review fixes
dklawren dbfb61a
Review fixes
dklawren File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 characters
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 characters
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 characters
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 characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,120 @@ | ||
| #!/usr/bin/env perl | ||
| # This Source Code Form is subject to the terms of the Mozilla Public | ||
| # License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| # file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
| # | ||
| # This Source Code Form is "Incompatible With Secondary Licenses", as | ||
| # defined by the Mozilla Public License, v. 2.0. | ||
|
|
||
| ##################################################### | ||
| # Test for REST Bug.create() and Bug.update() with # | ||
| # DATE and DATETIME custom fields # | ||
| # POST /rest/bug # | ||
| # PUT /rest/bug/<id> # | ||
| ##################################################### | ||
|
|
||
| # FIELD_TYPE_DATE custom fields must be passed through to the Bug object as | ||
| # YYYY-MM-DD and returned in that same format, so a value read from the API | ||
| # can be sent back unchanged. FIELD_TYPE_DATETIME custom fields must still be | ||
| # converted from and to ISO 8601 by the REST server. See bug 2074690. | ||
|
|
||
| use 5.10.1; | ||
| use strict; | ||
| use warnings; | ||
| use lib qw(lib ../../lib ../../local/lib/perl5); | ||
|
|
||
| use Bugzilla; | ||
| use QA::Util qw(get_config); | ||
| use QA::Tests qw(create_bug_fields); | ||
| use QA::REST::Util qw(api_headers); | ||
|
|
||
| use Test::Mojo; | ||
| use Test::More; | ||
|
|
||
| use constant DATE_FIELD => 'cf_qa_date'; | ||
| use constant DATETIME_FIELD => 'cf_qa_datetime'; | ||
|
|
||
| my $config = get_config(); | ||
| my $api_key = $config->{editbugs_user_api_key}; | ||
| my $url = Bugzilla->localconfig->urlbase; | ||
|
|
||
| my $t = Test::Mojo->new(); | ||
|
|
||
| sub check_bug_dates { | ||
| my ($bug_id, $date, $datetime, $desc) = @_; | ||
| my $fields = join(',', DATE_FIELD, DATETIME_FIELD); | ||
| $t->get_ok( | ||
| $url . "rest/bug/$bug_id?include_fields=$fields" => api_headers($api_key)) | ||
| ->status_is(200) | ||
| ->json_is('/bugs/0/' . DATE_FIELD, $date, | ||
| "$desc: date field has the right value") | ||
| ->json_is('/bugs/0/' . DATETIME_FIELD, $datetime, | ||
| "$desc: datetime field has the right value"); | ||
| } | ||
|
|
||
| ############################### | ||
| # Create with both field types # | ||
| ############################### | ||
|
|
||
| my $new_bug = create_bug_fields($config); | ||
| $new_bug->{+DATE_FIELD} = '2026-01-15'; | ||
| $new_bug->{+DATETIME_FIELD} = '2026-01-15T12:15:00Z'; | ||
|
|
||
| $t->post_ok($url . 'rest/bug' => api_headers($api_key) => json => $new_bug) | ||
| ->status_is(200)->json_has('/id'); | ||
| my $bug_id = $t->tx->res->json->{id}; | ||
|
|
||
| check_bug_dates($bug_id, '2026-01-15', '2026-01-15T12:15:00Z', 'After create'); | ||
|
|
||
| ############################### | ||
| # Update with both field types # | ||
| ############################### | ||
|
|
||
| $t->put_ok($url | ||
| . "rest/bug/$bug_id" => api_headers($api_key) => json => | ||
| {DATE_FIELD, '2026-02-20', DATETIME_FIELD, '2026-02-20T08:45:00Z'}) | ||
| ->status_is(200); | ||
|
|
||
| check_bug_dates($bug_id, '2026-02-20', '2026-02-20T08:45:00Z', 'After update'); | ||
|
|
||
| ############################################# | ||
| # Date fields still reject a time component # | ||
| ############################################# | ||
|
|
||
| $t->put_ok($url | ||
| . "rest/bug/$bug_id" => api_headers($api_key) => json => | ||
| {DATE_FIELD, '2026-03-01 10:00:00'})->status_is(400) | ||
|
Xzzz marked this conversation as resolved.
|
||
| ->json_is('/code' => 56) | ||
| ->json_like('/message' => qr/is not a legal date/); | ||
|
|
||
| check_bug_dates($bug_id, '2026-02-20', '2026-02-20T08:45:00Z', | ||
| 'After rejected update'); | ||
|
|
||
| # ISO 8601 with a time is rejected too. Date fields are returned as plain | ||
| # YYYY-MM-DD, so this is not a value a client would read back from the API. | ||
| $t->put_ok($url | ||
| . "rest/bug/$bug_id" => api_headers($api_key) => json => | ||
| {DATE_FIELD, '2026-03-01T00:00:00Z'})->status_is(400) | ||
| ->json_is('/code' => 56) | ||
| ->json_like('/message' => qr/is not a legal date/); | ||
|
|
||
| check_bug_dates($bug_id, '2026-02-20', '2026-02-20T08:45:00Z', | ||
| 'After rejected ISO 8601 update'); | ||
|
|
||
| ########################################## | ||
| # Read-modify-write round trip is stable # | ||
| ########################################## | ||
|
|
||
| my $read_url = $url . "rest/bug/$bug_id?include_fields=" . DATE_FIELD; | ||
| $t->get_ok($read_url => api_headers($api_key))->status_is(200); | ||
| my $read_back = $t->tx->res->json->{bugs}->[0]->{+DATE_FIELD}; | ||
| ok(defined $read_back, 'Date field value was read back from the API'); | ||
|
|
||
| $t->put_ok($url | ||
| . "rest/bug/$bug_id" => api_headers($api_key) => json => | ||
| {DATE_FIELD, $read_back})->status_is(200); | ||
|
|
||
| check_bug_dates($bug_id, '2026-02-20', '2026-02-20T08:45:00Z', | ||
| 'After writing back the value read from the API'); | ||
|
|
||
| done_testing(); | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.