public void TestBuildGetChannelsPushRequestCommon(bool ssl, string authKey, string pushToken, PNPushType pushType, bool sendQueryParams)
        {
            string uuid = "customuuid";
            Dictionary <string, string> queryParams = new Dictionary <string, string>();
            string queryParamString = "";

            if (sendQueryParams)
            {
                queryParams.Add("d", "f");
                queryParamString = "&d=f";
            }
            else
            {
                queryParams = null;
            }
            PNConfiguration pnConfiguration = new PNConfiguration();

            pnConfiguration.Origin           = EditorCommon.Origin;
            pnConfiguration.SubscribeKey     = EditorCommon.SubscribeKey;
            pnConfiguration.PublishKey       = EditorCommon.PublishKey;
            pnConfiguration.Secure           = ssl;
            pnConfiguration.CipherKey        = "enigma";
            pnConfiguration.LogVerbosity     = PNLogVerbosity.BODY;
            pnConfiguration.PresenceTimeout  = 60;
            pnConfiguration.PresenceInterval = 30;
            pnConfiguration.UUID             = uuid;
            pnConfiguration.AuthKey          = authKey;

            PubNubUnity pnUnity = new PubNubUnity(pnConfiguration, null, null);

            string authKeyString = "";

            if (!string.IsNullOrEmpty(authKey))
            {
                authKeyString = string.Format("&auth={0}", pnConfiguration.AuthKey);
            }

            Uri uri = BuildRequests.BuildGetChannelsPushRequest(pushType, pushToken, pnUnity, queryParams);

            //[1, "Modified Channels"]
            //["push_channel"]
            //https://ps.pndsn.com/v1/push/sub-key/demo-36/devices/pushToken?type=wns&uuid=customuuid&auth=authKey&pnsdk=PubNub-CSharp-UnityIOS/3.6.9.0
            //https://ps.pndsn.com/v1/push/sub-key/demo-36/devices/pushToken?type=mpns&uuid=customuuid&auth=authKey&pnsdk=PubNub-CSharp-UnityIOS/3.6.9.0
            string expected = string.Format("http{0}://{1}/v1/push/sub-key/{2}/devices/{3}?type={4}&uuid={5}{6}&pnsdk={7}{8}",
                                            ssl?"s":"", pnConfiguration.Origin, EditorCommon.SubscribeKey, pushToken,
                                            pushType.ToString().ToLower(),
                                            uuid, authKeyString,
                                            Utility.EncodeUricomponent(pnUnity.Version, PNOperationType.PNPushNotificationEnabledChannelsOperation, false, true),
                                            queryParamString
                                            );
            string received = uri.OriginalString;

            UnityEngine.Debug.Log("exp:" + expected);
            UnityEngine.Debug.Log(received);
            EditorCommon.LogAndCompare(expected, received);
        }
Exemple #2
0
        public void TestBuildGetChannelsPushRequestCommon(bool ssl, string authKey, string pushToken, PushTypeService pushType)
        {
            string uuid = "customuuid";

            Pubnub pubnub = new Pubnub(
                Common.PublishKey,
                Common.SubscribeKey,
                "",
                "",
                ssl
                );

            pubnub.AuthenticationKey = authKey;
            string authKeyString = "";

            if (!string.IsNullOrEmpty(authKey))
            {
                authKeyString = string.Format("&auth={0}", pubnub.AuthenticationKey);
            }

            Uri uri = BuildRequests.BuildGetChannelsPushRequest(pushType, pushToken, uuid, ssl,
                                                                pubnub.Origin, pubnub.AuthenticationKey, Common.SubscribeKey
                                                                );

            //[1, "Modified Channels"]
            //["push_channel"]
            //https://pubsub.pubnub.com/v1/push/sub-key/demo-36/devices/pushToken?type=wns&uuid=customuuid&auth=authKey&pnsdk=PubNub-CSharp-UnityIOS/3.6.9.0
            //https://pubsub.pubnub.com/v1/push/sub-key/demo-36/devices/pushToken?type=mpns&uuid=customuuid&auth=authKey&pnsdk=PubNub-CSharp-UnityIOS/3.6.9.0
            string expected = string.Format("http{0}://{1}/v1/push/sub-key/{2}/devices/{3}?type={4}&uuid={5}{6}&pnsdk={7}",
                                            ssl?"s":"", pubnub.Origin, Common.SubscribeKey, pushToken,
                                            pushType.ToString().ToLower(),
                                            uuid, authKeyString, PubnubUnity.Version
                                            );
            string received = uri.ToString();

            UnityEngine.Debug.Log("exp:" + expected);
            UnityEngine.Debug.Log(received);
            Common.LogAndCompare(expected, received);
        }