Resolves #6. Remove hash field from the project structures

This commit is contained in:
ErickSkrauch 2019-05-01 01:51:16 +03:00
parent a81c6fc9f8
commit ed0b9bb040
6 changed files with 10 additions and 17 deletions

View File

@ -38,5 +38,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Removed ### Removed
- `hash` field from `/textures` response because the game doesn't use it and calculates hash by getting the filename - `hash` field from `/textures` response because the game doesn't use it and calculates hash by getting the filename
from the textures link instead. from the textures link instead.
- `hash` field from `POST /api/skins` endpoint.
[Unreleased]: https://github.com/elyby/chrly/compare/4.1.1...HEAD [Unreleased]: https://github.com/elyby/chrly/compare/4.1.1...HEAD

View File

@ -172,7 +172,6 @@ form data. `form-urlencoded` also supported, but, as you may know, it doesn't su
| username | string | Username. Case insensitive. | | username | string | Username. Case insensitive. |
| uuid | uuid | UUID of the user. | | uuid | uuid | UUID of the user. |
| skinId | int | Skin identifier. | | skinId | int | Skin identifier. |
| hash | string | Skin's hash. Algorithm can be any. For example `md5`. |
| is1_8 | bool | Does the skin have the new format (64x64). | | is1_8 | bool | Does the skin have the new format (64x64). |
| isSlim | bool | Does skin have slim arms (Alex model). | | isSlim | bool | Does skin have slim arms (Alex model). |
| mojangTextures | string | Mojang textures field. It must be a base64 encoded json string. Not required. | | mojangTextures | string | Mojang textures field. It must be a base64 encoded json string. Not required. |

View File

