chromium/chrome/enterprise_companion/test/test_server.h

// Copyright 2024 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_ENTERPRISE_COMPANION_TEST_TEST_SERVER_H_
#define CHROME_ENTERPRISE_COMPANION_TEST_TEST_SERVER_H_

#include <list>
#include <memory>
#include <string>
#include <utility>
#include <vector>

#include "base/time/time.h"
#include "chrome/enterprise_companion/enterprise_companion_status.h"
#include "chrome/enterprise_companion/proto/enterprise_companion_event.pb.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "net/test/embedded_test_server/http_request.h"
#include "net/test/embedded_test_server/http_response.h"

class GURL;

namespace enterprise_companion {

// Defines a generic matcher to match expectations for a request.
Matcher;

// Defines a group of matchers which all must pass in order to match a request.
// This allows for combining several matchers when matching a single request.
using MatcherGroup = std::list<Matcher>;

class TestServer {};

// Creates a matcher that expects an event log containing the provided events
// and outcomes.
Matcher CreateEventLogMatcher(
    const TestServer& test_server,
    const std::vector<std::pair<proto::EnterpriseCompanionEvent::EventCase,
                                EnterpriseCompanionStatus>>& expected_events);

// Create and serialize a LogResponse proto.
std::string CreateLogResponse(
    const base::TimeDelta& next_request_wait = base::Seconds(0));

}  // namespace enterprise_companion

#endif  // CHROME_ENTERPRISE_COMPANION_TEST_TEST_SERVER_H_