-
Notifications
You must be signed in to change notification settings - Fork 204
SG-35018 Condition auth for Jenkins environment #350
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
Merged
Merged
Changes from 14 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
fa9baa4
Condition auth for Jenkins environment
carlos-villavicencio-adsk 5837e70
Add prints
carlos-villavicencio-adsk de8cb29
Add more debug logic
carlos-villavicencio-adsk f4e51cb
Use session token for Jenkins
carlos-villavicencio-adsk 02f6efd
Add debug info
carlos-villavicencio-adsk b761840
More debug info
carlos-villavicencio-adsk b80a397
Revert f4e51cbbc0b553f4b628073caf31c3e763bad341
carlos-villavicencio-adsk 33bf056
Remove redundant code
carlos-villavicencio-adsk d288086
Revert
carlos-villavicencio-adsk aa6fd15
Unskip old tests. Skip datetime tests for Jenkins.
carlos-villavicencio-adsk 6a2bb5a
Condition test for SG_JENKINS
carlos-villavicencio-adsk 0a86ca4
Improve test
carlos-villavicencio-adsk bacf907
Revert unskip
carlos-villavicencio-adsk 96e34c7
Add durations to pytest
carlos-villavicencio-adsk d16f91b
Address feedback
carlos-villavicencio-adsk e861767
Refactor find_one_await_thumbnail invocation
carlos-villavicencio-adsk 385b012
Remove duplicate line
carlos-villavicencio-adsk 22b3dca
Unskip test
carlos-villavicencio-adsk e1b5d6f
Update .coveragerc
carlos-villavicencio-adsk e811762
Addressing feedback
carlos-villavicencio-adsk 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -820,9 +820,8 @@ def test_summary_values(self): | |
def test_ensure_ascii(self): | ||
'''test_ensure_ascii tests ensure_unicode flag.''' | ||
sg_ascii = shotgun_api3.Shotgun(self.config.server_url, | ||
self.config.script_name, | ||
self.config.api_key, | ||
ensure_ascii=True) | ||
ensure_ascii=True, | ||
**self.auth_args) | ||
|
||
result = sg_ascii.find_one('Note', [['id', 'is', self.note['id']]], fields=['content']) | ||
if six.PY2: | ||
|
@@ -832,9 +831,8 @@ def test_ensure_ascii(self): | |
def test_ensure_unicode(self): | ||
'''test_ensure_unicode tests ensure_unicode flag.''' | ||
sg_unicode = shotgun_api3.Shotgun(self.config.server_url, | ||
self.config.script_name, | ||
self.config.api_key, | ||
ensure_ascii=False) | ||
ensure_ascii=False, | ||
**self.auth_args) | ||
result = sg_unicode.find_one('Note', [['id', 'is', self.note['id']]], fields=['content']) | ||
self.assertTrue(_has_unicode(result)) | ||
|
||
|
@@ -907,11 +905,8 @@ def test_work_schedule(self): | |
work_schedule['2012-01-04'] = {"reason": "USER_EXCEPTION", "working": False, "description": "Artist Holiday"} | ||
self.assertEqual(work_schedule, resp) | ||
|
||
# For now disable tests that are erroneously failling on some sites to | ||
# allow CI to pass until the known issue causing this is resolved. | ||
# test_preferences_read fails when preferences don't match the expected | ||
# preferences. | ||
@base.skip("Skip test_preferences_read because preferences on test sites are mismatched.") | ||
def test_preferences_read(self): | ||
# Only run the tests on a server with the feature. | ||
if not self.sg.server_caps.version or self.sg.server_caps.version < (7, 10, 0): | ||
|
@@ -936,8 +931,9 @@ def test_preferences_read(self): | |
'format_number_fields': '1,000', | ||
'format_time_hour_fields': '12 hour', | ||
'hours_per_day': 8.0, | ||
'last_day_work_week': None, | ||
'support_local_storage': True | ||
'support_local_storage': True, | ||
'enable_rv_integration': True, | ||
'enable_shotgun_review_for_rv': False, | ||
} | ||
# Simply make sure viewmaster settings are there. These change frequently and we | ||
# don't want to have the test break because Viewmaster changed or because we didn't | ||
|
@@ -1010,6 +1006,8 @@ def test_set_date(self): | |
self.assertEqual(expected, actual) | ||
|
||
def test_set_date_time(self): | ||
if self.config.jenkins: | ||
self.skipTest("Skipping test on Jenkins. locked_until not updating.") | ||
entity = 'HumanUser' | ||
entity_id = self.human_user['id'] | ||
field_name = 'locked_until' | ||
|
@@ -1069,8 +1067,7 @@ def test_set_list(self): | |
|
||
def test_set_multi_entity(self): | ||
sg = shotgun_api3.Shotgun(self.config.server_url, | ||
self.config.script_name, | ||
self.config.api_key) | ||
**self.auth_args) | ||
keys = ['project', 'user', 'code'] | ||
data = {'project': self.project, | ||
'user': self.human_user, | ||
|
@@ -1204,20 +1201,22 @@ def setUp(self): | |
self.datetime_none = datetime.datetime(2008, 10, 13, 23, 10) | ||
|
||
def test_convert_to_utc(self): | ||
if self.config.jenkins: | ||
self.skipTest("Skipping test on Jenkins. locked_until not updating.") | ||
sg_utc = shotgun_api3.Shotgun(self.config.server_url, | ||
self.config.script_name, | ||
self.config.api_key, | ||
http_proxy=self.config.http_proxy, | ||
convert_datetimes_to_utc=True) | ||
convert_datetimes_to_utc=True, | ||
**self.auth_args) | ||
self._assert_expected(sg_utc, self.datetime_none, self.datetime_local) | ||
self._assert_expected(sg_utc, self.datetime_local, self.datetime_local) | ||
|
||
def test_no_convert_to_utc(self): | ||
if self.config.jenkins: | ||
self.skipTest("Skipping test on Jenkins. locked_until not updating.") | ||
sg_no_utc = shotgun_api3.Shotgun(self.config.server_url, | ||
self.config.script_name, | ||
self.config.api_key, | ||
http_proxy=self.config.http_proxy, | ||
convert_datetimes_to_utc=False) | ||
convert_datetimes_to_utc=False, | ||
**self.auth_args) | ||
self._assert_expected(sg_no_utc, self.datetime_none, self.datetime_none) | ||
self._assert_expected(sg_no_utc, self.datetime_utc, self.datetime_none) | ||
|
||
|
@@ -1853,6 +1852,10 @@ def test_following(self): | |
|
||
|
||
class TestErrors(base.TestBase): | ||
def setUp(self): | ||
auth_mode = "HumanUser" if self.config.jenkins else "ApiUser" | ||
super(TestErrors, self).setUp(auth_mode) | ||
julien-lang marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
def test_bad_auth(self): | ||
'''test_bad_auth invalid script name or api key raises fault''' | ||
server_url = self.config.server_url | ||
|
@@ -2079,7 +2082,7 @@ def test_sanitized_auth_params(self, mock_open): | |
# Try to upload a bogus file | ||
self.sg.upload('Note', 1234, thumbnail_path) | ||
except shotgun_api3.ShotgunError as e: | ||
self.assertFalse(self.api_key in str(e)) | ||
self.assertFalse(str(self.api_key) in str(e)) | ||
return | ||
|
||
# You should never get here... Otherwise some mocking failed and the | ||
|
@@ -2114,7 +2117,7 @@ def test_upload_missing_file(self): | |
|
||
class TestScriptUserSudoAuth(base.LiveTestBase): | ||
def setUp(self): | ||
super(TestScriptUserSudoAuth, self).setUp('ApiUser') | ||
super(TestScriptUserSudoAuth, self).setUp() | ||
|
||
self.sg.update( | ||
'HumanUser', | ||
|
@@ -2131,10 +2134,9 @@ def test_user_is_creator(self): | |
return | ||
|
||
x = shotgun_api3.Shotgun(self.config.server_url, | ||
self.config.script_name, | ||
self.config.api_key, | ||
http_proxy=self.config.http_proxy, | ||
sudo_as_login=self.config.human_login) | ||
sudo_as_login=self.config.human_login, | ||
**self.auth_args) | ||
|
||
data = { | ||
'project': self.project, | ||
|
@@ -2161,6 +2163,8 @@ def test_human_user_sudo_auth_fails(self): | |
Test 'sudo_as_login' option for HumanUser. | ||
Request fails on server because user has no permission to Sudo. | ||
""" | ||
if self.config.jenkins: | ||
self.skipTest("Skipping test on Jenkins. locked_until not updating.") | ||
|
||
if not self.sg.server_caps.version or self.sg.server_caps.version < (5, 3, 12): | ||
return | ||
|
@@ -2169,7 +2173,7 @@ def test_human_user_sudo_auth_fails(self): | |
login=self.config.human_login, | ||
password=self.config.human_password, | ||
http_proxy=self.config.http_proxy, | ||
sudo_as_login="blah") | ||
sudo_as_login="[email protected]") | ||
julien-lang marked this conversation as resolved.
Show resolved
Hide resolved
|
||
self.assertRaises(shotgun_api3.Fault, x.find_one, 'Shot', []) | ||
expected = "The user does not have permission to 'sudo':" | ||
try: | ||
|
@@ -2340,10 +2344,9 @@ def test_sudo_as_user(self): | |
return | ||
|
||
sg = shotgun_api3.Shotgun(self.config.server_url, | ||
self.config.script_name, | ||
self.config.api_key, | ||
http_proxy=self.config.http_proxy, | ||
sudo_as_login=self.config.human_login) | ||
sudo_as_login=self.config.human_login, | ||
**self.auth_args) | ||
|
||
initial = sg.find_one('Project', [['id', 'is', self.project['id']]], ['last_accessed_by_current_user']) | ||
time.sleep(1) | ||
|
@@ -2490,6 +2493,10 @@ def _check_note(self, data, note_id, additional_fields): | |
note_data = self.sg.find_one("Note", | ||
[["id", "is", note_id]], | ||
list(expected_fields)) | ||
# remove images before comparison | ||
if "created_by.HumanUser.image" in note_data: | ||
note_data.pop("created_by.HumanUser.image") | ||
data.pop("created_by.HumanUser.image") | ||
self.assertEqual(note_data, data) | ||
|
||
def _check_reply(self, data, reply_id, additional_fields): | ||
|
@@ -2520,6 +2527,10 @@ def _check_attachment(self, data, attachment_id, additional_fields): | |
[["id", "is", attachment_id]], | ||
list(expected_fields)) | ||
|
||
# remove images before comparison | ||
if "this_file" in attachment_data: | ||
attachment_data["this_file"].pop("url") | ||
data["this_file"].pop("url") | ||
eduardoChaucaGallegos marked this conversation as resolved.
Show resolved
Hide resolved
|
||
self.assertEqual(attachment_data, data) | ||
|
||
# For now skip tests that are erroneously failling on some sites to | ||
|
@@ -2531,6 +2542,10 @@ def test_simple(self): | |
""" | ||
if not self.sg.server_caps.version or self.sg.server_caps.version < (6, 2, 0): | ||
return | ||
|
||
user_entity = "ApiUser" | ||
if self.config.jenkins: | ||
user_entity = "HumanUser" | ||
carlos-villavicencio-adsk marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
# create note | ||
note = self.sg.create("Note", {"content": "Test!", "project": self.project}) | ||
|
@@ -2542,21 +2557,21 @@ def test_simple(self): | |
|
||
d = self.sg.find_one("Note", | ||
[["id", "is", note["id"]]], | ||
["created_by", "created_by.ApiUser.image"]) | ||
["created_by", f"created_by.{user_entity}.image"]) | ||
|
||
current_thumbnail = d["created_by.ApiUser.image"] | ||
current_thumbnail = d[f"created_by.{user_entity}.image"] | ||
|
||
if current_thumbnail is None: | ||
# upload thumbnail | ||
self.sg.upload_thumbnail("ApiUser", | ||
self.sg.upload_thumbnail(user_entity, | ||
d["created_by"]["id"], | ||
self._thumbnail_path) | ||
|
||
d = self.sg.find_one("Note", | ||
[["id", "is", note["id"]]], | ||
["created_by", "created_by.ApiUser.image"]) | ||
["created_by", f"created_by.{user_entity}.image"]) | ||
|
||
current_thumbnail = d["created_by.ApiUser.image"] | ||
current_thumbnail = d[f"created_by.{user_entity}.image"] | ||
|
||
# get thread | ||
result = self.sg.note_thread_read(note["id"]) | ||
|
@@ -3025,7 +3040,11 @@ def _get_path(url): | |
def find_one_await_thumbnail(sg, entity_type, filters, fields=["image"], thumbnail_field_name="image", **kwargs): | ||
attempts = 0 | ||
result = sg.find_one(entity_type, filters, fields=fields, **kwargs) | ||
while attempts < THUMBNAIL_MAX_ATTEMPTS and TRANSIENT_IMAGE_PATH in result.get(thumbnail_field_name): | ||
while ( | ||
attempts < THUMBNAIL_MAX_ATTEMPTS | ||
and result[thumbnail_field_name] | ||
and TRANSIENT_IMAGE_PATH in result[thumbnail_field_name] | ||
): | ||
time.sleep(THUMBNAIL_RETRY_INTERAL) | ||
result = sg.find_one(entity_type, filters, fields=fields, **kwargs) | ||
attempts += 1 | ||
|
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
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.