-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AppProtect gRPC automation tests (#1603)
* Add AppProtect gRPC tests Co-authored-by: Michael Pleshakov <[email protected]>
- Loading branch information
Showing
10 changed files
with
513 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
apiVersion: appprotect.f5.com/v1beta1 | ||
kind: APPolicy | ||
metadata: | ||
name: grpc-block-saygoodbye | ||
spec: | ||
policy: | ||
blocking-settings: | ||
violations: | ||
- name: VIOL_GRPC_METHOD | ||
block: true | ||
alarm: true | ||
applicationLanguage: utf-8 | ||
bot-defense: | ||
settings: | ||
isEnabled: false | ||
grpc-profiles: | ||
- associateUrls: true | ||
defenseAttributes: | ||
allowUnknownFields: false | ||
maximumDataLength: "10000" | ||
description: My first profile | ||
idlFiles: | ||
- idlFile: | ||
fileName: autheid.proto | ||
name: gProf1 | ||
idl-files: | ||
- isBase64: true | ||
fileName: autheid.proto | ||
contents: Ly8gVGhlIGdyZWV0aW5nIHNlcnZpY2UgZGVmaW5pdGlvbi4KCnN5bnRheCA9ICJwcm90bzMiOwoKcGFja2FnZSBoZWxsb3dvcmxkOwoKc2VydmljZSBHcmVldGVyIHsKICAvLyBTZW5kcyBhIGdyZWV0aW5nCiAgcnBjIFNheUhlbGxvIChIZWxsb1JlcXVlc3QpIHJldHVybnMgKEhlbGxvUmVwbHkpIHt9Cn0KCi8vIFRoZSByZXF1ZXN0IG1lc3NhZ2UgY29udGFpbmluZyB0aGUgdXNlcidzIG5hbWUuCm1lc3NhZ2UgSGVsbG9SZXF1ZXN0IHsKICBzdHJpbmcgbmFtZSA9IDE7Cn0KCi8vIFRoZSByZXNwb25zZSBtZXNzYWdlIGNvbnRhaW5pbmcgdGhlIGdyZWV0aW5ncwptZXNzYWdlIEhlbGxvUmVwbHkgewogIHN0cmluZyBtZXNzYWdlID0gMTsKfQo= | ||
name: valid_string_encoding_policy | ||
template: | ||
name: POLICY_TEMPLATE_NGINX_BASE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
apiVersion: appprotect.f5.com/v1beta1 | ||
kind: APPolicy | ||
metadata: | ||
name: grpc-block-sayhello | ||
spec: | ||
policy: | ||
blocking-settings: | ||
violations: | ||
- name: VIOL_GRPC_METHOD | ||
block: True | ||
alarm: True | ||
applicationLanguage: utf-8 | ||
bot-defense: | ||
settings: | ||
isEnabled: false | ||
grpc-profiles: | ||
- associateUrls: true | ||
defenseAttributes: | ||
allowUnknownFields: false | ||
maximumDataLength: "10000" | ||
description: My first profile | ||
idlFiles: | ||
- idlFile: | ||
fileName: autheid.proto | ||
name: gProf1 | ||
idl-files: | ||
- isBase64: true | ||
fileName: autheid.proto | ||
contents: Ly8gVGhlIGdyZWV0aW5nIHNlcnZpY2UgZGVmaW5pdGlvbi4KCnN5bnRheCA9ICJwcm90bzMiOwoKcGFja2FnZSBoZWxsb3dvcmxkOwoKc2VydmljZSBHcmVldGVyIHsKICAvLyBTZW5kcyBhIGdyZWV0aW5nCiAgcnBjIFNheUdvb2RieWUgKEhlbGxvUmVxdWVzdCkgcmV0dXJucyAoSGVsbG9SZXBseSkge30KfQoKLy8gVGhlIHJlcXVlc3QgbWVzc2FnZSBjb250YWluaW5nIHRoZSB1c2VyJ3MgbmFtZS4KbWVzc2FnZSBIZWxsb1JlcXVlc3QgewogIHN0cmluZyBuYW1lID0gMTsKfQoKLy8gVGhlIHJlc3BvbnNlIG1lc3NhZ2UgY29udGFpbmluZyB0aGUgZ3JlZXRpbmdzCm1lc3NhZ2UgSGVsbG9SZXBseSB7CiAgc3RyaW5nIG1lc3NhZ2UgPSAxOwp9Cg== | ||
name: valid_string_encoding_policy | ||
template: | ||
name: POLICY_TEMPLATE_NGINX_BASE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
apiVersion: extensions/v1beta1 | ||
kind: Ingress | ||
metadata: | ||
name: appprotect-ingress | ||
annotations: | ||
nginx.org/grpc-services: "grpc-svc" | ||
kubernetes.io/ingress.class: "nginx" | ||
appprotect.f5.com/app-protect-policy: "default/grpc" | ||
appprotect.f5.com/app-protect-enable: "True" | ||
appprotect.f5.com/app-protect-security-log-enable: "True" | ||
appprotect.f5.com/app-protect-security-log: "default/logconf" | ||
appprotect.f5.com/app-protect-security-log-destination: "syslog:server=172.17.0.10:514" | ||
spec: | ||
tls: | ||
- hosts: | ||
- appprotect.example.com | ||
secretName: appprotect-secret | ||
rules: | ||
- host: appprotect.example.com | ||
http: | ||
paths: | ||
- path: /helloworld.Greeter | ||
backend: | ||
serviceName: grpc-svc | ||
servicePort: 50051 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
kind: ConfigMap | ||
apiVersion: v1 | ||
metadata: | ||
name: nginx-config | ||
namespace: nginx-ingress | ||
data: | ||
http2: "True" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: grpc | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: greeter | ||
template: | ||
metadata: | ||
labels: | ||
app: greeter | ||
spec: | ||
containers: | ||
- name: greeter | ||
image: nginxkic/test-grpc-server:0.1 | ||
ports: | ||
- containerPort: 50051 | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: grpc-svc | ||
spec: | ||
ports: | ||
- port: 50051 | ||
targetPort: 50051 | ||
protocol: TCP | ||
name: grpc | ||
selector: | ||
app: greeter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! | ||
import grpc | ||
|
||
from suite.grpc.helloworld_pb2 import ( | ||
HelloRequest, | ||
HelloReply, | ||
) | ||
|
||
|
||
class GreeterStub(object): | ||
"""The greeting service definition. | ||
""" | ||
|
||
def __init__(self, channel): | ||
"""Constructor. | ||
Args: | ||
channel: A grpc.Channel. | ||
""" | ||
self.SayHello = channel.unary_unary( | ||
'/helloworld.Greeter/SayHello', | ||
request_serializer=HelloRequest.SerializeToString, | ||
response_deserializer=HelloReply.FromString, | ||
) | ||
|
||
|
||
class GreeterServicer(object): | ||
"""The greeting service definition. | ||
""" | ||
|
||
def SayHello(self, request, context): | ||
"""Sends a greeting | ||
""" | ||
context.set_code(grpc.StatusCode.UNIMPLEMENTED) | ||
context.set_details('Method not implemented!') | ||
raise NotImplementedError('Method not implemented!') | ||
|
||
|
||
def add_GreeterServicer_to_server(servicer, server): | ||
rpc_method_handlers = { | ||
'SayHello': grpc.unary_unary_rpc_method_handler( | ||
servicer.SayHello, | ||
request_deserializer=HelloRequest.FromString, | ||
response_serializer=HelloReply.SerializeToString, | ||
), | ||
} | ||
generic_handler = grpc.method_handlers_generic_handler( | ||
'helloworld.Greeter', rpc_method_handlers) | ||
server.add_generic_rpc_handlers((generic_handler,)) |
Oops, something went wrong.