From 6dd7c68129d17e0f1ba9f44da7384d84acbdf782 Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Fri, 1 Apr 2016 17:59:53 +0800 Subject: [PATCH] add ios push test. Signed-off-by: Bo-Yi Wu --- certificate/certificate-valid.p12 | Bin 0 -> 2714 bytes certificate/certificate-valid.pem | 59 ++++++++++++++++++++++++++++++ gorush/server_test.go | 23 +++++++++++- 3 files changed, 81 insertions(+), 1 deletion(-) create mode 100644 certificate/certificate-valid.p12 create mode 100644 certificate/certificate-valid.pem diff --git a/certificate/certificate-valid.p12 b/certificate/certificate-valid.p12 new file mode 100644 index 0000000000000000000000000000000000000000..761b61493f6276cc594b74a395872742ac5f3772 GIT binary patch literal 2714 zcmY+^X*d+@8VB$h#$XZ>DcRLzi;-;EjeQy0m?V-lyX=g$A(L%vS>D$+j3qJ^S(+L< z*~T8SFA3QvRAf22u5-?N&WGoIp67qx*ZuJa!$2}=fV40S#2U;f8mk-o^E{9qh{r&T zKp2SLS*!)afI9zaf$GxqfrT1Z+ir(DqM=~` zL}5Tt2zNK6uo~+;FTLx^0*sCzvwfR5?{7DN=y|O1%Y%{=X&(&~k#2oc+?^OxZ7b%2=HnUJXSBCp8h>*;T!p7cztE8d{kO7MAj^ z$ej~aN}_s`H-Wf)Z&q5WQckGtYz8~BPSiRpDQUOfK#+?(SVEas;@fYyQ>bpRD$ji< zwPP%5b*Fyy!cO;#&r;{|AhA#DB&@aq12OZcofC@N0lAKoPX!MQ=~}h$?N&|bdbzj&?(5t#g9NvoBPxd6Z-ciK)135CY585Vya&)+o_uITe z-?bL@J{jYq%`jL4=sPHSCVEUL{$0%y;mqPWThW&8uVcI4uAWl6bo-i)B5ARamz_*)q9FUJb{K z>Wu@lGSxp*gXS)K$y|Gv?EVaEM#FUqCv7CHAQoBMnWy-3T|pF))zR&fK1~|Fy*Pj&5(x1Yw=_i9+Uvi?x*^Y0E~HvWM=_+*@8=nYU%jFH~qb zZha#nZ_@r|j^f9!I~360x3$=Vw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}OV4T8=?C{KE$!1OeT5a8VYqWskS8Wm#g5Wuz1h8=DteOyrwTbBP zi)NTW|02C8bxfQ#Gr*b!-&1qtzGU$rwP5EuS~!hJ*VMeFvi>{!Vbv;IjFz$PuMzfj zw!Y93j|fe2eNM(pQwIKt8GqMsq??=kZWtS#{1yY6v3W_gSL#9gQAwURT+rRjBGx{i zd=e)N-}+h+Jo@Ok*fgU z+;B~UWW&3D@*trHr0f?Blm2IjT?)#34WJG%0U!Y807<|t0RP$B7vKsA1lR%m0ZwOs zgR>d}lY$Ar7{PR6%(OIIbN~?ht8q(c&lSPa_Q{yf#yr_KcAgeXffxpSNRs1jt80H~ F{TE8;5;Fh* literal 0 HcmV?d00001 diff --git a/certificate/certificate-valid.pem b/certificate/certificate-valid.pem new file mode 100644 index 0000000..2939d7c --- /dev/null +++ b/certificate/certificate-valid.pem @@ -0,0 +1,59 @@ +Bag Attributes + localKeyID: 8C 1A 9F 00 66 BD 24 42 B9 5D 1E EB FE 5E 8B CA 04 3D 73 83 + friendlyName: APNS/2 Private Key +subject=/C=NZ/ST=Wellington/L=Wellington/O=Internet Widgits Pty Ltd/OU=9ZEH62KRVV/CN=APNS/2 Development IOS Push Services: com.sideshow.Apns2 +issuer=/C=NZ/ST=Wellington/L=Wellington/O=APNS/2 Inc./OU=APNS/2 Worldwide Developer Relations/CN=APNS/2 Worldwide Developer Relations Certification Authority +-----BEGIN CERTIFICATE----- +MIID6zCCAtMCAQIwDQYJKoZIhvcNAQELBQAwgcMxCzAJBgNVBAYTAk5aMRMwEQYD +VQQIEwpXZWxsaW5ndG9uMRMwEQYDVQQHEwpXZWxsaW5ndG9uMRQwEgYDVQQKEwtB +UE5TLzIgSW5jLjEtMCsGA1UECxMkQVBOUy8yIFdvcmxkd2lkZSBEZXZlbG9wZXIg +UmVsYXRpb25zMUUwQwYDVQQDEzxBUE5TLzIgV29ybGR3aWRlIERldmVsb3BlciBS +ZWxhdGlvbnMgQ2VydGlmaWNhdGlvbiBBdXRob3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RI= +-----END CERTIFICATE----- +Bag Attributes + localKeyID: 8C 1A 9F 00 66 BD 24 42 B9 5D 1E EB FE 5E 8B CA 04 3D 73 83 + friendlyName: APNS/2 Private Key +Key Attributes: +-----BEGIN RSA PRIVATE KEY----- +MIIEowIBAAKCAQEA2NHNUygeaGT8EO7dQsDCK76gehiFN7T8ukYXJGV05DgfGHgV +ie1Cnws/BxhxVaJgT9E+TlG3qkM6lmCW0M2fGumTLM2y9JTuF/fvtzouf07QMDlD +ivKzhTduZtin7Gsh0Gf+L1krSthcJuWiWxi5aR/2/+89Q+L4ZjIKAbk9SLsoRosh +cZWfRLU5aBb7KjNROX2GTkmQAsl02iuL3YG0DIFFbCO9eBQIC05StFHokZJipt6X +W7X1W67YcyPiB1yiLVCMvhZ9tD0TIXUp2s7Us+7YAVgiMdtqr3GKIB1ojoFGCDO+ +9sxNsvFFTq/A7IkZbDh0gOxCODCXEBthVKtmfwIDAQABAoIBAQCW8ZCI+OAae1tE +ipZ9F2bWP3LHLXTo8FYVdCA+VWeITk3PoiIUkJmV0aWCUhDstgto5doDej5sCTur +Xvj/ynaerMeqJFYWkewjwZcgLyAZvwuO1v7fp9E0x/9TGDfnjjnPNeaundxW0cNt +zOY3l0HVHsy9Jpe3QDcAJovy4Tv5+hFY4kDxUBGsyjvhScVgKg5tLkJclm3sOu/L +GyLqpwNI3OJAdMIuVD4N2BZ1aOEap6mp2y8Ie0/R4YWcaZ5A4Pw7xUPl6SXc9uua +/78QTERtPC6ejyCBiE05a8m3Q3iud3Xtnlyws2KwhgBAfE6M4zR/f3OQB7ZIXMhy +ZpmZZw5xAoGBAPYn84IrlIQetWQfvPdM7Kzgh6UDHCugnlCDghwYpRJGi8hMfuZV +xNIrYAJzLYDQ01lFJRJgWXTcbqz9NBz1nhg+cNOz1/KY+38eudee6DNYmztP7jDP +2jnaS+dtjC8hAXObnFqG+NilMDLLu6aRmrJaImbjSrfyLiE6mvJ7u81nAoGBAOF9 +g93wZ0mL1rk2s5WwHGTNU/HaOtmWS4z7kA7f4QaRub+MwppZmmDZPHpiZX7BPcZz +iOPQh+xn7IqRGoQWBLykBVt8zZFoLZJoCR3n63lex5A4p/0Pp1gFZrR+xX8PYVos +3yeeiWyPKsXXNc0s5QwHZcX6Wb8EHThTXGCBetcpAoGAMeQJC9IPaPPcae2w3CLA +OY3MkFpgBEuqqsDsxwsLsfeQb0lp0v+BQ+O8suJrT5eDrq1ABUh3+SKQYAl13YS+ +xUUqkw35b9cn6iztF9HCWF3WIKBjs4r9PQqMpdxjNE4pQChC+Wov16ErcrAuWWVb +iFiSbm4U/9FbHisFqq3/c3MCgYB+vzSuPgFw37+0oEDVtQZgyuGSop5NzCNvfb/9 +/G3aaXNFbnO8mv0hzzoleMWgODLnJ+4cUAz3H3tgcCu9bzr+Zhv0zvQl9a8YCo6F +VuWPdW0rbg1PO8tOuMqATnno79ZC/9H3zS9l7BuY1V2SlNeyqT3VyOFFc6SREpps +TJul8QKBgAxnQB8MA7zPULu1clyaJLdtEdRPkKWN7lKYptc0e/VHfSsKxseWkfqi +zgXZ51kQTrT6Zb6HYRfwC1mMXHWRKRyYjAnCxVim6YQd+KVT49iRDDAiIFoMGA4i +vvcIlneqOZZPDIoKJ60IjO/DZHWkw5mLjaIrT+qQ3XAGdJA13hcm +-----END RSA PRIVATE KEY----- diff --git a/gorush/server_test.go b/gorush/server_test.go index 18f0ad2..0896ecb 100644 --- a/gorush/server_test.go +++ b/gorush/server_test.go @@ -74,7 +74,28 @@ func TestDisabledIosPushHandler(t *testing.T) { r.POST("/api/push"). SetJSON(gofight.D{ - "tokens": []string{"dc0ca2819417e528d8a4a01fc3e6bc7d2518ce738930c3b11203c0ef7c0fab8c"}, + "tokens": []string{"11aa01229f15f0f0c52029d8cf8cd0aeaf2365fe4cebc4af26cd6d76b7919ef7"}, + "platform": 1, + "message": "Welcome", + }). + Run(GetMainEngine(), func(r gofight.HttpResponse, rq gofight.HttpRequest) { + + assert.Equal(t, http.StatusOK, r.Code) + }) +} + +func TestIosPushHandler(t *testing.T) { + initTest() + + PushConf.Ios.Enabled = true + PushConf.Ios.PemKeyPath = "../certificate/certificate-valid.pem" + InitAPNSClient() + + r := gofight.New() + + r.POST("/api/push"). + SetJSON(gofight.D{ + "tokens": []string{"11aa01229f15f0f0c52029d8cf8cd0aeaf2365fe4cebc4af26cd6d76b7919ef7"}, "platform": 1, "message": "Welcome", }).