public void Test_NotLoggedInSync() { string topicName = "test_topic"; KiiTopic topic = Kii.Topic(topicName); topic.ListAclEntries(); }
public void Test_GroupScopeAsync() { KiiGroup group = Kii.Group("test_group"); group.Save(); group.Topic("group_topic").Save(); CountDownLatch cd = new CountDownLatch(1); IList <KiiACLEntry <KiiTopic, TopicAction> > entries = null; Exception exception = null; KiiTopic topic = group.Topic("group_topic"); topic.ListAclEntries((IList <KiiACLEntry <KiiTopic, TopicAction> > result, Exception e) => { entries = result; exception = e; cd.Signal(); }); if (!cd.Wait(new TimeSpan(0, 0, 0, 20))) { Assert.Fail("Callback not fired."); } Assert.IsNull(exception); Assert.AreEqual(4, entries.Count); }
public void Test_AppScopeSync() { LogIn("test-user-00001"); client.AddResponse(200, RESPONSE_BODY); string topicName = "test_topic"; KiiTopic topic = Kii.Topic(topicName); IList <KiiACLEntry <KiiTopic, TopicAction> > entries = topic.ListAclEntries(); Assert.AreEqual(6, entries.Count); Assert.AreEqual(TopicAction.SEND_MESSAGE_TO_TOPIC, entries [0].Action); Assert.AreEqual("UUUU-5555-6666-7777-8888", ((KiiUser)entries [0].Subject).ID); Assert.AreEqual(TopicAction.SEND_MESSAGE_TO_TOPIC, entries [1].Action); Assert.AreEqual("GGGG-5555-6666-7777-8888", ((KiiGroup)entries[1].Subject).ID); Assert.AreEqual(TopicAction.SUBSCRIBE_TO_TOPIC, entries [2].Action); Assert.AreEqual(KiiAnonymousUser.Get(), entries [2].Subject); Assert.AreEqual(TopicAction.SUBSCRIBE_TO_TOPIC, entries [3].Action); Assert.AreEqual(KiiAnyAuthenticatedUser.Get(), entries [3].Subject); Assert.AreEqual(TopicAction.SUBSCRIBE_TO_TOPIC, entries [4].Action); Assert.AreEqual("UUUU-1111-2222-3333-4444", ((KiiUser)entries [4].Subject).ID); Assert.AreEqual(TopicAction.SUBSCRIBE_TO_TOPIC, entries [5].Action); Assert.AreEqual("GGGG-1111-2222-3333-4444", ((KiiGroup)entries[5].Subject).ID); Assert.AreEqual(KiiHttpMethod.GET, client.RequestMethod [0]); Assert.AreEqual(Utils.Path(Kii.BaseUrl, "apps", Kii.AppId, "topics", topicName, "acl"), client.RequestUrl [0]); }
public void Test_UserScope404ASync() { LogIn("test-user-00001"); client.AddResponse(new NotFoundException("", null, "", NotFoundException.Reason.ACL_NOT_FOUND)); string userID = "test_user"; string topicName = "test_topic"; KiiTopic topic = KiiUser.UserWithID(userID).Topic(topicName); CountDownLatch cd = new CountDownLatch(1); IList <KiiACLEntry <KiiTopic, TopicAction> > entries = null; Exception exception = null; topic.ListAclEntries((IList <KiiACLEntry <KiiTopic, TopicAction> > result, Exception e) => { entries = result; exception = e; cd.Signal(); }); if (!cd.Wait(new TimeSpan(0, 0, 0, 3))) { Assert.Fail("Callback not fired."); } Assert.IsNull(entries); Assert.IsInstanceOfType(typeof(NotFoundException), exception); Assert.AreEqual(KiiHttpMethod.GET, client.RequestMethod [0]); Assert.AreEqual(Utils.Path(Kii.BaseUrl, "apps", Kii.AppId, "users", userID, "topics", topicName, "acl"), client.RequestUrl [0]); }
public void Test_AppScope404Sync() { LogIn("test-user-00001"); client.AddResponse(new NotFoundException("", null, "", NotFoundException.Reason.ACL_NOT_FOUND)); string topicName = "test_topic"; KiiTopic topic = Kii.Topic(topicName); topic.ListAclEntries(); }
public void Test_NotLoggedInASync() { string topicName = "test_topic"; KiiTopic topic = Kii.Topic(topicName); CountDownLatch cd = new CountDownLatch(1); IList <KiiACLEntry <KiiTopic, TopicAction> > entries = null; Exception exception = null; topic.ListAclEntries((IList <KiiACLEntry <KiiTopic, TopicAction> > result, Exception e) => { entries = result; exception = e; cd.Signal(); }); if (!cd.Wait(new TimeSpan(0, 0, 0, 3))) { Assert.Fail("Callback not fired."); } Assert.IsNull(entries); Assert.IsInstanceOfType(typeof(InvalidOperationException), exception); }
public void Test_UserScopeASync() { LogIn("test-user-00001"); client.AddResponse(200, RESPONSE_BODY); string userID = "test_user"; string topicName = "test_topic"; KiiTopic topic = KiiUser.UserWithID(userID).Topic(topicName); CountDownLatch cd = new CountDownLatch(1); IList <KiiACLEntry <KiiTopic, TopicAction> > entries = null; Exception exception = null; topic.ListAclEntries((IList <KiiACLEntry <KiiTopic, TopicAction> > result, Exception e) => { entries = result; exception = e; cd.Signal(); }); if (!cd.Wait(new TimeSpan(0, 0, 0, 3))) { Assert.Fail("Callback not fired."); } Assert.IsNull(exception); Assert.AreEqual(6, entries.Count); Assert.AreEqual(TopicAction.SEND_MESSAGE_TO_TOPIC, entries [0].Action); Assert.AreEqual("UUUU-5555-6666-7777-8888", ((KiiUser)entries [0].Subject).ID); Assert.AreEqual(TopicAction.SEND_MESSAGE_TO_TOPIC, entries [1].Action); Assert.AreEqual("GGGG-5555-6666-7777-8888", ((KiiGroup)entries[1].Subject).ID); Assert.AreEqual(TopicAction.SUBSCRIBE_TO_TOPIC, entries [2].Action); Assert.AreEqual(KiiAnonymousUser.Get(), entries [2].Subject); Assert.AreEqual(TopicAction.SUBSCRIBE_TO_TOPIC, entries [3].Action); Assert.AreEqual(KiiAnyAuthenticatedUser.Get(), entries [3].Subject); Assert.AreEqual(TopicAction.SUBSCRIBE_TO_TOPIC, entries [4].Action); Assert.AreEqual("UUUU-1111-2222-3333-4444", ((KiiUser)entries [4].Subject).ID); Assert.AreEqual(TopicAction.SUBSCRIBE_TO_TOPIC, entries [5].Action); Assert.AreEqual("GGGG-1111-2222-3333-4444", ((KiiGroup)entries[5].Subject).ID); Assert.AreEqual(KiiHttpMethod.GET, client.RequestMethod [0]); Assert.AreEqual(Utils.Path(Kii.BaseUrl, "apps", Kii.AppId, "users", userID, "topics", topicName, "acl"), client.RequestUrl [0]); }