From 267fe016e83a26e6bd8b8c7c05115ddfd0edec53 Mon Sep 17 00:00:00 2001 From: Clercq Date: Sat, 23 Jul 2022 07:27:25 +0300 Subject: [PATCH] test fixes --- .../auth/core/HttpAuthCoreProvider.java | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/HttpAuthCoreProvider.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/HttpAuthCoreProvider.java index ef228c7f..eda81a60 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/HttpAuthCoreProvider.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/HttpAuthCoreProvider.java @@ -17,6 +17,7 @@ import pro.gravit.launchserver.auth.core.interfaces.user.UserSupportHardware; import pro.gravit.launchserver.auth.core.interfaces.user.UserSupportProperties; import pro.gravit.launchserver.auth.core.interfaces.user.UserSupportTextures; +import pro.gravit.launchserver.helper.HttpHelper; import pro.gravit.launchserver.manangers.AuthManager; import pro.gravit.launchserver.socket.Client; import pro.gravit.launchserver.socket.response.auth.AuthResponse; @@ -152,7 +153,7 @@ public UserHardware getHardwareInfoByPublicKey(byte[] publicKey) { } try { return requester.send(requester.post(getHardwareInfoByPublicKeyUrl, new HardwareRequest(publicKey), - null), HttpUserHardware.class).getOrThrow(); + bearerToken), HttpUserHardware.class).getOrThrow(); } catch (IOException e) { logger.error(e); return null; @@ -165,8 +166,10 @@ public UserHardware getHardwareInfoByData(HardwareReportRequest.HardwareInfo inf return null; } try { - return requester.send(requester.post(getHardwareInfoByDataUrl, new HardwareRequest(new HttpUserHardware(info)), - null), HttpUserHardware.class).getOrThrow(); + HttpHelper.HttpOptional hardware = requester.send(requester.post(getHardwareInfoByDataUrl, new HardwareRequest(new HttpUserHardware(info)), + bearerToken), HttpUserHardware.class); + //should return null if not found + return hardware.isSuccessful() ? hardware.getOrThrow() : null; } catch (IOException e) { logger.error(e); return null; @@ -180,7 +183,7 @@ public UserHardware getHardwareInfoById(String id) { } try { return requester.send(requester.post(getHardwareInfoByIdUrl, new HardwareRequest(new HttpUserHardware(Long.parseLong(id))), - null), HttpUserHardware.class).getOrThrow(); + bearerToken), HttpUserHardware.class).getOrThrow(); } catch (IOException | NumberFormatException e) { logger.error(e); return null; @@ -194,7 +197,7 @@ public UserHardware createHardwareInfo(HardwareReportRequest.HardwareInfo info, } try { return requester.send(requester.post(createHardwareInfoUrl, new HardwareRequest(new HttpUserHardware(info, publicKey, false)), - null), HttpUserHardware.class).getOrThrow(); + bearerToken), HttpUserHardware.class).getOrThrow(); } catch (IOException e) { logger.error(e); return null; @@ -207,7 +210,7 @@ public void connectUserAndHardware(UserSession userSession, UserHardware hardwar return; } try { - requester.send(requester.post(connectUserAndHardwareUrl, new HardwareRequest(userSession, hardware), null), Void.class); + requester.send(requester.post(connectUserAndHardwareUrl, new HardwareRequest(userSession, hardware), bearerToken), Void.class); } catch (IOException e) { logger.error(e); } @@ -219,7 +222,7 @@ public void addPublicKeyToHardwareInfo(UserHardware hardware, byte[] publicKey) return; } try { - requester.send(requester.post(addPublicKeyToHardwareInfoUrl, new HardwareRequest(hardware, publicKey), null), Void.class); + requester.send(requester.post(addPublicKeyToHardwareInfoUrl, new HardwareRequest(hardware, publicKey), bearerToken), Void.class); } catch (IOException e) { logger.error(e); } @@ -232,7 +235,7 @@ public Iterable getUsersByHardwareInfo(UserHardware hardware) { } try { return requester.send(requester.post(getUsersByHardwareInfoUrl, new HardwareRequest(hardware), - null), List.class).getOrThrow(); + bearerToken), List.class).getOrThrow(); } catch (IOException e) { logger.error(e); return null; @@ -245,7 +248,7 @@ public void banHardware(UserHardware hardware) { return; } try { - requester.send(requester.post(banHardwareUrl, new HardwareRequest(hardware), null), Void.class); + requester.send(requester.post(banHardwareUrl, new HardwareRequest(hardware), bearerToken), Void.class); } catch (IOException e) { logger.error(e); } @@ -257,7 +260,7 @@ public void unbanHardware(UserHardware hardware) { return; } try { - requester.send(requester.post(unbanHardwareUrl, new HardwareRequest(hardware), null), Void.class); + requester.send(requester.post(unbanHardwareUrl, new HardwareRequest(hardware), bearerToken), Void.class); } catch (IOException e) { logger.error(e); } @@ -534,6 +537,7 @@ public String toString() { ", permissions=" + permissions + ", assets=" + getAssets() + ", properties=" + properties + + ", hwidId=" + hwidId + '}'; }