Skip to content

Commit 105a096

Browse files
committed
fix #8
Signed-off-by: John 9e9 <[email protected]>
1 parent 600495a commit 105a096

25 files changed

+599
-3
lines changed

generator/generator.py

+8
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@
2020
gen as list_opcodes_directauth,
2121
)
2222
from generators.list_providers import gen as list_providers # noqa: F401
23+
from generators.list_clients import gen as list_clients # noqa: F401
24+
from generators.list_clients_admin_err import gen as list_clients_admin_err # noqa: F401
25+
from generators.delete_client import gen as delete_client # noqa: F401
26+
from generators.list_authenticators import gen as list_authenticators # noqa: F401
27+
from generators.delete_client_admin_err import gen as delete_client_admin_err # noqa: F401
28+
from generators.delete_client_notexist import gen as delete_client_notexist # noqa: F401
2329

2430

2531
class TestSpec(object):
@@ -96,6 +102,8 @@ def generate_spec_data(output_folder, spec, name):
96102
"test_data": {
97103
"request": base64.b64encode(request_buf).decode("ascii"),
98104
"response": base64.b64encode(response_buf).decode("ascii"),
105+
"request_hex": "".join('{:02x}'.format(x) for x in request_buf),
106+
"response_hex": "".join('{:02x}'.format(x) for x in response_buf),
99107
},
100108
}
101109
out_path = os.path.join(output_folder, name + ".test.yaml")

generator/generators/delete_client.py

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Copyright 2021 Contributors to the Parsec project.
2+
# SPDX-License-Identifier: Apache-2.0
3+
from .protobuf import delete_client_pb2
4+
5+
6+
def gen():
7+
operation = delete_client_pb2.Operation()
8+
operation.client = "existing client"
9+
result = delete_client_pb2.Result()
10+
return (operation.SerializeToString(), result.SerializeToString())
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Copyright 2021 Contributors to the Parsec project.
2+
# SPDX-License-Identifier: Apache-2.0
3+
from .protobuf import delete_client_pb2
4+
5+
6+
def gen():
7+
operation = delete_client_pb2.Operation()
8+
operation.client = "client exists"
9+
result = delete_client_pb2.Result()
10+
return (operation.SerializeToString(), result.SerializeToString())
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Copyright 2021 Contributors to the Parsec project.
2+
# SPDX-License-Identifier: Apache-2.0
3+
from .protobuf import delete_client_pb2
4+
5+
6+
def gen():
7+
operation = delete_client_pb2.Operation()
8+
operation.client = "not exist"
9+
result = delete_client_pb2.Result()
10+
return (operation.SerializeToString(), result.SerializeToString())
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Copyright 2021 Contributors to the Parsec project.
2+
# SPDX-License-Identifier: Apache-2.0
3+
from .protobuf import list_authenticators_pb2
4+
5+
6+
def gen():
7+
operation = list_authenticators_pb2.Operation()
8+
9+
result = list_authenticators_pb2.Result()
10+
auth_info = list_authenticators_pb2.AuthenticatorInfo()
11+
auth_info.description = "direct auth"
12+
auth_info.version_maj = 12
13+
auth_info.version_min = 42
14+
auth_info.id = 1
15+
result.authenticators.extend([auth_info])
16+
return (operation.SerializeToString(), result.SerializeToString())

