Skip to content

Commit b58bfa5

Browse files
authored
Merge pull request #9 from parallaxsecond/jn9e9/issue8
fix #8
2 parents 600495a + c49958f commit b58bfa5

26 files changed

+606
-3
lines changed

generator/generator.py

+14
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,18 @@
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 ( # noqa: F401
25+
gen as list_clients_admin_err,
26+
)
27+
from generators.delete_client import gen as delete_client # noqa: F401
28+
from generators.list_authenticators import gen as list_authenticators # noqa: F401
29+
from generators.delete_client_admin_err import ( # noqa: F401
30+
gen as delete_client_admin_err,
31+
)
32+
from generators.delete_client_notexist import ( # noqa: F401
33+
gen as delete_client_notexist,
34+
)
2335

2436

2537
class TestSpec(object):
@@ -96,6 +108,8 @@ def generate_spec_data(output_folder, spec, name):
96108
"test_data": {
97109
"request": base64.b64encode(request_buf).decode("ascii"),
98110
"response": base64.b64encode(response_buf).decode("ascii"),
111+
"request_hex": "".join("{:02x}".format(x) for x in request_buf),
112+
"response_hex": "".join("{:02x}".format(x) for x in response_buf),
99113
},
100114
}
101115
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.

0 commit comments

Comments
 (0)