• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

tomdesair / tus-java-server / 30699386120

01 Aug 2026 12:16PM UTC coverage: 96.519% (+0.2%) from 96.295%
30699386120

push

github

web-flow
feat(rufh): add Python conformity test suite and resolve RUFH draft-12 compliance failures (#110)

* Refactor RUFH 104 interim response handling and add Tomcat Valve documentation

* feat(rufh): add Python conformity test suite and resolve RUFH draft-12 compliance failures

* fix(download): set dual-protocol response headers on GET responses and refine error handling

* fix: Cleanup code

* test: add unit tests for missing branch coverage on RUFH and utility handlers

* refactor: replace generic TusException with typed exceptions across validators and tests

* docs: add typed exception guidelines to AGENTS.md

1392 of 1496 branches covered (93.05%)

Branch coverage included in aggregate %.

192 of 194 new or added lines in 36 files covered. (98.97%)

2933 of 2985 relevant lines covered (98.26%)

6.43 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

94.12
/src/main/java/me/desair/tus/server/creation/validation/UploadMetadataValidator.java
1
package me.desair.tus.server.creation.validation;
2

3
import jakarta.servlet.http.HttpServletRequest;
4
import me.desair.tus.server.HttpHeader;
5
import me.desair.tus.server.HttpMethod;
6
import me.desair.tus.server.RequestValidator;
7
import me.desair.tus.server.exception.InvalidUploadMetadataException;
8
import me.desair.tus.server.exception.TusException;
9
import me.desair.tus.server.upload.UploadStorageService;
10
import me.desair.tus.server.util.Utils;
11
import org.apache.commons.codec.binary.Base64;
12
import org.apache.commons.lang3.StringUtils;
13

14
/**
15
 * Validator that ensures the Upload-Metadata header adheres to formatting guidelines and has valid
16
 * Base64 values.
17
 */
18
public class UploadMetadataValidator implements RequestValidator {
6✔
19

20
  @Override
21
  public void validate(
22
      HttpMethod method,
23
      HttpServletRequest request,
24
      UploadStorageService uploadStorageService,
25
      String ownerKey)
26
      throws TusException {
27

28
    String metadata = Utils.getHeader(request, HttpHeader.UPLOAD_METADATA);
8✔
29
    if (StringUtils.isNotBlank(metadata)) {
6✔
30
      String[] pairs = metadata.split(",");
8✔
31
      for (String pair : pairs) {
32✔
32
        pair = pair.trim();
6✔
33
        if (StringUtils.isBlank(pair)) {
6✔
34
          throw new InvalidUploadMetadataException("Upload-Metadata cannot contain empty pairs");
5✔
35
        }
36

37
        String[] keyValue = pair.split(" ");
8✔
38
        if (keyValue.length > 2) {
8✔
39
          throw new InvalidUploadMetadataException(
5✔
40
              "Upload-Metadata key-value pairs must be separated by a single space");
41
        }
42

43
        String key = keyValue[0];
8✔
44
        if (StringUtils.isBlank(key)) {
6!
NEW
45
          throw new InvalidUploadMetadataException("Upload-Metadata key cannot be empty");
×
46
        }
47

48
        if (keyValue.length == 2) {
8✔
49
          String value = keyValue[1];
8✔
50
          if (!Base64.isBase64(value)) {
6✔
51
            throw new InvalidUploadMetadataException(
5✔
52
                "Upload-Metadata value must be a valid Base64 encoded string");
53
          }
54
        }
55
      }
56
    }
57
  }
2✔
58

59
  @Override
60
  public boolean supports(HttpMethod method) {
61
    return HttpMethod.POST.equals(method);
8✔
62
  }
63
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc