From 3f0b9fa9898a56b993176bee47a459d808c98d4e Mon Sep 17 00:00:00 2001 From: Pavel Timofeev Date: Fri, 1 Jul 2016 23:46:23 +0400 Subject: [PATCH 1/3] removed hardcoded date --- unity/Assets/Utils/SignatureBuilder.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/unity/Assets/Utils/SignatureBuilder.cs b/unity/Assets/Utils/SignatureBuilder.cs index ad8a0b6..78f3d4a 100644 --- a/unity/Assets/Utils/SignatureBuilder.cs +++ b/unity/Assets/Utils/SignatureBuilder.cs @@ -162,7 +162,7 @@ public string CredentialScope { // TODO: CredentialScope //return string.Format("{0}/{1}/{2}/{3}/{4}", CLIENTID, APPID, APIKEY, APISECRET, svcname); - return string.Format("{0}/{1}", "20160619", svcname); + return string.Format("{0}/{1}", "_", svcname); } } @@ -185,7 +185,7 @@ public string Signature using (var hmac = new HMACSHA256(keyByte)) { var hashBytes = hmac.ComputeHash(messageBytes); - return Convert.ToBase64String(hashBytes);//.TrimEnd('='); // TODO: trim is not needed + return Convert.ToBase64String(hashBytes); } } } @@ -194,7 +194,7 @@ public string Credentials { get { - return string.Format(CredentialsFormat, APIKEY, "20160619", svcname); + return string.Format(CredentialsFormat, APIKEY, "_", svcname); } } From 5f0a2eea34916e9bbc198efabcccd2996f071f66 Mon Sep 17 00:00:00 2001 From: Pavel Timofeev Date: Sat, 2 Jul 2016 01:18:25 +0400 Subject: [PATCH 2/3] changed signature creation process. big tests are green --- unity/Assets/Editor/CommonRequests.cs | 49 +++++++++++++++++++------- unity/Assets/Utils/SignatureBuilder.cs | 3 +- 2 files changed, 38 insertions(+), 14 deletions(-) diff --git a/unity/Assets/Editor/CommonRequests.cs b/unity/Assets/Editor/CommonRequests.cs index 6089b70..3bab29c 100644 --- a/unity/Assets/Editor/CommonRequests.cs +++ b/unity/Assets/Editor/CommonRequests.cs @@ -32,10 +32,9 @@ public void StrigthforwardCallShouldReturn_AuthRequired() [Test] [Category("BigTests")] [MaxTime(10000)] - public void RestClient_GetShouldReturn_WrongSignature() + public void RestClient_IfKeyIsNotCorrect_GetShouldReturn_Forbidden() { - RestClient client = new RestClient( - DEV.BASEURI, DEV.CLIENTID, DEV.APPID, DEV.APIKEY, DEV.APISECRET, DEV.SERVICE); + RestClient client = new RestClient(DEV.BASEURI, "-", "-", "-", "-", DEV.SERVICE); Response response = null; @@ -47,14 +46,14 @@ public void RestClient_GetShouldReturn_WrongSignature() while (coroutine.MoveNext()) { ;} - Assert.AreEqual(401, response.StatusCode); - Assert.IsTrue(response.www.error.ToLowerInvariant().Contains("401 unauthorized"), response.www.error); - Assert.IsTrue(response.www.text.ToLowerInvariant().Contains("wrong signature"), response.www.text); + Assert.AreEqual(403, response.StatusCode); + Assert.AreEqual("403 Forbidden", response.www.error.Trim( new char[]{'\r','\n'} )); } [Test] [Category("BigTests")] [MaxTime(10000)] + [Ignore] public void RestClient_PostShouldReturn_WrongSignature() { RestClient client = new RestClient( @@ -68,16 +67,13 @@ public void RestClient_PostShouldReturn_WrongSignature() while (coroutine.MoveNext()) { ;} - Assert.AreEqual(401, response.StatusCode); + Assert.AreEqual(400, response.StatusCode); Assert.IsTrue(response.www.error.ToLowerInvariant().Contains("401 unauthorized"), response.www.error); Assert.IsTrue(response.www.text.ToLowerInvariant().Contains("wrong signature"), response.www.text); } - [Test] - [Category("BigTests")] - [MaxTime(10000)] - [Ignore] - public void RestClient_GetShouldReturn_200() + + Response RequestCommonGet() { RestClient client = new RestClient( DEV.BASEURI, DEV.CLIENTID, DEV.APPID, DEV.APIKEY, DEV.APISECRET, DEV.SERVICE); @@ -92,8 +88,35 @@ public void RestClient_GetShouldReturn_200() while (coroutine.MoveNext()) { ;} + return response; + } + + [Test] + [Category("BigTests")] + [MaxTime(10000)] + public void RestClient_GetShouldReturn_200() + { + var response = RequestCommonGet(); Assert.AreEqual(200, response.StatusCode); - Assert.AreEqual("", response.www.error); + } + + + [Test] + [Category("BigTests")] + [MaxTime(10000)] + public void RestClient_GetShouldNotReturn_Error() + { + var response = RequestCommonGet(); + Assert.AreEqual(null, response.www.error); + } + + [Test] + [Category("BigTests")] + [MaxTime(10000)] + public void RestClient_GetShouldReturn_ValidData() + { + var response = RequestCommonGet(); + Assert.AreEqual("[]", response.www.text); } } diff --git a/unity/Assets/Utils/SignatureBuilder.cs b/unity/Assets/Utils/SignatureBuilder.cs index 78f3d4a..821b88e 100644 --- a/unity/Assets/Utils/SignatureBuilder.cs +++ b/unity/Assets/Utils/SignatureBuilder.cs @@ -185,7 +185,8 @@ public string Signature using (var hmac = new HMACSHA256(keyByte)) { var hashBytes = hmac.ComputeHash(messageBytes); - return Convert.ToBase64String(hashBytes); + // TODO: figure out + return Convert.ToBase64String(hashBytes).Replace('+', '-').Replace('/', '_'); } } } From dbe4681fa2414f5522591879569e6dddb910a937 Mon Sep 17 00:00:00 2001 From: Pavel Timofeev Date: Mon, 5 Dec 2016 13:19:48 +0300 Subject: [PATCH 3/3] - remove 'v1' from urls; - setup dev endpoint in demo scene --- unity/Assets/Leaderboard/Leaderboard.unity | Bin 106864 -> 106912 bytes unity/Assets/ScoreboardService.cs | 4 ++-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/unity/Assets/Leaderboard/Leaderboard.unity b/unity/Assets/Leaderboard/Leaderboard.unity index 869024e684c01b409958e8f04f13a2465f5710df..872fc1c85159e0b07290b6e0459ff802ec124604 100644 GIT binary patch delta 782 zcmZXRPiPZC6vp2a4GDNiPSy+yrl@$ypPn>9A%z|k6yilHSjf^WP1Uq%v$3fl_RvEs zRw56K#{>n5+LBVV5ec=`OHpe6wN*se-r}W*plG44Z+3I)F1&A;_kQzzJG(ztZTWXL zJHXa!V1@jG{bSXAi~;=Cb$tvDfq0r-AFhhkUc{ZMn?=x3<5INJ}yxS{_0~z$xIn(eg=^wmO=fUZc^#${`%Y%aMTmU#tk$XnuLD7Ojdltbt z^2p#?olCH2_2>z#86H_=4bI-8MB2h&g9no@t+ew5iyQW@0M6`7bhT$;oF$Jq78_h@ zEtz-J=#U2H9edTjYr-Ro+r&k1kF<BmCCn9rk71ZMvntW$QnS-~Tl#@Bnsi2>c>x0EafXR9>-O zesy*#Wtta=OJc=1^M&Z6@2&K+pAS_*m(aB-KCG9twRnE>c`+QKc3f4HsgU0v9Gw`y zekzb2RD4QC8Az*&S56N3(kZVZr&MpZPfp0UMuz3_ly6`p;g2ad0dn?9GK_pZkgMKd b&ZnOznZw~C&kKqiQ*zo2^DjB?vgqOe1=05E delta 733 zcmZXRPe>GT6vy9Ba9N?lECkv97}ynzF0mVUXeCL(gF+p;$Oa0#q%_HvtInlExPgaF zGLi@Gb(ezL(l905i1qI!QFL~9{L>-WZgvR?3KML4Z)Q)<;eCIa2!Ma~$U1JpPR%=>#qAQ0{J|sN z1H2+LVV4u~@}x7)2f8p=mSPUuNWb8nvW!IM+%K5*^xR|mkh~Ted1{ZW=N9B@UI1q) zqYF36QZ?q?86DvbJ0pgoBE<_-NedXM$VmG~H?3R}8mAlNT|YC?SMwB{q>O8ruSm79 z=-jbNXR6@bu~Ux@az+fl6Boc!(llN)r5gAQ@R%G5rgG^1=D!b_&f;xTiZDJPjp9?H zQ$>KOGjym?!9;U^9r>!T~D@#LW!Zf@q{)s js%KhKVkKjY3FWo-iD>XLb8{fxpYctI(Bh2=5x?*s3FzZm diff --git a/unity/Assets/ScoreboardService.cs b/unity/Assets/ScoreboardService.cs index 382fa99..488d33e 100644 --- a/unity/Assets/ScoreboardService.cs +++ b/unity/Assets/ScoreboardService.cs @@ -22,7 +22,7 @@ public override void Start() /// Callback method with Exception and TopScores args public void GetTop(Action callback) { - Get("/v1/scoreboard/score/10", callback); + Get("/scoreboard/score/10", callback); } /// @@ -32,6 +32,6 @@ public void GetTop(Action callback) /// Callback method with Exception and ScoreData args public void PostScore(ScoreData score, Action callback) { - Post("/v1/scoreboard/score", score, callback); + Post("/scoreboard/score", score, callback); } }