1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-06-01 19:06:06 +02:00

fix tests

This commit is contained in:
Andreas Shimokawa 2024-02-12 18:31:48 +01:00
parent a977436200
commit 8b9462f521
3 changed files with 12 additions and 12 deletions

View File

@ -245,7 +245,7 @@ public class HuaweiPacket {
} }
public boolean attemptDecrypt() throws ParseException { public boolean attemptDecrypt() throws ParseException {
if (paramsProvider.getSecretKey() == null) if (paramsProvider == null || paramsProvider.getSecretKey() == null)
return false; return false;
if (this.tlv == null) if (this.tlv == null)
return false; return false;

View File

@ -145,7 +145,7 @@ import nodomain.freeyourgadget.gadgetbridge.util.GBPrefs;
import nodomain.freeyourgadget.gadgetbridge.util.Prefs; import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
import nodomain.freeyourgadget.gadgetbridge.util.SilentMode; import nodomain.freeyourgadget.gadgetbridge.util.SilentMode;
public final class ZeppOsSupport extends HuamiSupport implements ZeppOsFileTransferService.Callback { public class ZeppOsSupport extends HuamiSupport implements ZeppOsFileTransferService.Callback {
private static final Logger LOG = LoggerFactory.getLogger(ZeppOsSupport.class); private static final Logger LOG = LoggerFactory.getLogger(ZeppOsSupport.class);
// Tracks whether realtime HR monitoring is already started, so we can just // Tracks whether realtime HR monitoring is already started, so we can just
@ -1014,7 +1014,7 @@ public final class ZeppOsSupport extends HuamiSupport implements ZeppOsFileTrans
@Override @Override
@Deprecated @Deprecated
public final HuamiFWHelper createFWHelper(final Uri uri, final Context context) throws IOException { public HuamiFWHelper createFWHelper(final Uri uri, final Context context) throws IOException {
throw new UnsupportedOperationException("This function should not be used for Zepp OS devices"); throw new UnsupportedOperationException("This function should not be used for Zepp OS devices");
} }

View File

@ -288,7 +288,7 @@ public class TestHuaweiTLV {
} }
@Test @Test
public void testGetBytesEmpty() { public void testGetBytesEmpty() throws HuaweiPacket.MissingTagException {
int tag = 0x01; int tag = 0x01;
ArrayList<HuaweiTLV.TLV> input = new ArrayList<>(); ArrayList<HuaweiTLV.TLV> input = new ArrayList<>();
input.add(new HuaweiTLV.TLV((byte) 0x01, new byte[] {})); input.add(new HuaweiTLV.TLV((byte) 0x01, new byte[] {}));
@ -301,7 +301,7 @@ public class TestHuaweiTLV {
} }
@Test @Test
public void testGetBytes() { public void testGetBytes() throws HuaweiPacket.MissingTagException {
int tag = 0x01; int tag = 0x01;
ArrayList<HuaweiTLV.TLV> input = new ArrayList<>(); ArrayList<HuaweiTLV.TLV> input = new ArrayList<>();
input.add(new HuaweiTLV.TLV((byte) 0x01, new byte[] {0x01, 0x02, 0x03})); input.add(new HuaweiTLV.TLV((byte) 0x01, new byte[] {0x01, 0x02, 0x03}));
@ -314,7 +314,7 @@ public class TestHuaweiTLV {
} }
@Test @Test
public void testGetByte() { public void testGetByte() throws HuaweiPacket.MissingTagException {
int tag = 0x01; int tag = 0x01;
ArrayList<HuaweiTLV.TLV> input = new ArrayList<>(); ArrayList<HuaweiTLV.TLV> input = new ArrayList<>();
input.add(new HuaweiTLV.TLV((byte) 0x01, new byte[] {0x04})); input.add(new HuaweiTLV.TLV((byte) 0x01, new byte[] {0x04}));
@ -327,7 +327,7 @@ public class TestHuaweiTLV {
} }
@Test @Test
public void testGetBooleans() { public void testGetBooleans() throws HuaweiPacket.MissingTagException {
ArrayList<HuaweiTLV.TLV> input = new ArrayList<>(); ArrayList<HuaweiTLV.TLV> input = new ArrayList<>();
input.add(new HuaweiTLV.TLV((byte) 0x01, new byte[] {0x01})); input.add(new HuaweiTLV.TLV((byte) 0x01, new byte[] {0x01}));
input.add(new HuaweiTLV.TLV((byte) 0x02, new byte[] {0x00})); input.add(new HuaweiTLV.TLV((byte) 0x02, new byte[] {0x00}));
@ -340,7 +340,7 @@ public class TestHuaweiTLV {
} }
@Test @Test
public void testGetInteger() { public void testGetInteger() throws HuaweiPacket.MissingTagException {
int tag = 0x01; int tag = 0x01;
ArrayList<HuaweiTLV.TLV> input = new ArrayList<>(); ArrayList<HuaweiTLV.TLV> input = new ArrayList<>();
input.add(new HuaweiTLV.TLV((byte) 0x01, new byte[] {(byte) 0xDE, (byte) 0xAD, (byte) 0xBE, (byte) 0xEF})); input.add(new HuaweiTLV.TLV((byte) 0x01, new byte[] {(byte) 0xDE, (byte) 0xAD, (byte) 0xBE, (byte) 0xEF}));
@ -353,7 +353,7 @@ public class TestHuaweiTLV {
} }
@Test @Test
public void testGetShort() { public void testGetShort() throws HuaweiPacket.MissingTagException {
int tag = 0x01; int tag = 0x01;
ArrayList<HuaweiTLV.TLV> input = new ArrayList<>(); ArrayList<HuaweiTLV.TLV> input = new ArrayList<>();
input.add(new HuaweiTLV.TLV((byte) 0x01, new byte[] {(byte) 0xCA, (byte) 0xFE})); input.add(new HuaweiTLV.TLV((byte) 0x01, new byte[] {(byte) 0xCA, (byte) 0xFE}));
@ -366,7 +366,7 @@ public class TestHuaweiTLV {
} }
@Test @Test
public void testGetString() { public void testGetString() throws HuaweiPacket.MissingTagException {
int tag = 0x01; int tag = 0x01;
ArrayList<HuaweiTLV.TLV> input = new ArrayList<>(); ArrayList<HuaweiTLV.TLV> input = new ArrayList<>();
input.add(new HuaweiTLV.TLV((byte) 0x01, new byte[] {0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x20, 0x77, 0x6F, 0x72, 0x6C, 0x64, 0x21})); input.add(new HuaweiTLV.TLV((byte) 0x01, new byte[] {0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x20, 0x77, 0x6F, 0x72, 0x6C, 0x64, 0x21}));
@ -379,7 +379,7 @@ public class TestHuaweiTLV {
} }
@Test @Test
public void testGetObject() { public void testGetObject() throws HuaweiPacket.MissingTagException {
int tag = 0x01; int tag = 0x01;
ArrayList<HuaweiTLV.TLV> input = new ArrayList<>(); ArrayList<HuaweiTLV.TLV> input = new ArrayList<>();
input.add(new HuaweiTLV.TLV((byte) 0x01, new byte[] {0x01, 0x00})); input.add(new HuaweiTLV.TLV((byte) 0x01, new byte[] {0x01, 0x00}));
@ -512,7 +512,7 @@ public class TestHuaweiTLV {
* Following test also depends on the HuaweiCrypto class functioning correctly * Following test also depends on the HuaweiCrypto class functioning correctly
*/ */
@Test @Test
public void testDecrypt() throws HuaweiCrypto.CryptoException { public void testDecrypt() throws HuaweiCrypto.CryptoException, HuaweiPacket.MissingTagException {
byte[] ciphertext = {(byte) 0x0E, (byte) 0xA0, (byte) 0x01, (byte) 0xBB, (byte) 0x1E, (byte) 0xDA, (byte) 0xCB, (byte) 0x09, (byte) 0x83, (byte) 0x20, (byte) 0x40, (byte) 0x7D, (byte) 0x97, (byte) 0x1B, (byte) 0xF6, (byte) 0xD0}; byte[] ciphertext = {(byte) 0x0E, (byte) 0xA0, (byte) 0x01, (byte) 0xBB, (byte) 0x1E, (byte) 0xDA, (byte) 0xCB, (byte) 0x09, (byte) 0x83, (byte) 0x20, (byte) 0x40, (byte) 0x7D, (byte) 0x97, (byte) 0x1B, (byte) 0xF6, (byte) 0xD0};
ArrayList<HuaweiTLV.TLV> input = new ArrayList<>(); ArrayList<HuaweiTLV.TLV> input = new ArrayList<>();
input.add(new HuaweiTLV.TLV((byte) 0x7C, new byte[] {0x01})); input.add(new HuaweiTLV.TLV((byte) 0x7C, new byte[] {0x01}));