We analyze equilibrium behavior and optimal policy within a Susceptible-Infected-Recovered epidemic model augmented with potentially undiagnosed agents who infer their health status and a social planner with imperfect enforcement of social distancing. We define and prove the existence of a perfect Bayesian Markov competitive equilibrium and contrast it with the efficient allocation subject to the same informational constraints. We identify two externalities, static (individual actions affect current risk of infection) and dynamic (individual actions affect future disease prevalence), and study how they are affected by limitations on testing and enforcement. We prove that a planner with imperfect enforcement will always wish to curtail activity, but that its incentives vanish as testing becomes perfect. When a vaccine arrives far into the future, the planner with perfect enforcement may encourage activity before herd immunity. We find that lockdown policies have modest welfare gains, whereas quarantine policies are effective even with imperfect testing.