network_policy.slt 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. # Copyright Materialize, Inc. and contributors. All rights reserved.
  2. #
  3. # Use of this software is governed by the Business Source License
  4. # included in the LICENSE file at the root of this repository.
  5. #
  6. # As of the Change Date specified in that file, in accordance with
  7. # the Business Source License, use of this software will be governed
  8. # by the Apache License, Version 2.0.
  9. # Test for `NETWORK POLICIES`.
  10. mode standard
  11. # Start from a pristine state
  12. reset-server
  13. # Verify initial Network Policies.
  14. query TTT rowsort
  15. select * from (SHOW NETWORK POLICIES)
  16. ----
  17. default
  18. open_ingress
  19. (empty)
  20. simple conn=mz_system,user=mz_system
  21. ALTER SYSTEM SET enable_network_policies=on
  22. ----
  23. COMPLETE 0
  24. simple conn=mz_system,user=mz_system
  25. CREATE NETWORK POLICY np (RULES ( r1 (address='0.0.0.0/32', action='allow', direction='ingress'), r2 (address='0.0.0.1/32', action='allow', direction='ingress') ))
  26. ----
  27. COMPLETE 0
  28. query TTT rowsort
  29. SELECT * FROM (SHOW NETWORK POLICIES)
  30. ----
  31. default
  32. open_ingress
  33. (empty)
  34. np
  35. r1,r2
  36. (empty)
  37. query TTT valuesort
  38. SELECT id, name, owner_id FROM mz_internal.mz_network_policies
  39. ----
  40. u2
  41. np
  42. s1
  43. u1
  44. default
  45. s1
  46. query TTTTT colnames,valuesort
  47. SELECT * FROM mz_internal.mz_network_policy_rules
  48. ----
  49. name policy_id action address direction
  50. r1
  51. u2
  52. allow
  53. 0.0.0.0/32
  54. ingress
  55. r2
  56. u2
  57. allow
  58. 0.0.0.1/32
  59. ingress
  60. open_ingress
  61. u1
  62. allow
  63. 0.0.0.0/0
  64. ingress
  65. simple conn=mz_system,user=mz_system
  66. ALTER NETWORK POLICY np SET (RULES (r1 (address='1.1.1.1/32', action='allow', direction='ingress') ));
  67. ----
  68. COMPLETE 0
  69. query TTTTT colnames,valuesort
  70. SELECT * FROM mz_internal.mz_network_policy_rules
  71. ----
  72. name policy_id action address direction
  73. r1
  74. u2
  75. allow
  76. 1.1.1.1/32
  77. ingress
  78. open_ingress
  79. u1
  80. allow
  81. 0.0.0.0/0
  82. ingress
  83. simple conn=mz_system,user=mz_system
  84. DROP NETWORK POLICY np;
  85. ----
  86. COMPLETE 0
  87. query TTT rowsort
  88. select * from (SHOW NETWORK POLICIES)
  89. ----
  90. default
  91. open_ingress
  92. (empty)