generator/generators/list_clients.py

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Copyright 2021 Contributors to the Parsec project.
2+
# SPDX-License-Identifier: Apache-2.0
3+
from .protobuf import list_clients_pb2
4+
5+
6+
def gen():
7+
operation = list_clients_pb2.Operation()
8+
9+
result = list_clients_pb2.Result()
10+
result.clients.extend(["jim", "bob"])
11+
return (operation.SerializeToString(), result.SerializeToString())
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Copyright 2021 Contributors to the Parsec project.
2+
# SPDX-License-Identifier: Apache-2.0
3+
from .protobuf import list_clients_pb2
4+
5+
6+
def gen():
7+
operation = list_clients_pb2.Operation()
8+
9+
result = list_clients_pb2.Result()
10+
return (operation.SerializeToString(), result.SerializeToString())
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Copyright 2021 Contributors to the Parsec project.
2+
# SPDX-License-Identifier: Apache-2.0
3+
spec:
4+
description: Delete client with direct authenticator
5+
request:
6+
header:
7+
magic_number: 0x5EC0A710
8+
header_size: 0x1E
9+
major_version_number: 0x01
10+
minor_version_number: 0x00
11+
flags: 0x0000
12+
provider: 0x02
13+
session_handle: 0x0000000000000000
14+
content_type: 0x00
15+
accept_type: 0x00
16+
auth_type: 0x01
17+
content_length: auto
18+
auth_length: auto
19+
opcode: 0x0000001C
20+
status: 0x0000
21+
body_description: single client called "existing client"
22+
auth:
23+
type: direct
24+
app_name: admin_priv
25+
response:
26+
header:
27+
magic_number: 0x5EC0A710
28+
header_size: 0x1E
29+
major_version_number: 0x01
30+
minor_version_number: 0x00
31+
flags: 0x0000
32+
provider: 0x00
33+
session_handle: 0x0000000000000000
34+
content_type: 0x00
35+
accept_type: 0x00
36+
auth_type: 0x00
37+
content_length: auto
38+
auth_length: 0x0000
39+
opcode: 0x0000001C
40+
status: 0x0000
41+
body_description: no body
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Copyright 2021 Contributors to the Parsec project.
2+
# SPDX-License-Identifier: Apache-2.0
3+
spec:
4+
description: Delete client without admin privilege
5+
request:
6+
header:
7+
magic_number: 0x5EC0A710
8+
header_size: 0x1E
9+
major_version_number: 0x01
10+
minor_version_number: 0x00
11+
flags: 0x0000
12+
provider: 0x02
13+
session_handle: 0x0000000000000000
14+
content_type: 0x00
15+
accept_type: 0x00
16+
auth_type: 0x01
17+
content_length: auto
18+
auth_length: auto
19+
opcode: 0x0000001C
20+
status: 0x0000
21+
body_description: client called 'client exists'
22+
auth:
23+
type: direct
24+
app_name: no_admin
25+
response:
26+
header:
27+
magic_number: 0x5EC0A710
28+
header_size: 0x1E
29+
major_version_number: 0x01
30+
minor_version_number: 0x00
31+
flags: 0x0000
32+
provider: 0x00
33+
session_handle: 0x0000000000000000
34+
content_type: 0x00
35+
accept_type: 0x00
36+
auth_type: 0x00
37+
content_length: auto
38+
auth_length: 0x0000
39+
opcode: 0x0000001C
40+
status: 0x0015
41+
body_description: empty response with AdminOperation status code
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Copyright 2021 Contributors to the Parsec project.
2+
# SPDX-License-Identifier: Apache-2.0
3+
spec:
4+
description: Delete client that doesn't exist
5+
request:
6+
header:
7+
magic_number: 0x5EC0A710
8+
header_size: 0x1E
9+
major_version_number: 0x01
10+
minor_version_number: 0x00
11+
flags: 0x0000
12+
provider: 0x02
13+
session_handle: 0x0000000000000000
14+
content_type: 0x00
15+
accept_type: 0x00
16+
auth_type: 0x01
17+
content_length: auto
18+
auth_length: auto
19+
opcode: 0x0000001C
20+
status: 0x0000
21+
body_description: single client named 'not exist'
22+
auth:
23+
type: direct
24+
app_name: admin_priv
25+
response:
26+
header:
27+
magic_number: 0x5EC0A710
28+
header_size: 0x1E
29+
major_version_number: 0x01
30+
minor_version_number: 0x00
31+
flags: 0x0000
32+
provider: 0x00
33+
session_handle: 0x0000000000000000
34+
content_type: 0x00
35+
accept_type: 0x00
36+
auth_type: 0x00
37+
content_length: auto
38+
auth_length: 0x0000
39+
opcode: 0x0000001C
40+
status: 1140 # PsaErrorNotExist
41+
body_description: empty response PsaErrorNotExist error code
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Copyright 2021 Contributors to the Parsec project.
2+
# SPDX-License-Identifier: Apache-2.0
3+
spec:
4+
description: List authenticators message
5+
request:
6+
header:
7+
magic_number: 0x5EC0A710
8+
header_size: 0x1E
9+
major_version_number: 0x01
10+
minor_version_number: 0x00
11+
flags: 0x0000
12+
provider: 0x00
13+
session_handle: 0x0000000000000000
14+
content_type: 0x00
15+
accept_type: 0x00
16+
auth_type: 0x00
17+
content_length: auto
18+
auth_length: 0x0000
19+
opcode: 0x0000000E
20+
status: 0x0000
21+
body_description: no parameters required
22+
auth:
23+
type: none
24+
response:
25+
header:
26+
magic_number: 0x5EC0A710
27+
header_size: 0x1E
28+
major_version_number: 0x01
29+
minor_version_number: 0x00
30+
flags: 0x0000
31+
provider: 0x00
32+
session_handle: 0x0000000000000000
33+
content_type: 0x00
34+
accept_type: 0x00
35+
auth_type: 0x00
36+
content_length: auto
37+
auth_length: 0x0000
38+
opcode: 0x0000000E
39+
status: 0x0000
40+
body_description: One direct authenticator with description "direct auth", version_maj=12, version_min=42, id=0x01
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Copyright 2021 Contributors to the Parsec project.
2+
# SPDX-License-Identifier: Apache-2.0
3+
spec:
4+
description: List clients message with direct authenticator
5+
request:
6+
header:
7+
magic_number: 0x5EC0A710
8+
header_size: 0x1E
9+
major_version_number: 0x01
10+
minor_version_number: 0x00
11+
flags: 0x0000
12+
provider: 0x02 # list_providers test spec gives this as the one provider
13+
session_handle: 0x0000000000000000
14+
content_type: 0x00
15+
accept_type: 0x00
16+
auth_type: 0x01
17+
content_length: 0
18+
auth_length: auto
19+
opcode: 0x0000001B
20+
status: 0x0000
21+
body_description: no parameters required
22+
auth:
23+
type: direct
24+
app_name: admin_priv
25+
response:
26+
header:
27+
magic_number: 0x5EC0A710
28+
header_size: 0x1E
29+
major_version_number: 0x01
30+
minor_version_number: 0x00
31+
flags: 0x0000
32+
provider: 0x00
33+
session_handle: 0x0000000000000000
34+
content_type: 0x00
35+
accept_type: 0x00
36+
auth_type: 0x00
37+
content_length: auto
38+
auth_length: 0x0000
39+
opcode: 0x0000001B
40+
status: 0x0000
41+
body_description: list clients response with jim and bob
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Copyright 2021 Contributors to the Parsec project.
2+
# SPDX-License-Identifier: Apache-2.0
3+
spec:
4+
description: List clients message with direct authenticator
5+
request:
6+
header:
7+
magic_number: 0x5EC0A710
8+
header_size: 0x1E
9+
major_version_number: 0x01
10+
minor_version_number: 0x00
11+
flags: 0x0000
12+
provider: 0x02
13+
session_handle: 0x0000000000000000
14+
content_type: 0x00
15+
accept_type: 0x00
16+
auth_type: 0x01
17+
content_length: 0
18+
auth_length: auto
19+
opcode: 0x0000001B
20+
status: 0x0000
21+
body_description: no parameters required
22+
auth:
23+
type: direct
24+
app_name: no_admin
25+
response:
26+
header:
27+
magic_number: 0x5EC0A710
28+
header_size: 0x1E
29+
major_version_number: 0x01
30+
minor_version_number: 0x00
31+
flags: 0x0000
32+
provider: 0x00
33+
session_handle: 0x0000000000000000
34+
content_type: 0x00
35+
accept_type: 0x00
36+
auth_type: 0x00
37+
content_length: auto
38+
auth_length: 0x0000
39+
opcode: 0x0000001B
40+
status: 0x0015
41+
body_description: empty response with AdminOperation status code

