-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AppProtect gRPC automation tests #1603
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
fae2ce5
Add AppProtect gRPC tests
vepatel 7c3f987
Fox test marker
vepatel 716e63f
Add wait for syslog pod and hosts modification
vepatel 0632d63
Update branch with requirements
vepatel 2ca12fb
remove python_hosts and related imports
vepatel 932125e
add python proto server and client
vepatel fe7042c
Fix grpc app protect tests
pleshakov 4e82410
Add grpc files in separate dir. & update tests
vepatel 9bb67d0
Delete helloworld_pb2_grpc.py
vepatel 5ddc541
Delete helloworld_pb2.py
vepatel File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we publish the sources similarly to how we published the sources for the TCP and UDP servers? so we don't loose it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not too sure about publishing sources for this one as the code isn't written by our team members unlike TCP/UDP server one which @soneillf5 wrote. Also If we're to add source in the tests, i'd prefer adding them to
examples/
first.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in the case of the backend, it's just a Dockerfile, right? we don't really modify the backend code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where does the test-grpc-server come from then ?