Skip to content

Commit

Permalink
Updating Frozen Play Session Test Cookie
Browse files Browse the repository at this point in the history
Running

Prometheus metric sampler now has two samples which was breaking tests
  • Loading branch information
gwendolyngoetz committed Jun 10, 2024
1 parent 1f77670 commit 179a61b
Show file tree
Hide file tree
Showing 19 changed files with 41 additions and 35 deletions.
2 changes: 1 addition & 1 deletion browser-test/src/support/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ export const {
// This value was extracted from the browser test env via:
//
// python -c "import requests;print(requests.Session().get('http://localhost:9999').cookies.get_dict()['PLAY_SESSION'])"
FROZEN_PLAY_SESSION_COOKIE_VALUE = 'eyJhbGciOiJIUzI1NiJ9.eyJkYXRhIjp7InNlc3Npb25JZCI6IjU1MTMwZDYyLTA3M2QtNDQwNi05MGI5LWJkOWU0NjNhM2U5NyIsInBhYzRqIjoiWDFBM1Z6YnVUOVJLZ24xNmZ1QXNCT25DY0swb1BwcFA3NTlUMzR1NXAvTndMNk5qS2ovL0dyZDhaUUN5UU1FcUhvbXJsTEV0VXJPYnFZRlp4dXlOck8wb3Boayt2eFhYY3dzWis4YUZxeHpLWnkvdlBtcnIvd3FVT21SRjhPNm1SZzBqQ2hZRjB4ZFdBa0lQNGlnNUhkZW5tZlptSHcyYmg2N2JVWnB1MGlMREFTQmdGbHhEaDdDamdHRXNGZnRGYmVSRWtoVjFUdzZacWxDZTM3MFR3dXg2NmNmSWp2c092NHN4Q0FMVG4wVGVxbUR4K2tpM29ibWQ1TFNyLzhhb1RBY2kzTGFoOERLczQrVWxKUHpKOGZLVHZkTzFXS0kwSjZ0MjdBbGx2T2N1ZkxtRVJXM0Y2dnpVU0l5bTVMa1ZSS01hUlFWOG9Da1JESlQrV09xQk1qTDBJdXJ3SUFrQ3UyZCtqUmxTZklqTnBISWVvcDFrUTNEa1BMejM0QVNvNEVNWml1VUhER3lWZkZhWW5aK2YyVWZESkxWeWs2ZmhRNjBZTWlXRG5OMUtHSGlON3UzcVIzZ3grSVZ3OWtON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JVHMwT0pZV3FCcFFNV055dm5lMWtWTi9TVUNXWmZGY3lsb2poWjdZYjdvM2Y5UzExcEJKSkhndGVVb3JjZnBRTUwvMnNQNDZmbm5ETzI2TmttZ1hneC9DVGZ0N3lWbXpRVGFVZ1VOTUYxcHJ4RVIxTVM1aDF3THEzcFdNamp6NTZFWlpCblE1NmswQm81d2gzaUJ6ci9PWXpQT2R6L3pqZWNKSlpMZCttK1gwQWdxbm1mL3B3WTBRZVJUOWgyR2ZFRnFoWXM0bFVaeVdFSWxCUW1Tc0tmYm9TZXo3RE92NmhTT1ZWZVhzeUFOWm9SUXRFZE9WWlZtdy8xQlpxWU9hb0NLRHhrVmdaaDhrUUJVdUkyckNTb015cC9OSndpakxOUXpSK1hab3ZCRkZUcFZFcGFreEtwb2RtditRakhOdE03a1p3MjE3WjlETWcrTVhuK2pneHhuZEtraVdDWVo1T0luMGVyOVZxaXdPOWo0RWtOQWpuY3RlZVp1S29RUmdUWEZ1ejNpbEdOVFB2dmlkREw5MEg4WjYxSWNMeE42bGp1SW5LZFFQL2VxVjlUK2JMc0gwUnBLK2tMbnNtVWd0ZE4ybFJxUm05Vm90b2lKdGJYUTI2MFF2ZS9SMjZFMUdyUXc9PSIsImNzcmZUb2tlbiI6ImQ4OGJmYWI4NTUzYTRlMzkwNDYwZTgzMmMyYjhjZjI2ZjY0ZjFjMmYtMTcxNTU0Njk0Mzc1Ny05YmQxMTg5NzJkNGU0ZGVhYzYyMjFjN2QifSwibmJmIjoxNzE1NTQ2OTQzLCJpYXQiOjE3MTU1NDY5NDN9.66hG4yG3ogUdG15qecQ-0LvGKz0CMnjNQRs_m9Tkl9c',
} = process.env
10 changes: 5 additions & 5 deletions server/app/durablejobs/DurableJob.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
import models.PersistedDurableJobModel;

