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

in POST v2/subscriptions if expires has invalid date the subscription is created #2303

Closed
iariasleon opened this issue Jun 17, 2016 · 12 comments
Assignees
Labels
Milestone

Comments

@iariasleon
Copy link
Contributor

in POST v2/subscriptions if expires has invalid date the subscription is created

dataset

      | expires                  |
      |--------------------------|
      | 2016-04-05T14:10:0x.00Z  |
      | 2016-04-05T14:10:00,00Z  |
      | 2016-04-05T14:10:00.h00Z |
      | 2016-04-05T14:10:00.0h0Z |
      | 2016-04-05T14:10:00.,00L |

subscription request

url: POST http://localhost:1026/v2/subscriptions
headers:
    Content-Type: application/json
    Fiware-Service: test_csub_expires
    Fiware-ServicePath: /test
payload: {"notification": {"http": {"url": "http://localhost:1234"}, "attrs": ["temperature"]}, "expires": "2016-04-05T14:10:00.,00L", "description": "my first subscription", "subject": {"entities": [{"idPattern": ".*", "type": "room"}], "condition": {"attrs": ["temperature_0", "temperature_1", "temperature_2"]}}}

subscription response

http code: 201 - Created
headers:
   date: Fri, 17 Jun 2016 14:09:55 GMT
   fiware-correlator: 2aba5c08-3495-11e6-9bff-005056a20feb
   connection: Keep-Alive
   content-length: 0
   location: /v2/subscriptions/576404b337f587249daaba45
payload:

expected response

http code: 400 - Bad Request
payload: {"error":"BadRequest","description":"expires has an invalid format"}
@iariasleon
Copy link
Contributor Author

Re-tested in CB version and it issue still fails, it returns 201-Created

  "version" : "1.2.0-next",
  "git_hash" : "d81dcf28e71d8d63dc0929ef7a6b73d7db47421b"

@kzangeli kzangeli self-assigned this Sep 21, 2016
@kzangeli
Copy link
Member

I looked into this issue a little and found the following solution (detecting trailing garbage in the date string):

p = strptime(s.c_str(), " %Y-%m-%dT%T", &tm);
if (p == NULL)
{
  return -1;
}
else if (*p != 0)  // trailing garbage
{
  return -1;
}

This fix (the addition is the else part) works just fine, however, in many many of our functests we use dates with the following format:

2016-04-05T14:10:00:00.00Z

The fix receives .00Z as trailing garbage and the functest fails. Many many functests.

Now, what do we do with this?
Change all functests?
Accept .00Z as 'good garbage' :-) ?

@fgalan
Copy link
Member

fgalan commented Sep 22, 2016

I haven read in deep last comment, sorry... My only concern here if is changing the way we deal with dates could break (or "make it worse" if already broken :) our support to ISO8601

@fgalan
Copy link
Member

fgalan commented Jan 16, 2017

Take into account that rencelty (1.6.0, Nov 2016) we implemented the following functionality:

Take that into account (in particular, the PRs linked from these issues) in order to fix this issue.

In addition, the issue #2718 seems to be very related with this.

@kzangeli
Copy link
Member

This issue seems to have been fixed.
Functest added in PR #2814

@kzangeli kzangeli assigned iariasleon and unassigned kzangeli Jan 16, 2017
@fgalan fgalan modified the milestones: 1.6.0, 1.7.0 Jan 16, 2017
@iariasleon
Copy link
Contributor Author

Re-tested with:

"version" : "1.6.0-next",
  "git_hash" : "4bbe1edfcc8a5cbd3a91bc05a07d6671d089f2f2"

And all cases are OK, except the first case in the dataset:

url: POST http://localhost:1026/v2/subscriptions
headers:
    Content-Type: application/json
    Fiware-Service: test_csub_expires
    Fiware-ServicePath: /test
payload: {"notification": {"http": {"url": "http://localhost:1234"}, "attrs": ["temperature"]}, "expires": "2016-04-05T14:10:0x.00Z", "description": "my first subscription", "subject": {"entities": [{"idPattern": ".*", "type": "room"}], "condition": {"attrs": ["temperature_0", "temperature_1", "temperature_2"]}}}


 ----------------- Response ---------------------------------
http code: 201 - Created
headers:
   Connection: Keep-Alive
   Content-Length: 0
   Location: /v2/subscriptions/587c9b59c3373ce3dfe91fe3
   Fiware-Correlator: 922c8e3e-dbd3-11e6-9fd2-005056a20feb
   Date: Mon, 16 Jan 2017 10:07:21 GMT
payload:

@fgalan
Copy link
Member

fgalan commented Jan 16, 2017

(As the issue is still open, then it seems I incorrectly put it in the 1.6.0 milestone. Moved back to NGSIv2SubscriptionValidation milestone)

@fgalan
Copy link
Member

fgalan commented Jan 16, 2017

Related to #2718

@fgalan fgalan assigned fgalan and unassigned iariasleon Jan 18, 2017
@fgalan
Copy link
Member

fgalan commented Jan 18, 2017

(feedback required from @fgalan)

@ArqamFarooqui110719
Copy link
Contributor

ArqamFarooqui110719 commented Jun 7, 2024

I think this issue also can be closed. similar to issue #4541
@fgalan what is your opinion.

@fgalan
Copy link
Member

fgalan commented Jun 7, 2024

@ArqamFarooqui110719 maybe you could do a PR including a .test covering the cases:

      | expires                  |
      |--------------------------|
      | 2016-04-05T14:10:0x.00Z  |
      | 2016-04-05T14:10:00,00Z  |
      | 2016-04-05T14:10:00.h00Z |
      | 2016-04-05T14:10:00.0h0Z |
      | 2016-04-05T14:10:00.,00L |

That way we strengthen our test base and check that issue is actually solved.

@fgalan
Copy link
Member

fgalan commented Aug 29, 2024

Fixed by PR #4584

@fgalan fgalan closed this as completed Aug 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants