-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8976 from OpenMined/eelco/codehash
Make code hash specific to user
- Loading branch information
Showing
3 changed files
with
53 additions
and
5 deletions.
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
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 |
---|---|---|
|
@@ -457,3 +457,48 @@ def my_func(): | |
|
||
assert len(ds_client.code.get_all()) == 1 | ||
assert len(ds_client.requests.get_all()) == 1 | ||
|
||
|
||
def test_submit_existing_code_different_user(worker): | ||
root_domain_client = worker.root_client | ||
|
||
root_domain_client.register( | ||
name="data-scientist", | ||
email="[email protected]", | ||
password="0000", | ||
password_verify="0000", | ||
) | ||
ds_client_1 = root_domain_client.login( | ||
email="[email protected]", | ||
password="0000", | ||
) | ||
|
||
root_domain_client.register( | ||
name="data-scientist-2", | ||
email="[email protected]", | ||
password="0000", | ||
password_verify="0000", | ||
) | ||
ds_client_2 = root_domain_client.login( | ||
email="[email protected]", | ||
password="0000", | ||
) | ||
|
||
@sy.syft_function_single_use() | ||
def my_func(): | ||
return 42 | ||
|
||
res_submit = ds_client_1.api.services.code.submit(my_func) | ||
assert isinstance(res_submit, SyftSuccess) | ||
res_resubmit = ds_client_1.api.services.code.submit(my_func) | ||
assert isinstance(res_resubmit, SyftError) | ||
|
||
# Resubmit with different user | ||
res_submit = ds_client_2.api.services.code.submit(my_func) | ||
assert isinstance(res_submit, SyftSuccess) | ||
res_resubmit = ds_client_2.api.services.code.submit(my_func) | ||
assert isinstance(res_resubmit, SyftError) | ||
|
||
assert len(ds_client_1.code.get_all()) == 1 | ||
assert len(ds_client_2.code.get_all()) == 1 | ||
assert len(root_domain_client.code.get_all()) == 2 |