/**
* Represents code that runs in a background thread. In contrast to Akka tasks, they are backed by
* {@link PersistedDurableJobModel} records in the database, making them durable to server failures
* and allowing automated retry logic. The behavior of a {@code DurableJob} is determined by its
* implementing class, which is identified by its associated {@link PersistedDurableJobModel} record
* via the {@code jobName} attribute.
* Represents code that runs in a background thread. In contrast to org.apache.pekko tasks, they are
* backed by {@link PersistedDurableJobModel} records in the database, making them durable to server
* failures and allowing automated retry logic. The behavior of a {@code DurableJob} is determined
* by its implementing class, which is identified by its associated {@link PersistedDurableJobModel}
* record via the {@code jobName} attribute.
*/
public abstract class DurableJob {

Expand Down
2 changes: 1 addition & 1 deletion server/app/durablejobs/DurableJobExecutionContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import static com.google.common.base.Preconditions.checkNotNull;

import akka.actor.ActorSystem;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.apache.pekko.actor.ActorSystem;
import play.libs.concurrent.CustomExecutionContext;

/** Thread pool for executing durable jobs. */
Expand Down
10 changes: 5 additions & 5 deletions server/app/filters/ApiKeyUsageFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import javax.inject.Provider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import play.api.libs.concurrent.AkkaSchedulerProvider;
import play.api.libs.concurrent.PekkoSchedulerProvider;
import play.mvc.EssentialAction;
import play.mvc.EssentialFilter;
import play.mvc.Http;
Expand All @@ -28,7 +28,7 @@
*/
public class ApiKeyUsageFilter extends EssentialFilter {

private final AkkaSchedulerProvider akkaSchedulerProvider;
private final PekkoSchedulerProvider pekkoSchedulerProvider;
private final Provider<ApiKeyService> apiKeyServiceProvider;
private final Executor exec;
private final Provider<ProfileUtils> profileUtilsProvider;
Expand All @@ -37,12 +37,12 @@ public class ApiKeyUsageFilter extends EssentialFilter {

@Inject
public ApiKeyUsageFilter(
AkkaSchedulerProvider akkaSchedulerProvider,
PekkoSchedulerProvider pekkoSchedulerProvider,
Provider<ApiKeyService> apiKeyServiceProvider,
Executor exec,
Provider<ProfileUtils> profileUtilsProvider,
ClientIpResolver clientIpResolver) {
this.akkaSchedulerProvider = checkNotNull(akkaSchedulerProvider);
this.pekkoSchedulerProvider = checkNotNull(pekkoSchedulerProvider);
this.apiKeyServiceProvider = checkNotNull(apiKeyServiceProvider);
this.exec = checkNotNull(exec);
this.profileUtilsProvider = checkNotNull(profileUtilsProvider);
Expand All @@ -67,7 +67,7 @@ public EssentialAction apply(EssentialAction next) {
if (maybeApiKeyId.isPresent()) {
String remoteAddress = clientIpResolver.resolveClientIp(request);

akkaSchedulerProvider
pekkoSchedulerProvider
.get()
.scheduleOnce(
Duration.ZERO,
Expand Down
2 changes: 1 addition & 1 deletion server/app/filters/CiviFormProfileFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
import static controllers.CallbackController.REDIRECT_TO_SESSION_KEY;
import static play.mvc.Results.redirect;

import akka.stream.Materializer;
import auth.GuestClient;
import auth.ProfileUtils;
import com.google.inject.Inject;
import controllers.routes;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
import java.util.function.Function;
import org.apache.pekko.stream.Materializer;
import play.mvc.Filter;
import play.mvc.Http;
import play.mvc.Result;
Expand Down
2 changes: 1 addition & 1 deletion server/app/filters/SettingsFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

import static com.google.common.base.Preconditions.checkNotNull;

import akka.stream.Materializer;
import com.google.common.collect.ImmutableList;
import javax.inject.Inject;
import javax.inject.Provider;
import org.apache.pekko.stream.Materializer;
import play.libs.streams.Accumulator;
import play.mvc.EssentialAction;
import play.mvc.EssentialFilter;
Expand Down
2 changes: 1 addition & 1 deletion server/app/modules/DatabaseSeedModule.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package modules;

import akka.actor.ActorSystem;
import com.google.inject.AbstractModule;
import com.google.inject.Inject;
import java.time.Duration;
import javax.inject.Provider;
import org.apache.pekko.actor.ActorSystem;
import scala.concurrent.ExecutionContext;
import services.seeding.DatabaseSeedTask;

Expand Down
6 changes: 4 additions & 2 deletions server/app/modules/DurableJobModule.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package modules;

import akka.actor.ActorSystem;
import annotations.BindingAnnotations;
import com.google.inject.AbstractModule;
import com.google.inject.Inject;
Expand All @@ -20,6 +19,7 @@
import java.time.Duration;
import java.time.LocalDateTime;
import java.util.Random;
import org.apache.pekko.actor.ActorSystem;
import repository.AccountRepository;
import repository.PersistedDurableJobRepository;
import repository.ReportingRepository;
Expand All @@ -41,7 +41,9 @@ protected void configure() {
bind(DurableJobRunnerScheduler.class).asEagerSingleton();
}

/** Schedules the job runner to run on an interval using the akka scheduling system. */
/**
* Schedules the job runner to run on an interval using the org.apache.pekko scheduling system.
*/
public static final class DurableJobRunnerScheduler {

@Inject
Expand Down
2 changes: 1 addition & 1 deletion server/app/modules/SettingsMigrationModule.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package modules;

import akka.actor.ActorSystem;
import com.google.inject.AbstractModule;
import com.google.inject.Inject;
import java.time.Duration;
import javax.inject.Provider;
import org.apache.pekko.actor.ActorSystem;
import scala.concurrent.ExecutionContext;
import services.settings.SettingsService;

Expand Down
2 changes: 1 addition & 1 deletion server/app/repository/DatabaseExecutionContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import static com.google.common.base.Preconditions.checkNotNull;

import akka.actor.ActorSystem;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.apache.pekko.actor.ActorSystem;
import play.libs.concurrent.CustomExecutionContext;

/** Custom execution context wired to "database.dispatcher" thread pool */
Expand Down
2 changes: 1 addition & 1 deletion server/app/services/program/ActiveAndDraftPrograms.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import static com.google.common.base.Preconditions.checkNotNull;

import akka.japi.Pair;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
Expand All @@ -14,6 +13,7 @@
import java.util.function.Function;
import models.DisplayMode;
import models.VersionModel;
import org.apache.pekko.japi.Pair;
import repository.VersionRepository;

/**
Expand Down
2 changes: 1 addition & 1 deletion server/app/services/question/ActiveAndDraftQuestions.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package services.question;

import akka.japi.Pair;
import com.google.auto.value.AutoValue;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
Expand All @@ -9,6 +8,7 @@
import java.util.Optional;
import java.util.function.Function;
import models.VersionModel;
import org.apache.pekko.japi.Pair;
import repository.VersionRepository;
import services.DeletionStatus;
import services.program.ProgramDefinition;
Expand Down
4 changes: 2 additions & 2 deletions server/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ lazy val root = (project in file("."))
"com.h2database" % "h2" % "2.2.224" % Test,

// Metrics collection and export for Prometheus
"io.github.jyllands-posten" %% "play-prometheus-filters" % "0.6.1",
"io.github.jyllands-posten" %% "play-prometheus-filters" % "1.0.2",

// Parameterized testing
"pl.pragmatists" % "JUnitParams" % "1.1.1" % Test,
Expand All @@ -74,7 +74,7 @@ lazy val root = (project in file("."))

// Security libraries
// pac4j core (https://github.com/pac4j/play-pac4j)
"org.pac4j" %% "play-pac4j" % "12.0.0-PLAY2.9",
"org.pac4j" %% "play-pac4j" % "12.0.0-PLAY3.0",
"org.pac4j" % "pac4j-core" % "6.0.2",
// basic http authentication (for the anonymous client)
"org.pac4j" % "pac4j-http" % "6.0.2",
Expand Down
14 changes: 7 additions & 7 deletions server/conf/application.conf
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,20 @@ include "helper/whitelabel.conf"
## filters/LoggingFilter configuration. Overrided in application.dev.conf.
filters.LoggingFilter.enable_request_session_logging = false

## Akka
# https://www.playframework.com/documentation/latest/ScalaAkka#Configuration
# https://www.playframework.com/documentation/latest/JavaAkka#Configuration
## Pekko
# https://www.playframework.com/documentation/latest/ScalaPekko#Configuration
# https://www.playframework.com/documentation/latest/JavaPekko#Configuration
# ~~~~~
# Play uses Akka internally and exposes Akka Streams and actors in Websockets and
# Play uses Pekko internally and exposes Pekko Streams and actors in Websockets and
# other streaming HTTP responses.
akka {
# "akka.log-config-on-start" is extraordinarly useful because it log the complete
pekko {
# "pekko.log-config-on-start" is extraordinarly useful because it log the complete
# configuration at INFO level, including defaults and overrides, so it s worth
# putting at the very top.
#
# Put the following in your conf/logback.xml file:
#
# <logger name="akka.actor" level="INFO" />
# <logger name="org.apache.pekko.actor" level="INFO" />
#
# And then uncomment this line to debug the configuration.
#
Expand Down
4 changes: 2 additions & 2 deletions server/project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Play plugins
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.9.2")
addSbtPlugin("com.typesafe.play" % "sbt-play-ebean" % "7.3.0")
addSbtPlugin("org.playframework" % "sbt-plugin" % "3.0.3")
addSbtPlugin("org.playframework" % "sbt-play-ebean" % "8.3.0")

// Dependency tree plugin. To use, open an sbt shell and run dependencyBrowseTree
addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.10.0-RC1")
Expand Down
4 changes: 4 additions & 0 deletions server/test/controllers/applicant/ApplicantRoutesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ private Counts getApplicantIdInProfileCounts() {
for (MetricFamilySamples mfs : Collections.list(registry.metricFamilySamples())) {
if (mfs.name.equals("applicant_id_in_profile")) {
for (MetricFamilySamples.Sample sample : mfs.samples) {
if (!sample.name.equals("applicant_id_in_profile_total")) {
continue;
}

if (sample.labelValues.contains("present")) {
counts.present = sample.value;
} else if (sample.labelValues.contains("absent")) {
Expand Down
2 changes: 1 addition & 1 deletion server/test/filters/RecordCookieSizeFilterTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
import static org.assertj.core.api.Assertions.assertThat;
import static play.test.Helpers.fakeRequest;

import akka.stream.testkit.NoMaterializer$;
import com.google.common.collect.ImmutableList;
import io.prometheus.client.CollectorRegistry;
import java.util.List;
import java.util.stream.Collectors;
import org.apache.pekko.stream.testkit.NoMaterializer$;
import org.junit.Before;
import org.junit.Test;
import play.libs.streams.Accumulator;
Expand Down
2 changes: 1 addition & 1 deletion server/test/filters/UnsupportedBrowserFilterTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
import static org.assertj.core.api.Assertions.assertThat;
import static play.test.Helpers.fakeRequest;

import akka.stream.testkit.NoMaterializer$;
import com.google.common.collect.ImmutableList;
import junitparams.JUnitParamsRunner;
import junitparams.Parameters;
import org.apache.pekko.stream.testkit.NoMaterializer$;
import org.junit.Test;
import org.junit.runner.RunWith;
import play.libs.streams.Accumulator;
Expand Down
2 changes: 1 addition & 1 deletion server/test/repository/ResetPostgres.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import static play.test.Helpers.fakeApplication;

import akka.stream.Materializer;
import io.ebean.DB;
import io.ebean.Database;
import java.time.Clock;
Expand All @@ -11,6 +10,7 @@
import models.LifecycleStage;
import models.Models;
import models.VersionModel;
import org.apache.pekko.stream.Materializer;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
Expand Down

0 comments on commit 179a61b

Please sign in to comment.