예제 #1
0
    def test_token_auth(self):
        cluster = self.create_cluster(
            self.rc, self.configure_cluster(self.hazelcast_token_xml))
        cluster.start_member()

        token_provider = BasicTokenProvider("Hazelcast")
        client = HazelcastClient(cluster_name=cluster.id,
                                 token_provider=token_provider)
        self.assertTrue(client.lifecycle_service.is_running())
        client.shutdown()
예제 #2
0
 def test_auth_fromdict(self):
     tp = BasicTokenProvider("tok")
     cfg = _Config().from_dict({
         "creds_username": "******",
         "creds_password": "******",
         "token_provider": tp,
     })
     self.assertEqual("user", cfg.creds_username)
     self.assertEqual("pass", cfg.creds_password)
     self.assertEqual(tp, cfg.token_provider)
예제 #3
0
#     <client-permissions>
#         <map-permission name="auth-map" principal="*">
#             <actions>
#                 <action>create</action>
#                 <action>destroy</action>
#                 <action>put</action>
#                 <action>read</action>
#             </actions>
#         </map-permission>
#     </client-permissions>
#     <member-authentication realm="tokenRealm"/>
#     <realms>
#         <realm name="tokenRealm">
#              <identity>
#                 <token>s3crEt</token>
#             </identity>
#         </realm>
#     </realms>
# </security>

# Start a new Hazelcast client with the given token provider.
token_provider = BasicTokenProvider("s3crEt")
client = hazelcast.HazelcastClient(token_provider=token_provider)

hz_map = client.get_map("auth-map").blocking()
hz_map.put("key", "value")

print(hz_map.get("key"))

client.shutdown()
예제 #4
0
 def test_empty(self):
     p = BasicTokenProvider()
     self.assertEqual(b"", p.token())
예제 #5
0
 def test_invalid_type(self):
     self.assertRaises(TypeError, lambda: BasicTokenProvider(123456))
예제 #6
0
 def test_bytes(self):
     p = BasicTokenProvider("Hazelcast".encode("utf-8"))
     self.assertEqual(b"Hazelcast", p.token())
예제 #7
0
 def test_string(self):
     p = BasicTokenProvider("Hazelcast")
     self.assertEqual(b"Hazelcast", p.token())