generator/test_specs/list_providers.spec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,4 @@ spec:
3737
auth_length: 0x0000
3838
opcode: 0x00000008
3939
status: 0x0000
40-
body_description: One provider info element with UUID "ee870e5a-ce4a-417f-8543-8fbd84b49cbe", "some empty provider" description, "Arm Ltd." vendor, version 9.8.7 and the id 2.
40+
body_description: One provider info element with UUID "ee870e5a-ce4a-417f-8543-8fbd84b49cbe", description "Some empty provider" description, vendor "Arm Ltd.", version 9.8.7 and the id 2.
+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
spec:
2+
description: Delete client with direct authenticator
3+
request:
4+
header:
5+
magic_number: 1589683984
6+
header_size: 30
7+
major_version_number: 1
8+
minor_version_number: 0
9+
flags: 0
10+
provider: 2
11+
session_handle: 0
12+
content_type: 0
13+
accept_type: 0
14+
auth_type: 1
15+
content_length: auto
16+
auth_length: auto
17+
opcode: 28
18+
status: 0
19+
body_description: single client called "existing client"
20+
auth:
21+
type: direct
22+
app_name: admin_priv
23+
response:
24+
header:
25+
magic_number: 1589683984
26+
header_size: 30
27+
major_version_number: 1
28+
minor_version_number: 0
29+
flags: 0
30+
provider: 0
31+
session_handle: 0
32+
content_type: 0
33+
accept_type: 0
34+
auth_type: 0
35+
content_length: auto
36+
auth_length: 0
37+
opcode: 28
38+
status: 0
39+
body_description: no body
40+
test_data:
41+
request: EKfAXh4AAQAAAAIAAAAAAAAAAAAAAREAAAAKABwAAAAAAAAACg9leGlzdGluZyBjbGllbnRhZG1pbl9wcml2
42+
response: EKfAXh4AAQAAAAAAAAAAAAAAAAAAAAAAAAAAABwAAAAAAAAA
43+
request_hex: 10a7c05e1e0001000000020000000000000000000001110000000a001c000000000000000a0f6578697374696e6720636c69656e7461646d696e5f70726976
44+
response_hex: 10a7c05e1e00010000000000000000000000000000000000000000001c00000000000000

0 commit comments

Comments
 (0)