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

archer v2: fixed fetch times and timzone #10247

Merged
merged 9 commits into from
Dec 6, 2020
Merged

Conversation

jochman
Copy link
Contributor

@jochman jochman commented Dec 3, 2020

Status

  • In Progress
  • Ready
  • In Hold - (Reason for hold)

Related Issues

fixes: https://github.com/demisto/etc/issues/30546

Description

Fixed error when comparing DateTime object with different timezones.

Does it break backward compatibility?

  • Yes
    • Further details:
  • No

Must have

  • Tests
  • Documentation

@jochman jochman requested a review from Itay4 December 3, 2020 09:59
@jochman jochman added release-notes-only Indicates that this pull request has ONLY release notes to review for documentation process bug labels Dec 6, 2020
mocker.patch.object(client, 'search_records', return_value=([record], {}))
_, next_fetch = fetch_incidents(client, params, last_fetch)
assert last_fetch < next_fetch
assert next_fetch == datetime(2018, 4, 3, 10, 3, tzinfo=timezone.utc)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

asset occurred

incident, incident_created_time = client.record_to_incident(
INCIDENT_RECORD, 75, 'Date/Time Reported', day_first=False
)
assert incident_created_time.strftime('%Y-%m-%dT%H:%M:%SZ') == '2018-03-26T10:03:00Z'
assert incident['occurred'] == '2018-03-26T10:03:00Z'

@pytest.mark.parametrize('date_time_reported, use_european_time', [
('2018-04-03T10:03:00.000Z', False),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check zulu time with europeantime is true
check true/false statement (11/29).

@@ -57,8 +57,15 @@ def parse_date_to_datetime(date: str, day_first: bool = False) -> datetime:
Returns:
a datetime object
"""
date_order = {'DATE_ORDER': 'DMY' if day_first else 'MDY'}
date_obj = parser(date, settings=date_order)
if 'z' in date.lower(): # For OCCURRED like time stamps
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check is parser getting a timezone

)
_, next_fetch = fetch_incidents(client, params, last_fetch)
assert last_fetch < next_fetch
assert next_fetch == datetime(2020, 3, 18, 10, 30, tzinfo=timezone.utc)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assert occurred time

assert last_fetch < next_fetch
assert next_fetch == datetime(2018, 4, 3, 10, 3, tzinfo=timezone.utc)

def test_two_fetches(self, mocker):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check of not european time, and with date like 29/11.

@@ -7,8 +7,8 @@ This integration was integrated and tested with version xx of RSA Archer v2
3. Click **Add instance** to create and configure a new integration instance.

## Clarifications
The timezone (offset) parameter should be used if the Cortex XSOAR server and Archer's server aren't in the same time zone.
If the Cortex XSOAR server time is 00:00 and the Archer server time is 01:00, the timezone parameter should be -60 (minutes).
The timezone (offset) parameter should be used if the Cortex XSOAR server and Archer's server arn't in the same time zone.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The timezone (offset) parameter should be used if the Cortex XSOAR server and Archer's server arn't in the same time zone.
The timezone (offset) parameter should be used if the Cortex XSOAR server and Archer's server are not in the same time zone.

@jochman jochman merged commit c49eabe into master Dec 6, 2020
@jochman jochman deleted the archverv2-time-fetch-fix branch December 6, 2020 14:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug docs-approved release-notes-only Indicates that this pull request has ONLY release notes to review for documentation process
Projects
None yet
4 participants