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

Lines changed: 8 additions & 0 deletions
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

Lines changed: 10 additions & 0 deletions
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())
Lines changed: 10 additions & 0 deletions
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())
Lines changed: 10 additions & 0 deletions
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())
Lines changed: 16 additions & 0 deletions
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

Lines changed: 11 additions & 0 deletions
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())
Lines changed: 10 additions & 0 deletions
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())
Lines changed: 41 additions & 0 deletions
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
Lines changed: 41 additions & 0 deletions
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
Lines changed: 41 additions & 0 deletions
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

0 commit comments

Comments
 (0)