Skip to content

Commit bf5cafc

Browse files
committed
Add autest
1 parent 17117aa commit bf5cafc

10 files changed

Lines changed: 1377 additions & 0 deletions

tests/gold_tests/pluginTest/jax_fingerprint/jax_fingerprint.test.py

Lines changed: 342 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
# Used by: global JA4H append mode test.
18+
#
19+
# The jax_fingerprint plugin is loaded globally with --method JA4H
20+
# --standalone --mode append.
21+
#
22+
# append mode behaviour (from header.cc):
23+
# - If the header field is absent: create it with the new value.
24+
# - If the header field is already present: insert the new value as an
25+
# additional value in the last duplicate field. HTTP clients and
26+
# intermediaries represent this as a comma-separated list,
27+
# e.g. "upstream-via, test.proxy.test".
28+
29+
meta:
30+
version: "1.0"
31+
32+
sessions:
33+
34+
# Session 1: no pre-existing x-jax-via – plugin creates it.
35+
- protocol:
36+
- name: http
37+
version: 1
38+
- name: tcp
39+
- name: ip
40+
41+
transactions:
42+
43+
- client-request:
44+
method: GET
45+
url: /resource-no-via
46+
version: '1.1'
47+
headers:
48+
fields:
49+
- [ Host, jax.server.test ]
50+
- [ Content-Length, 0 ]
51+
- [ uuid, append-no-existing-via ]
52+
53+
# No existing via header – plugin sets it to the proxy name.
54+
proxy-request:
55+
headers:
56+
fields:
57+
- [ x-jax, { as: present } ]
58+
- [ x-jax-via, { value: 'test.proxy.test', as: equal } ]
59+
60+
server-response:
61+
status: 200
62+
reason: OK
63+
headers:
64+
fields:
65+
- [ Content-Length, 2 ]
66+
- [ Connection, close ]
67+
content:
68+
encoding: plain
69+
data: "OK"
70+
71+
proxy-response:
72+
status: 200
73+
74+
# Session 2: pre-existing x-jax-via – append mode adds proxy name to it.
75+
- protocol:
76+
- name: http
77+
version: 1
78+
- name: tcp
79+
- name: ip
80+
81+
transactions:
82+
83+
- client-request:
84+
method: GET
85+
url: /resource-with-via
86+
version: '1.1'
87+
headers:
88+
fields:
89+
- [ Host, jax.server.test ]
90+
- [ Content-Length, 0 ]
91+
- [ uuid, append-existing-via ]
92+
- [ x-jax-via, upstream-via ]
93+
94+
# append mode: proxy name is inserted as an additional value, yielding
95+
# the comma-separated form "upstream-via, test.proxy.test".
96+
proxy-request:
97+
headers:
98+
fields:
99+
- [ x-jax, { as: present } ]
100+
- [ x-jax-via, { value: 'upstream-via, test.proxy.test', as: equal } ]
101+
102+
server-response:
103+
status: 200
104+
reason: OK
105+
headers:
106+
fields:
107+
- [ Content-Length, 2 ]
108+
- [ Connection, close ]
109+
content:
110+
encoding: plain
111+
data: "OK"
112+
113+
proxy-response:
114+
status: 200
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
# Used by: global JA4H overwrite test.
18+
#
19+
# The jax_fingerprint plugin is loaded globally with --method JA4H
20+
# --standalone --mode overwrite. Every request should have the
21+
# fingerprint header (x-jax) and via header (x-jax-via) written by ATS
22+
# regardless of any pre-existing values.
23+
24+
meta:
25+
version: "1.0"
26+
27+
sessions:
28+
29+
# Session 1: no pre-existing x-jax header – plugin adds it.
30+
- protocol:
31+
- name: http
32+
version: 1
33+
- name: tcp
34+
- name: ip
35+
36+
transactions:
37+
38+
- client-request:
39+
method: GET
40+
url: /resource
41+
version: '1.1'
42+
headers:
43+
fields:
44+
- [ Host, jax.server.test ]
45+
- [ Content-Length, 0 ]
46+
- [ uuid, global-ja4h-request ]
47+
48+
# Global plugin (overwrite) must add both headers.
49+
proxy-request:
50+
headers:
51+
fields:
52+
- [ x-jax, { as: present } ]
53+
- [ x-jax-via, { value: 'test.proxy.test', as: equal } ]
54+
55+
server-response:
56+
status: 200
57+
reason: OK
58+
headers:
59+
fields:
60+
- [ Content-Length, 2 ]
61+
- [ Connection, close ]
62+
content:
63+
encoding: plain
64+
data: "OK"
65+
66+
proxy-response:
67+
status: 200
68+
69+
# Session 2: pre-existing x-jax header – overwrite mode replaces it.
70+
- protocol:
71+
- name: http
72+
version: 1
73+
- name: tcp
74+
- name: ip
75+
76+
transactions:
77+
78+
- client-request:
79+
method: GET
80+
url: /resource-with-header
81+
version: '1.1'
82+
headers:
83+
fields:
84+
- [ Host, jax.server.test ]
85+
- [ Content-Length, 0 ]
86+
- [ uuid, global-ja4h-overwrite ]
87+
- [ x-jax, upstream-fingerprint ]
88+
- [ x-jax-via, upstream-via ]
89+
90+
# In overwrite mode the plugin replaces the upstream values.
91+
# x-jax contains the freshly computed fingerprint (dynamic value,
92+
# so we only assert presence); x-jax-via is set to the proxy name.
93+
proxy-request:
94+
headers:
95+
fields:
96+
- [ x-jax, { as: present } ]
97+
- [ x-jax-via, { value: 'test.proxy.test', as: equal } ]
98+
99+
server-response:
100+
status: 200
101+
reason: OK
102+
headers:
103+
fields:
104+
- [ Content-Length, 2 ]
105+
- [ Connection, close ]
106+
content:
107+
encoding: plain
108+
data: "OK"
109+
110+
proxy-response:
111+
status: 200
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
# Used by: global JA4 HTTP/2 test and global JA4H HTTP/2 test.
18+
#
19+
# The client connects to ATS over HTTP/2 (h2 over TLS). ATS forwards
20+
# to the backend over HTTPS/1.1.
21+
#
22+
# JA3/JA4: the TLS ClientHello includes an h2 ALPN extension, so the
23+
# computed fingerprint differs from a plain HTTP/1.1 TLS session.
24+
#
25+
# JA4H: TxnDatasource::get_version() detects HTTP/2 via
26+
# TSHttpTxnClientProtocolStackContains(txn, "h2"), producing an
27+
# h2-specific fingerprint value.
28+
#
29+
# In both cases the plugin writes x-jax and x-jax-via into the
30+
# HTTP/1.1 proxy-request that ATS sends upstream. Header field names
31+
# are already lowercase so HTTP/2's mandatory-lowercase rule does not
32+
# introduce any new behaviour to verify here.
33+
34+
meta:
35+
version: "1.0"
36+
37+
sessions:
38+
39+
# Session 1: HTTP/2 request without pre-existing x-jax – plugin adds it.
40+
- protocol:
41+
- name: http
42+
version: 2
43+
- name: tls
44+
sni: jax.server.test
45+
- name: tcp
46+
- name: ip
47+
48+
transactions:
49+
50+
- client-request:
51+
headers:
52+
fields:
53+
- [ :method, GET ]
54+
- [ :scheme, https ]
55+
- [ :authority, jax.server.test ]
56+
- [ :path, /resource-h2 ]
57+
- [ uuid, global-h2-request ]
58+
59+
# ATS translates to HTTP/1.1 toward the backend; the plugin must have
60+
# written both headers into this outgoing request.
61+
proxy-request:
62+
headers:
63+
fields:
64+
- [ x-jax, { as: present } ]
65+
- [ x-jax-via, { value: 'test.proxy.test', as: equal } ]
66+
67+
server-response:
68+
headers:
69+
fields:
70+
- [ :status, 200 ]
71+
- [ Content-Length, 2 ]
72+
- [ X-Response, global-h2-response ]
73+
- [ Connection, close ]
74+
75+
proxy-response:
76+
headers:
77+
fields:
78+
- [ :status, { value: 200, as: equal } ]
79+
80+
# Session 2: HTTP/2 request with pre-existing x-jax – overwrite mode
81+
# replaces the upstream value with the freshly computed fingerprint.
82+
- protocol:
83+
- name: http
84+
version: 2
85+
- name: tls
86+
sni: jax.server.test
87+
- name: tcp
88+
- name: ip
89+
90+
transactions:
91+
92+
- client-request:
93+
headers:
94+
fields:
95+
- [ :method, GET ]
96+
- [ :scheme, https ]
97+
- [ :authority, jax.server.test ]
98+
- [ :path, /resource-h2-with-header ]
99+
- [ uuid, global-h2-overwrite ]
100+
- [ x-jax, upstream-fingerprint ]
101+
- [ x-jax-via, upstream-via ]
102+
103+
# Overwrite mode: both upstream values must be replaced by the plugin.
104+
proxy-request:
105+
headers:
106+
fields:
107+
- [ x-jax, { as: present } ]
108+
- [ x-jax-via, { value: 'test.proxy.test', as: equal } ]
109+
110+
server-response:
111+
headers:
112+
fields:
113+
- [ :status, 200 ]
114+
- [ Content-Length, 2 ]
115+
- [ X-Response, global-h2-overwrite-response ]
116+
- [ Connection, close ]
117+
118+
proxy-response:
119+
headers:
120+
fields:
121+
- [ :status, { value: 200, as: equal } ]

0 commit comments

Comments
 (0)