MCPcopy Create free account
hub / github.com/apache/impala / test_user_validation

Method test_user_validation

tests/custom_cluster/test_beeswax.py:26–82  ·  view source on GitHub ↗

Test various scenarios with cross-connection operations with the same and different users.

(self)

Source from the content-addressed store, hash-verified

24class TestBeeswax(CustomClusterTestSuite):
25
26 def test_user_validation(self):
27 """Test various scenarios with cross-connection operations with the same
28 and different users."""
29 USER1 = "user1"
30 USER2 = "user2"
31 client1 = self.create_impala_client(protocol=BEESWAX)
32 different_user_client = None
33 unset_user_client = None
34 try:
35 same_user_client = self.create_impala_client(protocol=BEESWAX)
36 different_user_client = self.create_impala_client(protocol=BEESWAX)
37 unset_user_client = self.create_impala_client(protocol=BEESWAX)
38
39 # Unauthenticated Beewax only sets user once the query is run.
40 result = client1.execute("select effective_user()", user=USER1)
41 assert result.data[0] == USER1
42 result = same_user_client.execute("select effective_user()", user=USER1)
43 assert result.data[0] == USER1
44 # The user shouldn't change once set.
45 result = client1.execute("select effective_user()", user=USER2)
46 assert result.data[0] == USER1
47 result = different_user_client.execute("select effective_user()", user=USER2)
48 assert result.data[0] == USER2
49
50 QUERY = "select * from functional.alltypes"
51 handle = client1.execute_async(QUERY)
52 client1.get_state(handle)
53 # Connections with a effective user should not be able to access other users'
54 # sessions.
55 self._assert_invalid_handle(lambda: different_user_client.fetch(QUERY, handle))
56 self._assert_invalid_handle(lambda: different_user_client.get_state(handle))
57 self._assert_invalid_handle(lambda: different_user_client.get_log(handle))
58 self._assert_profile_access_denied(
59 lambda: different_user_client.get_runtime_profile(handle))
60 self._assert_profile_access_denied(
61 lambda: different_user_client.get_exec_summary(handle))
62 self._assert_invalid_handle(lambda: different_user_client.close_dml(handle))
63
64 # Connections with the same user can always access the requests. A connection
65 # without an effective user (only possible with unauthenticated connections)
66 # is allowed to access any query. Some Impala tests depend on this.
67 for valid_client in [client1, same_user_client, unset_user_client]:
68 valid_client.get_state(handle)
69 valid_client.fetch(QUERY, handle)
70 valid_client.get_log(handle)
71 valid_client.get_runtime_profile(handle)
72 valid_client.get_exec_summary(handle)
73
74 # Validation of user should be skipped for closing and cancelling queries, to
75 # avoid breaking administrative tools that clean up queries via Beeswax RPCs.
76 different_user_client.cancel(handle)
77 different_user_client.close_query(handle)
78 finally:
79 if different_user_client is not None:
80 different_user_client.close()
81 if unset_user_client is not None:
82 unset_user_client.close()
83

Callers

nothing calls this directly

Calls 14

create_impala_clientMethod · 0.80
closeMethod · 0.65
executeMethod · 0.45
execute_asyncMethod · 0.45
get_stateMethod · 0.45
fetchMethod · 0.45
get_logMethod · 0.45
get_runtime_profileMethod · 0.45
get_exec_summaryMethod · 0.45
close_dmlMethod · 0.45

Tested by

no test coverage detected