typesafehub / conductr-cli

CLI for Lightbend ConductR
Other
16 stars 21 forks source link

Expand abilities of `bndl --acl` #462

Closed longshorej closed 7 years ago

longshorej commented 7 years ago

This PR adds options to bndl --acl to allow specification of --path, --path-beg, --path-regex, and --rewrite

Example usage:

bndl my-bundle --endpoint test --acl /service --path-beg --rewrite /

longshorej commented 7 years ago

Manual Tests

Description

These tests invoke bndl with various acl options and then check the contents of the generated bundle.conf.

Setup

$ cat bundle.conf 
name = "test"
components {
  test {
  }
}
-> 0

Prior usage unaffected

$ (bndl bundle.conf --no-shazar --endpoint test --acl http:/service  | tar x) && cat test/bundle.conf && rm -r test
name = "test"
components {
  test {
    endpoints {
      test {
        bind-protocol = "http"
        bind-port = 0
        acls = [
          {
            http {
              requests = [
                {
                  path = "/service"
                }
              ]
            }
          }
        ]
      }
    }
  }
}-> 0
$ (bndl bundle.conf --no-shazar --endpoint test --acl tcp:[123]  | tar x) && cat test/bundle.conf && rm -r test
name = "test"
components {
  test {
    endpoints {
      test {
        bind-protocol = "tcp"
        bind-port = 0
        acls = [
          {
            tcp {
              requests = [
                123
              ]
            }
          }
        ]
      }
    }
  }
}-> 0
$ (bndl bundle.conf --no-shazar --endpoint test --acl 'udp:[123, 456]'  | tar x) && cat test/bundle.conf && rm -r test
name = "test"
components {
  test {
    endpoints {
      test {
        bind-protocol = "udp"
        bind-port = 0
        acls = [
          {
            udp {
              requests = [
                123
                456
              ]
            }
          }
        ]
      }
    }
  }
}-> 0

--rewrite works

$ (bndl bundle.conf --no-shazar --endpoint test --acl /service --rewrite /  | tar x) && cat test/bundle.conf && rm -r test
name = "test"
components {
  test {
    endpoints {
      test {
        bind-protocol = "http"
        bind-port = 0
        acls = [
          {
            http {
              requests = [
                {
                  path = "/service"
                  rewrite = "/"
                }
              ]
            }
          }
        ]
      }
    }
  }
}-> 0

--path-beg works

$ (bndl bundle.conf --no-shazar --endpoint test --acl /service --path-beg  | tar x) && cat test/bundle.conf && rm -r test
name = "test"
components {
  test {
    endpoints {
      test {
        bind-protocol = "http"
        bind-port = 0
        acls = [
          {
            http {
              requests = [
                {
                  path-beg = "/service"
                }
              ]
            }
          }
        ]
      }
    }
  }
}-> 0

--path-regex works

$ (bndl bundle.conf --no-shazar --endpoint test --acl /service --path-regex  | tar x) && cat test/bundle.conf && rm -r test
name = "test"
components {
  test {
    endpoints {
      test {
        bind-protocol = "http"
        bind-port = 0
        acls = [
          {
            http {
              requests = [
                {
                  path-regex = "/service"
                }
              ]
            }
          }
        ]
      }
    }
  }
}-> 0