@ -72,7 +72,6 @@ func (cfg *Config) PostSkin(resp http.ResponseWriter, req *http.Request) {
record.Uuid = req.Form.Get("uuid") record.Uuid = req.Form.Get("uuid")
record.SkinId = skinId record.SkinId = skinId
record.Hash = req.Form.Get("hash")
record.Is1_8 = is18 record.Is1_8 = is18
record.IsSlim = isSlim record.IsSlim = isSlim
record.Url = req.Form.Get("url") record.Url = req.Form.Get("url")

View File

@ -28,7 +28,6 @@ func TestConfig_PostSkin(t *testing.T) {
resultModel := createSkinModel("mock_user", false) resultModel := createSkinModel("mock_user", false)
resultModel.SkinId = 5 resultModel.SkinId = 5
resultModel.Hash = "94a457d92a61460cb9cb5d6f29732d2a"
resultModel.Url = "http://ely.by/minecraft/skins/default.png" resultModel.Url = "http://ely.by/minecraft/skins/default.png"
resultModel.MojangTextures = "" resultModel.MojangTextures = ""
resultModel.MojangSignature = "" resultModel.MojangSignature = ""
@ -125,7 +124,6 @@ func TestConfig_PostSkin(t *testing.T) {
resultModel := createSkinModel("mock_user", false) resultModel := createSkinModel("mock_user", false)
resultModel.SkinId = 5 resultModel.SkinId = 5
resultModel.Hash = "94a457d92a61460cb9cb5d6f29732d2a"
resultModel.Url = "http://textures-server.com/skin.png" resultModel.Url = "http://textures-server.com/skin.png"
resultModel.MojangTextures = "" resultModel.MojangTextures = ""
resultModel.MojangSignature = "" resultModel.MojangSignature = ""
@ -173,7 +171,6 @@ func TestConfig_PostSkin(t *testing.T) {
resultModel := createSkinModel("mock_user", false) resultModel := createSkinModel("mock_user", false)
resultModel.UserId = 2 resultModel.UserId = 2
resultModel.SkinId = 5 resultModel.SkinId = 5
resultModel.Hash = "94a457d92a61460cb9cb5d6f29732d2a"
resultModel.Url = "http://ely.by/minecraft/skins/default.png" resultModel.Url = "http://ely.by/minecraft/skins/default.png"
resultModel.MojangTextures = "" resultModel.MojangTextures = ""
resultModel.MojangSignature = "" resultModel.MojangSignature = ""
@ -222,7 +219,6 @@ func TestConfig_PostSkin(t *testing.T) {
resultModel := createSkinModel("changed_username", false) resultModel := createSkinModel("changed_username", false)
resultModel.SkinId = 5 resultModel.SkinId = 5
resultModel.Hash = "94a457d92a61460cb9cb5d6f29732d2a"
resultModel.Url = "http://ely.by/minecraft/skins/default.png" resultModel.Url = "http://ely.by/minecraft/skins/default.png"
resultModel.MojangTextures = "" resultModel.MojangTextures = ""
resultModel.MojangSignature = "" resultModel.MojangSignature = ""

View File

@ -24,7 +24,7 @@ type skinsTestCase struct {
var skinsTestCases = []*skinsTestCase{ var skinsTestCases = []*skinsTestCase{
{ {
Name: "Obtain skin for known username", Name: "Obtain skin for known username",
ExistsInLocalStorage: true, ExistsInLocalStorage: true,
AssertResponse: func(assert *testify.Assertions, resp *http.Response) { AssertResponse: func(assert *testify.Assertions, resp *http.Response) {
assert.Equal(301, resp.StatusCode) assert.Equal(301, resp.StatusCode)
@ -32,28 +32,28 @@ var skinsTestCases = []*skinsTestCase{
}, },
}, },
{ {
Name: "Obtain skin for unknown username that exists in Mojang and has a cape", Name: "Obtain skin for unknown username that exists in Mojang and has a cape",
ExistsInLocalStorage: false, ExistsInLocalStorage: false,
ExistsInMojang: true, ExistsInMojang: true,
HasSkinInMojangResp: true, HasSkinInMojangResp: true,
AssertResponse: func(assert *testify.Assertions, resp *http.Response) { AssertResponse: func(assert *testify.Assertions, resp *http.Response) {
assert.Equal(301, resp.StatusCode) assert.Equal(301, resp.StatusCode)
assert.Equal("http://mojang/skin.png", resp.Header.Get("Location")) assert.Equal("http://mojang/skin.png", resp.Header.Get("Location"))
}, },
}, },
{ {
Name: "Obtain skin for unknown username that exists in Mojang, but don't has a cape", Name: "Obtain skin for unknown username that exists in Mojang, but don't has a cape",
ExistsInLocalStorage: false, ExistsInLocalStorage: false,
ExistsInMojang: true, ExistsInMojang: true,
HasSkinInMojangResp: false, HasSkinInMojangResp: false,
AssertResponse: func(assert *testify.Assertions, resp *http.Response) { AssertResponse: func(assert *testify.Assertions, resp *http.Response) {
assert.Equal(404, resp.StatusCode) assert.Equal(404, resp.StatusCode)
}, },
}, },
{ {
Name: "Obtain skin for unknown username that doesn't exists in Mojang", Name: "Obtain skin for unknown username that doesn't exists in Mojang",
ExistsInLocalStorage: false, ExistsInLocalStorage: false,
ExistsInMojang: false, ExistsInMojang: false,
AssertResponse: func(assert *testify.Assertions, resp *http.Response) { AssertResponse: func(assert *testify.Assertions, resp *http.Response) {
assert.Equal(404, resp.StatusCode) assert.Equal(404, resp.StatusCode)
}, },
@ -150,7 +150,6 @@ func createSkinModel(username string, isSlim bool) *model.Skin {
Username: username, Username: username,
Uuid: "0f657aa8-bfbe-415d-b700-5750090d3af3", // Use non nil UUID to pass validation in api tests Uuid: "0f657aa8-bfbe-415d-b700-5750090d3af3", // Use non nil UUID to pass validation in api tests
SkinId: 1, SkinId: 1,
Hash: "00000000000000000000000000000000",
Url: "http://chrly/skin.png", Url: "http://chrly/skin.png",
MojangTextures: "mocked textures base64", MojangTextures: "mocked textures base64",
MojangSignature: "mocked signature", MojangSignature: "mocked signature",

View File

@ -8,7 +8,6 @@ type Skin struct {
Url string `json:"url"` Url string `json:"url"`
Is1_8 bool `json:"is1_8"` Is1_8 bool `json:"is1_8"`
IsSlim bool `json:"isSlim"` IsSlim bool `json:"isSlim"`
Hash string `json:"hash"`
MojangTextures string `json:"mojangTextures"` MojangTextures string `json:"mojangTextures"`
MojangSignature string `json:"mojangSignature"` MojangSignature string `json:"mojangSignature"`
OldUsername string OldUsername string