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/Leaderboard/Leaderboard.unity b/unity/Assets/Leaderboard/Leaderboard.unity index 869024e..872fc1c 100644 Binary files a/unity/Assets/Leaderboard/Leaderboard.unity and b/unity/Assets/Leaderboard/Leaderboard.unity differ 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); } } diff --git a/unity/Assets/Utils/SignatureBuilder.cs b/unity/Assets/Utils/SignatureBuilder.cs index ad8a0b6..821b88e 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,8 @@ public string Signature using (var hmac = new HMACSHA256(keyByte)) { var hashBytes = hmac.ComputeHash(messageBytes); - return Convert.ToBase64String(hashBytes);//.TrimEnd('='); // TODO: trim is not needed + // TODO: figure out + return Convert.ToBase64String(hashBytes).Replace('+', '-').Replace('/', '_'); } } } @@ -194,7 +195,7 @@ public string Credentials { get { - return string.Format(CredentialsFormat, APIKEY, "20160619", svcname); + return string.Format(CredentialsFormat, APIKEY, "_", svcname); } }