restore core gRPC server tests & add testing framework for gateway handlers#2381
Conversation
# Conflicts: # crates/defguard_core/tests/integration/grpc/gateway.rs
There was a problem hiding this comment.
Pull request overview
Restores and modernizes gRPC-related test coverage by (1) re-enabling defguard_core integration gRPC tests aligned with the current “reversed communication” approach, and (2) introducing a dedicated gateway-manager handler test harness that exercises handler behavior without full TLS/cert setup.
Changes:
- Add a Unix-socket based mock gateway +
HandlerTestContextharness and comprehensive gateway handler behavior tests indefguard_gateway_manager. - Re-enable
defguard_coreintegration gRPC test module, replacing obsolete gateway tests with Worker service + health checks using a lightweight in-process test server. - Refactor gateway-manager handler connection code to support a test transport (Unix socket) and expose a test-only handler entrypoint.
Reviewed changes
Copilot reviewed 17 out of 18 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/defguard_gateway_manager/tests/mod.rs | Adds integration test module roots for gateway-manager tests. |
| crates/defguard_gateway_manager/tests/gateway_manager/mod.rs | Wires gateway-manager handler test module. |
| crates/defguard_gateway_manager/tests/gateway_manager/handler.rs | Adds extensive gateway handler behavioral tests (config handshake, updates routing, disconnect behavior, peer-stats filtering). |
| crates/defguard_gateway_manager/tests/common/mod.rs | Introduces reusable mock gateway server + handler test context (DB setup, stream control, assertions). |
| crates/defguard_gateway_manager/src/tests.rs | Removes old in-crate test scaffolding (superseded by new integration harness). |
| crates/defguard_gateway_manager/src/lib.rs | Re-exports TestGatewayHandler for integration tests. |
| crates/defguard_gateway_manager/src/handler.rs | Adds test transport (Unix socket) and TestGatewayHandler; refactors connection loop to support single-iteration handling for tests. |
| crates/defguard_gateway_manager/Cargo.toml | Moves hyper-util to regular dependencies (now used by non-test code path). |
| crates/defguard_core/tests/integration/main.rs | Re-enables the grpc integration test module. |
| crates/defguard_core/tests/integration/grpc/mod.rs | Updates gRPC integration test module list (health + worker). |
| crates/defguard_core/tests/integration/grpc/health.rs | Adds health check test validating Worker service is marked Serving. |
| crates/defguard_core/tests/integration/grpc/worker.rs | Adds Worker service integration tests (registration, job lifecycle, interceptor auth). |
| crates/defguard_core/tests/integration/grpc/gateway.rs | Removes outdated gateway gRPC integration tests. |
| crates/defguard_core/tests/integration/grpc/common/mod.rs | Reworks gRPC test server utilities (in-process server/router, JWT helpers). |
| crates/defguard_core/tests/integration/grpc/common/mock_gateway.rs | Removes legacy mock gateway implementation tied to old gateway gRPC API. |
| crates/defguard_core/src/grpc/mod.rs | Makes router builder public and marks Worker service as Serving in health reporter. |
| crates/defguard_core/Cargo.toml | Adds hyper-util for integration-test utilities. |
| Cargo.lock | Updates lockfile for new dependency usage. |
Comments suppressed due to low confidence (1)
crates/defguard_core/src/grpc/mod.rs:103
- Making
build_grpc_service_routerfullypubexpands the public API ofdefguard_coreprimarily to support integration tests. Ifdefguard_coreis intended to keep a smaller public surface, consider gating this behind atest-utilsfeature (enabled for tests) or moving the helper into a dedicated test support module/crate to avoid exposing internal server wiring as a stable API.
pub async fn build_grpc_service_router(
server: Server,
pool: PgPool,
worker_state: Arc<Mutex<WorkerState>>,
failed_logins: Arc<Mutex<FailedLoginMap>>,
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
5e55c6e to
78075b2
Compare
# Conflicts: # crates/defguard_core/tests/integration/grpc/gateway.rs # crates/defguard_gateway_manager/src/tests.rs
There was a problem hiding this comment.
Pull request overview
This PR restores and modernizes the gRPC/integration test setup around the “reversed communication” gateway flow by adding a dedicated test harness for defguard_gateway_manager and re-enabling defguard_core gRPC integration tests (focused on Worker + Health).
Changes:
- Adds a Unix-socket-based mock gateway server + shared test contexts, and comprehensive integration tests for gateway handler/manager behavior (handshake, lifecycle, retries, event routing, MFA, firewall, peer-stats filtering).
- Extends
defguard_gateway_managerwith test-support hooks (test socket transport, retry-delay overrides, counters/notifications) and updates connection/disconnection handling. - Re-enables
defguard_coregRPC integration tests (Worker service + Health) and adjusts gRPC router health reporting accordingly.
Reviewed changes
Copilot reviewed 28 out of 29 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/defguard_gateway_manager/tests/mod.rs | Adds top-level integration test modules. |
| crates/defguard_gateway_manager/tests/gateway_manager/mod.rs | Splits tests into handler vs manager suites. |
| crates/defguard_gateway_manager/tests/gateway_manager/manager.rs | Manager integration tests (startup, notifications, retries, reconnect behavior). |
| crates/defguard_gateway_manager/tests/gateway_manager/handler.rs | Test driver that includes handler test cases. |
| crates/defguard_gateway_manager/tests/gateway_manager/handler/support.rs | Shared helpers/assertions for handler tests (peer/network/firewall update assertions, device creation helpers). |
| crates/defguard_gateway_manager/tests/gateway_manager/handler/handshake.rs | Tests config request handshake behavior. |
| crates/defguard_gateway_manager/tests/gateway_manager/handler/lifecycle.rs | Tests connected/disconnected DB state transitions. |
| crates/defguard_gateway_manager/tests/gateway_manager/handler/stats.rs | Tests peer stats forwarding and endpoint validation behavior. |
| crates/defguard_gateway_manager/tests/gateway_manager/handler/network_events.rs | Tests network event routing and update payloads. |
| crates/defguard_gateway_manager/tests/gateway_manager/handler/firewall_events.rs | Tests firewall event routing and payloads. |
| crates/defguard_gateway_manager/tests/gateway_manager/handler/device_events.rs | Tests device create/modify/delete event routing and payloads. |
| crates/defguard_gateway_manager/tests/gateway_manager/handler/mfa.rs | Tests MFA session events -> peer updates. |
| crates/defguard_gateway_manager/tests/common/mod.rs | Provides mock gateway gRPC service, test contexts, socket-path registry, helper DB builders. |
| crates/defguard_gateway_manager/src/tests.rs | Removes old in-crate test scaffolding. |
| crates/defguard_gateway_manager/src/lib.rs | Adds test-support plumbing to GatewayManager (socket registry, counters, listener-ready notify, retry overrides). |
| crates/defguard_gateway_manager/src/handler.rs | Adds test socket transport option, reconnection logic refactor, exposes internal test handler wrapper, adds unit tests for config/stats conversion. |
| crates/defguard_gateway_manager/src/certs.rs | Adds unit/integration tests for certificate collection + refresh publishing. |
| crates/defguard_gateway_manager/Cargo.toml | Moves hyper-util to normal dependencies (used outside dev/test-only cfg paths now). |
| crates/defguard_core/tests/integration/main.rs | Re-enables grpc integration test module. |
| crates/defguard_core/tests/integration/grpc/mod.rs | Switches gRPC integration tests to health + worker modules. |
| crates/defguard_core/tests/integration/grpc/health.rs | Adds health check integration test. |
| crates/defguard_core/tests/integration/grpc/worker.rs | Adds worker service integration tests (auth, job flow, side effects). |
| crates/defguard_core/tests/integration/grpc/common/mod.rs | Reworks gRPC test server harness; adds JWT secret initialization + helpers for authorization metadata. |
| crates/defguard_core/tests/integration/grpc/gateway.rs | Removes legacy gateway integration tests (no longer aligned with new gateway comms model). |
| crates/defguard_core/tests/integration/grpc/common/mock_gateway.rs | Removes legacy mock gateway client (no longer used). |
| crates/defguard_core/src/grpc/mod.rs | Makes router builder public for tests; adds Worker service health “serving” reporting. |
| crates/defguard_core/Cargo.toml | Adds hyper-util dev-dependency for mock transport. |
| crates/defguard_common/src/db/models/gateway.rs | Moves Gateway::url() to generic Gateway<I> impl (usable before insert/save). |
| Cargo.lock | Adds hyper-util to workspace lockfile. |
Comments suppressed due to low confidence (1)
crates/defguard_core/src/grpc/mod.rs:106
build_grpc_service_routerwas made fullypub, which expands defguard_core's public API surface with a primarily test-oriented constructor. To avoid locking this into a supported API, consider moving this into a#[doc(hidden)] pub mod test_support(or gating it behind a feature liketest-support) and keeping the main constructorpub(crate)/private.
pub async fn build_grpc_service_router(
server: Server,
pool: PgPool,
worker_state: Arc<Mutex<WorkerState>>,
failed_logins: Arc<Mutex<FailedLoginMap>>,
// incompatible_components: Arc<RwLock<IncompatibleComponents>>,
) -> Result<Router, anyhow::Error> {
let auth_service = AuthServiceServer::new(AuthServer::new(pool.clone(), failed_logins));
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
# Conflicts: # crates/defguard_gateway_manager/src/handler.rs
There was a problem hiding this comment.
Pull request overview
This PR re-enables and modernizes gRPC integration tests in defguard_core (aligned with the newer “reversed” gateway communication) and introduces a dedicated testing harness + suite for defguard_gateway_manager handlers/managers to validate runtime behavior (handshake, event routing, retries, peer-stats filtering).
Changes:
- Re-enable
defguard_coregRPC integration tests (replacing old gateway-mock tests with worker/health-focused tests and updated test router utilities). - Add a full
defguard_gateway_managertest framework (mock gateway over Unix sockets, manager/handler contexts, and scenario coverage). - Reduce test flakiness via shared-state guards/locks across setup/API/enterprise tests and supporting helpers (JWT secret overrides, test-only gRPC router access).
Reviewed changes
Copilot reviewed 48 out of 49 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/defguard_setup/tests/wizard_state.rs | Serializes setup-server tests via a shared async test guard. |
| crates/defguard_setup/tests/session_info.rs | Serializes setup/migration session-info tests via the test guard. |
| crates/defguard_setup/tests/migration_wizard.rs | Updates migration wizard tests to use the shared test guard. |
| crates/defguard_setup/tests/initial_setup.rs | Updates initial setup tests to use the shared test guard. |
| crates/defguard_setup/tests/common/mod.rs | Introduces a global async mutex guard and threads it through the test client to prevent concurrent interference. |
| crates/defguard_setup/tests/auto_adoption_wizard.rs | Updates auto-adoption tests to use the shared test guard. |
| crates/defguard_gateway_manager/src/tests/mod.rs | Adds the new unit-test module root for gateway manager tests. |
| crates/defguard_gateway_manager/src/tests/gateway_manager/mod.rs | Adds submodules for handler/manager test suites. |
| crates/defguard_gateway_manager/src/tests/gateway_manager/manager.rs | Adds manager-level behavior tests (startup, notifications, reconnect/retry semantics). |
| crates/defguard_gateway_manager/src/tests/gateway_manager/handler/support.rs | Adds shared test helpers/assertions for handler update payloads and seeded DB state. |
| crates/defguard_gateway_manager/src/tests/gateway_manager/handler/stats.rs | Adds handler tests ensuring peer-stats are ignored pre-handshake and malformed endpoints are dropped. |
| crates/defguard_gateway_manager/src/tests/gateway_manager/handler/network_events.rs | Adds handler tests for routing network create/modify/delete events. |
| crates/defguard_gateway_manager/src/tests/gateway_manager/handler/mfa.rs | Adds handler tests for MFA session authorized/disconnected → peer create/delete updates. |
| crates/defguard_gateway_manager/src/tests/gateway_manager/handler/lifecycle.rs | Adds handler lifecycle tests (DB connected/disconnected timestamps). |
| crates/defguard_gateway_manager/src/tests/gateway_manager/handler/handshake.rs | Adds handler handshake tests (config request/response, ignore repeats). |
| crates/defguard_gateway_manager/src/tests/gateway_manager/handler/firewall_events.rs | Adds handler tests for firewall config changed/disabled events. |
| crates/defguard_gateway_manager/src/tests/gateway_manager/handler/device_events.rs | Adds handler tests for device create/modify/delete updates + ignore rules. |
| crates/defguard_gateway_manager/src/tests/gateway_manager/handler.rs | Aggregates handler test modules via include! and shared support module. |
| crates/defguard_gateway_manager/src/tests/common/mod.rs | Implements mock gateway gRPC service + test contexts for manager/handler, using Unix sockets. |
| crates/defguard_gateway_manager/src/tests.rs | Removes legacy/obsolete gateway handler test scaffold. |
| crates/defguard_gateway_manager/src/lib.rs | Adds test-support plumbing (socket overrides, counters/notifiers, retry overrides) and improves task lifecycle control. |
| crates/defguard_gateway_manager/src/handler.rs | Adds test transport over Unix sockets, refactors connection loop for testability, and improves reconnect handling structure. |
| crates/defguard_gateway_manager/src/certs.rs | Adds unit/integration tests for cert refresh behavior and filtering semantics. |
| crates/defguard_gateway_manager/Cargo.toml | Moves hyper-util dependency (currently to normal deps). |
| crates/defguard_core/tests/integration/main.rs | Re-enables the gRPC integration test module. |
| crates/defguard_core/tests/integration/grpc/worker.rs | Adds worker-service integration tests (register/get_job/set_job_done + auth interceptor coverage). |
| crates/defguard_core/tests/integration/grpc/mod.rs | Switches gRPC test modules to health and worker (drops old gateway tests). |
| crates/defguard_core/tests/integration/grpc/health.rs | Adds gRPC health-check integration test for the worker service. |
| crates/defguard_core/tests/integration/grpc/gateway.rs | Removes legacy gateway gRPC integration tests (outdated comms direction/auth model). |
| crates/defguard_core/tests/integration/grpc/common/mod.rs | Reworks gRPC test server harness (JWT override init, test_support router, worker/app events). |
| crates/defguard_core/tests/integration/grpc/common/mock_gateway.rs | Removes legacy mock gateway (no longer matches current gateway↔core approach). |
| crates/defguard_core/tests/integration/api/common/mod.rs | Adds a global async lock and plumbs it through API test client creation. |
| crates/defguard_core/tests/integration/api/common/client.rs | Keeps API lock guard alive for the lifetime of the test client/server task. |
| crates/defguard_core/tests/integration/api/acl/mod.rs | Updates ACL API tests to acquire/pass the API test guard. |
| crates/defguard_core/src/handlers/user.rs | Adjusts LDAP sync-allowed checks to use the new executor expectations. |
| crates/defguard_core/src/grpc/mod.rs | Marks Worker service as “serving” in health and exposes a doc-hidden router builder for tests. |
| crates/defguard_core/src/enterprise/mod.rs | Adds a shared async mutex lock for enterprise tests that mutate global license state. |
| crates/defguard_core/src/enterprise/ldap/tests.rs | Serializes specific LDAP enterprise tests using the shared enterprise test lock. |
| crates/defguard_core/src/enterprise/ldap/model.rs | Changes ldap_sync_allowed_for_user to Acquire and reads settings from DB via an acquired connection. |
| crates/defguard_core/src/enterprise/firewall/tests/mod.rs | Introduces an enterprise-test lock helper for firewall test modules. |
| crates/defguard_core/src/enterprise/firewall/tests/destination.rs | Uses the enterprise-test lock guard to serialize license/stateful tests. |
| crates/defguard_core/src/enterprise/firewall/tests/all_locations.rs | Uses the enterprise-test lock guard to serialize license/stateful tests. |
| crates/defguard_core/src/enterprise/directory_sync/tests.rs | Serializes directory sync enterprise tests using the enterprise test lock. |
| crates/defguard_core/Cargo.toml | Adds hyper-util for dev/integration-test support. |
| crates/defguard_common/src/db/models/gateway.rs | Moves Gateway::url() to the generic impl so it’s available for NoId gateways (test usage). |
| crates/defguard_common/src/config.rs | Rewrites new_test_config to avoid clap parsing; sets explicit test defaults. |
| crates/defguard_common/src/auth/claims.rs | Adds OnceLock-based JWT secret overrides for deterministic test token generation. |
| Cargo.lock | Updates lockfile for added dependency usage. |
| .cargo/config.toml | Forces RUST_TEST_THREADS=1 globally for cargo test. |
Comments suppressed due to low confidence (1)
crates/defguard_gateway_manager/Cargo.toml:24
hyper-utilappears to be used only inside#[cfg(test)]code (e.g., the Unix-socket connector insrc/handler.rs). Keeping it in[dependencies]pulls it into non-test builds unnecessarily. Consider moving it back to[dev-dependencies](or making it optional behind a test-only feature) so production builds don’t compile/link it.
anyhow.workspace = true
chrono.workspace = true
hyper-util = "0.1"
hyper-rustls.workspace = true
reqwest.workspace = true
semver.workspace = true
serde_json.workspace = true
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| let mut transaction = appstate.pool.begin().await?; | ||
| let ldap_sync_allowed = ldap_sync_allowed_for_user(&user, &mut *transaction).await?; | ||
| let ldap_sync_allowed = ldap_sync_allowed_for_user(&user, &appstate.pool).await?; |
There was a problem hiding this comment.
Pull request overview
This PR re-enables and reshapes parts of the gRPC test suite and introduces a more comprehensive test harness for defguard_gateway_manager gateway handlers/managers (including Unix-socket based mock gateways), while also adding test serialization guards to reduce flakiness in areas that rely on global/shared state.
Changes:
- Added a new
defguard_gateway_managertest framework (mock gateway service + manager/handler contexts) and a broad set of handler/manager tests aligned with the “reversed communication” flow. - Restored
crates/defguard_core/tests/integration/grpcas an enabled module, adding worker + health coverage and removing the legacy gateway integration tests/mocks. - Introduced test-only global locks/guards in multiple test suites and added JWT secret override support for deterministic auth in tests.
Reviewed changes
Copilot reviewed 47 out of 48 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/defguard_setup/tests/wizard_state.rs | Passes a shared async test guard into setup test client to serialize setup tests. |
| crates/defguard_setup/tests/session_info.rs | Passes a shared async test guard into setup/migration test clients. |
| crates/defguard_setup/tests/migration_wizard.rs | Passes a shared async test guard into migration test client. |
| crates/defguard_setup/tests/initial_setup.rs | Serializes setup-flow tests via guard; updates setup test client creation. |
| crates/defguard_setup/tests/common/mod.rs | Adds global OnceLock + async Mutex guard and threads it through TestClient constructors. |
| crates/defguard_setup/tests/auto_adoption_wizard.rs | Passes a shared async test guard into setup test client usage. |
| crates/defguard_gateway_manager/src/tests/mod.rs | Introduces new internal test module layout. |
| crates/defguard_gateway_manager/src/tests/gateway_manager/mod.rs | Splits gateway manager tests into handler + manager modules. |
| crates/defguard_gateway_manager/src/tests/gateway_manager/manager.rs | Adds manager lifecycle/retry/notification behavior tests. |
| crates/defguard_gateway_manager/src/tests/gateway_manager/handler/support.rs | Adds helper builders/assertions for gateway handler tests. |
| crates/defguard_gateway_manager/src/tests/gateway_manager/handler/stats.rs | Adds peer-stats forwarding/validation tests. |
| crates/defguard_gateway_manager/src/tests/gateway_manager/handler/network_events.rs | Adds network create/modify/delete routing tests. |
| crates/defguard_gateway_manager/src/tests/gateway_manager/handler/mfa.rs | Adds MFA session event → peer update tests. |
| crates/defguard_gateway_manager/src/tests/gateway_manager/handler/lifecycle.rs | Adds connected/disconnected timestamp behavior tests. |
| crates/defguard_gateway_manager/src/tests/gateway_manager/handler/handshake.rs | Adds config request handshake tests (first request / repeated request / no unsolicited config). |
| crates/defguard_gateway_manager/src/tests/gateway_manager/handler/firewall_events.rs | Adds firewall config/disable event routing tests. |
| crates/defguard_gateway_manager/src/tests/gateway_manager/handler/device_events.rs | Adds device create/modify/delete event → peer update tests. |
| crates/defguard_gateway_manager/src/tests/gateway_manager/handler.rs | Wires handler test suite via include! + shared support module. |
| crates/defguard_gateway_manager/src/tests/common/mod.rs | Implements MockGateway gRPC service + test contexts for manager/handler. |
| crates/defguard_gateway_manager/src/tests.rs | Removes legacy gateway manager test file. |
| crates/defguard_gateway_manager/src/lib.rs | Adds test support hooks (socket override, counters, listener readiness), improves reconnect timing control, and refactors notification handling. |
| crates/defguard_gateway_manager/src/handler.rs | Adds Unix-socket test transport, test-support hooks, refactors connection loop/disconnect handling, and adds targeted unit tests for config/stats conversion. |
| crates/defguard_gateway_manager/src/certs.rs | Adds unit/integration tests for certificate collection/refresh publishing behavior. |
| crates/defguard_gateway_manager/Cargo.toml | Moves hyper-util into regular dependencies (was dev-only). |
| crates/defguard_core/tests/integration/main.rs | Re-enables the grpc integration test module. |
| crates/defguard_core/tests/integration/grpc/worker.rs | Adds worker service integration tests (registration/job lifecycle/auth). |
| crates/defguard_core/tests/integration/grpc/mod.rs | Switches grpc test modules to health + worker. |
| crates/defguard_core/tests/integration/grpc/health.rs | Adds health check integration test for worker service. |
| crates/defguard_core/tests/integration/grpc/gateway.rs | Removes legacy gateway gRPC integration tests. |
| crates/defguard_core/tests/integration/grpc/common/mod.rs | Reworks gRPC test server scaffolding, adds JWT secret overrides + helpers for auth metadata. |
| crates/defguard_core/tests/integration/grpc/common/mock_gateway.rs | Removes legacy mock gateway helper. |
| crates/defguard_core/tests/integration/api/common/mod.rs | Adds a global async lock to serialize API integration tests and threads guard through client creation. |
| crates/defguard_core/tests/integration/api/common/client.rs | Stores the async test guard in TestClient to keep serialization active for the client lifetime. |
| crates/defguard_core/tests/integration/api/acl/mod.rs | Acquires and passes the API test guard for ACL client setup. |
| crates/defguard_core/src/handlers/user.rs | Adjusts LDAP sync check calls after ldap executor signature change. |
| crates/defguard_core/src/grpc/mod.rs | Marks Worker service as serving in health reporter; exposes test_support::build_grpc_service_router. |
| crates/defguard_core/src/enterprise/mod.rs | Adds a global async lock to serialize enterprise tests touching shared cached/global state. |
| crates/defguard_core/src/enterprise/ldap/tests.rs | Serializes LDAP enterprise tests using enterprise test-state lock. |
| crates/defguard_core/src/enterprise/ldap/model.rs | Changes ldap sync eligibility helper to acquire a connection and read settings from DB. |
| crates/defguard_core/src/enterprise/firewall/tests/mod.rs | Adds helper to acquire enterprise test-state lock for firewall tests. |
| crates/defguard_core/src/enterprise/firewall/tests/destination.rs | Serializes firewall destination tests via enterprise lock. |
| crates/defguard_core/src/enterprise/firewall/tests/all_locations.rs | Serializes firewall all-locations tests via enterprise lock. |
| crates/defguard_core/src/enterprise/directory_sync/tests.rs | Serializes directory sync enterprise tests via enterprise lock. |
| crates/defguard_core/Cargo.toml | Adds hyper-util as a dev-dependency for grpc test scaffolding. |
| crates/defguard_common/src/db/models/gateway.rs | Moves Gateway::url() to impl<I> so it’s available across ID/no-ID variants. |
| crates/defguard_common/src/config.rs | Replaces clap-based test config parsing with an explicit DefGuardConfig test constructor. |
| crates/defguard_common/src/auth/claims.rs | Adds process-wide JWT secret overrides for tests via OnceLock. |
| Cargo.lock | Records new dependency usage (hyper-util). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Adds testing framework and actual tests for the gateway manager service.
Also adds tests for core gRPC server.
Closes #1854