mirror of
https://github.com/esphome/esphome.git
synced 2026-01-10 12:10:48 -07:00
Add HMAC-MD5 component tests (#12459)
This commit is contained in:
@@ -1,2 +1,6 @@
|
||||
import esphome.config_validation as cv
|
||||
|
||||
AUTO_LOAD = ["md5"]
|
||||
CODEOWNERS = ["@dwmw2"]
|
||||
|
||||
CONFIG_SCHEMA = cv.Schema({})
|
||||
|
||||
34
tests/components/hmac_md5/common.yaml
Normal file
34
tests/components/hmac_md5/common.yaml
Normal file
@@ -0,0 +1,34 @@
|
||||
esphome:
|
||||
on_boot:
|
||||
- lambda: |-
|
||||
// Test HMAC-MD5 functionality
|
||||
#ifdef USE_MD5
|
||||
using esphome::hmac_md5::HmacMD5;
|
||||
HmacMD5 hmac;
|
||||
|
||||
// Test with key "key" and message "The quick brown fox jumps over the lazy dog"
|
||||
const char* key = "key";
|
||||
const char* message = "The quick brown fox jumps over the lazy dog";
|
||||
|
||||
hmac.init(key, strlen(key));
|
||||
hmac.add(message, strlen(message));
|
||||
hmac.calculate();
|
||||
|
||||
char hex_output[33];
|
||||
hmac.get_hex(hex_output);
|
||||
hex_output[32] = '\0';
|
||||
|
||||
ESP_LOGD("HMAC_MD5", "HMAC-MD5('%s', '%s') = %s", key, message, hex_output);
|
||||
|
||||
// Expected: 80070713463e7749b90c2dc24911e275
|
||||
const char* expected = "80070713463e7749b90c2dc24911e275";
|
||||
if (strcmp(hex_output, expected) == 0) {
|
||||
ESP_LOGI("HMAC_MD5", "Test PASSED");
|
||||
} else {
|
||||
ESP_LOGE("HMAC_MD5", "Test FAILED. Expected %s", expected);
|
||||
}
|
||||
#else
|
||||
ESP_LOGW("HMAC_MD5", "HMAC-MD5 not available on this platform");
|
||||
#endif
|
||||
|
||||
hmac_md5:
|
||||
1
tests/components/hmac_md5/test.bk72xx-ard.yaml
Normal file
1
tests/components/hmac_md5/test.bk72xx-ard.yaml
Normal file
@@ -0,0 +1 @@
|
||||
<<: !include common.yaml
|
||||
1
tests/components/hmac_md5/test.esp32-idf.yaml
Normal file
1
tests/components/hmac_md5/test.esp32-idf.yaml
Normal file
@@ -0,0 +1 @@
|
||||
<<: !include common.yaml
|
||||
1
tests/components/hmac_md5/test.esp8266-ard.yaml
Normal file
1
tests/components/hmac_md5/test.esp8266-ard.yaml
Normal file
@@ -0,0 +1 @@
|
||||
<<: !include common.yaml
|
||||
1
tests/components/hmac_md5/test.rp2040-ard.yaml
Normal file
1
tests/components/hmac_md5/test.rp2040-ard.yaml
Normal file
@@ -0,0 +1 @@
|
||||
<<: !include common.yaml
|
||||
Reference in New Issue
Block a user