diff options
author | Joshua Watt <JPEWhacker@gmail.com> | 2023-11-03 08:26:40 -0600 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2023-11-09 17:33:03 +0000 |
commit | 95481c8668238b291fd693dd8b8589d49850dfd9 (patch) | |
tree | 67655219f2c042d96d9eb3fb78d594483bb59143 /bitbake/lib/hashserv | |
parent | 33cde47e109f65dc27b989cb0194afcccfec9535 (diff) | |
download | poky-95481c8668238b291fd693dd8b8589d49850dfd9.tar.gz |
bitbake: hashserv: server: Add owner if user is logged in
If a user is authenticated with the server, report them as the owner of
a report
(Bitbake rev: a9fd4a45bb6e5ac9832835897f594f3bbf67e1aa)
Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/hashserv')
-rw-r--r-- | bitbake/lib/hashserv/server.py | 3 | ||||
-rw-r--r-- | bitbake/lib/hashserv/tests.py | 9 |
2 files changed, 12 insertions, 0 deletions
diff --git a/bitbake/lib/hashserv/server.py b/bitbake/lib/hashserv/server.py index 439962f782..a86507830e 100644 --- a/bitbake/lib/hashserv/server.py +++ b/bitbake/lib/hashserv/server.py | |||
@@ -475,6 +475,9 @@ class ServerClient(bb.asyncrpc.AsyncServerConnection): | |||
475 | if k in data: | 475 | if k in data: |
476 | outhash_data[k] = data[k] | 476 | outhash_data[k] = data[k] |
477 | 477 | ||
478 | if self.user: | ||
479 | outhash_data["owner"] = self.user.username | ||
480 | |||
478 | # Insert the new entry, unless it already exists | 481 | # Insert the new entry, unless it already exists |
479 | if await self.db.insert_outhash(outhash_data): | 482 | if await self.db.insert_outhash(outhash_data): |
480 | # If this row is new, check if it is equivalent to another | 483 | # If this row is new, check if it is equivalent to another |
diff --git a/bitbake/lib/hashserv/tests.py b/bitbake/lib/hashserv/tests.py index f0be867915..a9e6fdf9ff 100644 --- a/bitbake/lib/hashserv/tests.py +++ b/bitbake/lib/hashserv/tests.py | |||
@@ -828,6 +828,15 @@ class HashEquivalenceCommonTests(object): | |||
828 | for col in columns: | 828 | for col in columns: |
829 | self.client.remove({col: ""}) | 829 | self.client.remove({col: ""}) |
830 | 830 | ||
831 | def test_auth_is_owner(self): | ||
832 | admin_client = self.start_auth_server() | ||
833 | |||
834 | user = self.create_user("test-user", ["@read", "@report"]) | ||
835 | with self.auth_client(user) as client: | ||
836 | taskhash, outhash, unihash = self.create_test_hash(client) | ||
837 | data = client.get_taskhash(self.METHOD, taskhash, True) | ||
838 | self.assertEqual(data["owner"], user["username"]) | ||
839 | |||
831 | 840 | ||
832 | class TestHashEquivalenceClient(HashEquivalenceTestSetup, unittest.TestCase): | 841 | class TestHashEquivalenceClient(HashEquivalenceTestSetup, unittest.TestCase): |
833 | def get_server_addr(self, server_idx): | 842 | def get_server_addr(self, server_idx): |