Skip to content

Commit b441cb5

Browse files
committed
test: add column mapping test for WebAuthnCredential byte[] length (#286)
1 parent 96bc1e2 commit b441cb5

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package com.digitalsanctuary.spring.user.persistence.model;
2+
3+
import static org.assertj.core.api.Assertions.assertThat;
4+
import java.lang.reflect.Field;
5+
import jakarta.persistence.Column;
6+
import org.hibernate.Length;
7+
import org.junit.jupiter.api.DisplayName;
8+
import org.junit.jupiter.params.ParameterizedTest;
9+
import org.junit.jupiter.params.provider.ValueSource;
10+
11+
@DisplayName("WebAuthnCredential Column Mapping Tests")
12+
class WebAuthnCredentialColumnMappingTest {
13+
14+
@ParameterizedTest
15+
@ValueSource(strings = {"attestationObject", "attestationClientDataJson", "publicKey"})
16+
@DisplayName("should use Length.LONG32 on byte[] fields for cross-database BLOB compatibility")
17+
void shouldUseLengthLong32OnBlobFields(String fieldName) throws NoSuchFieldException {
18+
Field field = WebAuthnCredential.class.getDeclaredField(fieldName);
19+
Column column = field.getAnnotation(Column.class);
20+
assertThat(column)
21+
.as("Field '%s' must have @Column annotation", fieldName)
22+
.isNotNull();
23+
assertThat(column.length())
24+
.as("Field '%s' @Column length must be Length.LONG32 (%d) to auto-upgrade "
25+
+ "to LONGBLOB on MariaDB/MySQL and remain bytea on PostgreSQL",
26+
fieldName, Length.LONG32)
27+
.isEqualTo(Length.LONG32);
28+
}
29+
}

0 commit comments

Comments
 (0)