public void null_presence_data_throw_Exception() { string channelName = "my-channel"; string socketId = "some_socket_id"; _pusher.Authenticate(channelName, socketId, null); }
public void the_auth_response_is_valid() { string channelName = "my-channel"; string socketId = "123.456"; string expectedAuthString = Config.AppKey + ":" + CreateSignedString(channelName, socketId); IAuthenticationData result = _pusher.Authenticate(channelName, socketId); Assert.AreEqual(expectedAuthString, result.auth); }
public void the_auth_response_is_valid() { string channelName = "my-channel"; string socketId = "some_socket_id"; var serializer = new JsonSerializer(); PresenceChannelData data = new PresenceChannelData() { user_id = "unique_user_id", user_info = new { twitter_id = "@leggetter" } }; string presenceJSON = serializer.Serialize(data); string expectedAuthString = Config.AppKey + ":" + CreateSignedString(channelName, socketId, presenceJSON); IAuthenticationData result = _pusher.Authenticate(channelName, socketId, data); Assert.AreEqual(expectedAuthString, result.auth); }
public JsonResult AuthForChannel(string channel_name, string socket_id) { if (_session.CurrentUser == null) { return(Json(new ErrorMessage { Status = HttpStatusCode.BadRequest, Message = ErrorMessages.UserNotLogged })); } int groupId; try { groupId = int.Parse(channel_name.Replace(AppSettings.PartialGroupName, "")); } catch (FormatException e) { return(Json(new { Content = e.Message })); } var isInChannel = _db.UserGroups.Count(gb => gb.GroupId == groupId && gb.UserId == _session.CurrentUser.ID); if (isInChannel <= 0) { return(Json(new ErrorMessage { Status = HttpStatusCode.BadRequest, Message = ErrorMessages.ForbiddenError })); } var auth = _pusher.Authenticate(channel_name, socket_id); return(Json(auth)); }