mirror of
https://github.com/google/nomulus
synced 2026-01-16 10:43:06 +00:00
Compare commits
3 Commits
nomulus-20
...
test
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2a67b04f3a | ||
|
|
9f191e9392 | ||
|
|
39c2a79898 |
@@ -280,4 +280,15 @@ export class BackendService {
|
||||
`/console-api/registry-lock-verify?lockVerificationCode=${lockVerificationCode}`
|
||||
);
|
||||
}
|
||||
|
||||
requestRegistryLockPasswordReset(
|
||||
registrarId: string,
|
||||
registryLockEmail: string
|
||||
) {
|
||||
return this.http.post('/console-api/password-reset-request', {
|
||||
type: 'REGISTRY_LOCK',
|
||||
registrarId,
|
||||
registryLockEmail,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,7 +80,15 @@
|
||||
roleToDescription(userDetails().role)
|
||||
}}</span>
|
||||
</mat-list-item>
|
||||
@if (userDetails().password) {
|
||||
@if (userDetails().registryLockEmailAddress) {
|
||||
<mat-divider></mat-divider>
|
||||
<mat-list-item role="listitem">
|
||||
<span class="console-app__list-key">Registry Lock email</span>
|
||||
<span class="console-app__list-value">{{
|
||||
userDetails().registryLockEmailAddress
|
||||
}}</span>
|
||||
</mat-list-item>
|
||||
} @if (userDetails().password) {
|
||||
<mat-divider></mat-divider>
|
||||
<mat-list-item role="listitem">
|
||||
<span class="console-app__list-key">Password</span>
|
||||
|
||||
@@ -35,5 +35,8 @@
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 10px;
|
||||
}
|
||||
.console-app__list-key {
|
||||
width: 160px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,45 +1,57 @@
|
||||
<form (ngSubmit)="saveEdit($event)" #form>
|
||||
<p *ngIf="isNew()">
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label
|
||||
>User name prefix:
|
||||
<mat-icon
|
||||
matTooltip="Prefix will be combined with registrar ID to create a unique user name - {prefix}.{registrarId}@registry.google"
|
||||
>help_outline</mat-icon
|
||||
></mat-label
|
||||
>
|
||||
<input
|
||||
matInput
|
||||
minlength="3"
|
||||
maxlength="3"
|
||||
[required]="true"
|
||||
[(ngModel)]="user().emailAddress"
|
||||
[ngModelOptions]="{ standalone: true }"
|
||||
/>
|
||||
</mat-form-field>
|
||||
</p>
|
||||
<p>
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label
|
||||
>User Role:
|
||||
<mat-icon
|
||||
matTooltip="Viewer role doesn't allow making updates; Editor role allows updates, like Contacts delete or SSL certificate change"
|
||||
>help_outline</mat-icon
|
||||
></mat-label
|
||||
>
|
||||
<mat-select [(ngModel)]="user().role" name="userRole">
|
||||
<mat-option value="PRIMARY_CONTACT">Editor</mat-option>
|
||||
<mat-option value="ACCOUNT_MANAGER">Viewer</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
</p>
|
||||
<div class="console-app__user-edit">
|
||||
<form (ngSubmit)="saveEdit($event)" #form>
|
||||
<p *ngIf="isNew()">
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label
|
||||
>User name prefix:
|
||||
<mat-icon
|
||||
matTooltip="Prefix will be combined with registrar ID to create a unique user name - {prefix}.{registrarId}@registry.google"
|
||||
>help_outline</mat-icon
|
||||
></mat-label
|
||||
>
|
||||
<input
|
||||
matInput
|
||||
minlength="3"
|
||||
maxlength="3"
|
||||
[required]="true"
|
||||
[(ngModel)]="user().emailAddress"
|
||||
[ngModelOptions]="{ standalone: true }"
|
||||
/>
|
||||
</mat-form-field>
|
||||
</p>
|
||||
<p>
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label
|
||||
>User Role:
|
||||
<mat-icon
|
||||
matTooltip="Viewer role doesn't allow making updates; Editor role allows updates, like Contacts delete or SSL certificate change"
|
||||
>help_outline</mat-icon
|
||||
></mat-label
|
||||
>
|
||||
<mat-select [(ngModel)]="user().role" name="userRole">
|
||||
<mat-option value="PRIMARY_CONTACT">Editor</mat-option>
|
||||
<mat-option value="ACCOUNT_MANAGER">Viewer</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
</p>
|
||||
<button
|
||||
mat-flat-button
|
||||
color="primary"
|
||||
aria-label="Save user"
|
||||
type="submit"
|
||||
aria-label="Save changes to the user"
|
||||
>
|
||||
Save
|
||||
</button>
|
||||
</form>
|
||||
@if(userDataService.userData()?.isAdmin) {
|
||||
<button
|
||||
mat-flat-button
|
||||
color="primary"
|
||||
aria-label="Save user"
|
||||
type="submit"
|
||||
aria-label="Save changes to the user"
|
||||
aria-label="Reset registry lock password"
|
||||
(click)="requestRegistryLockPasswordReset()"
|
||||
>
|
||||
Save
|
||||
Reset registry lock password
|
||||
</button>
|
||||
</form>
|
||||
}
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
// Copyright 2025 The Nomulus Authors. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
.console-app__user-edit {
|
||||
button {
|
||||
display: block;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,13 +17,56 @@ import {
|
||||
Component,
|
||||
ElementRef,
|
||||
EventEmitter,
|
||||
Inject,
|
||||
input,
|
||||
Output,
|
||||
ViewChild,
|
||||
} from '@angular/core';
|
||||
import { MaterialModule } from '../material.module';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { User } from './users.service';
|
||||
import { User, UsersService } from './users.service';
|
||||
import { UserDataService } from '../shared/services/userData.service';
|
||||
import { BackendService } from '../shared/services/backend.service';
|
||||
import { RegistrarService } from '../registrar/registrar.service';
|
||||
import {
|
||||
MAT_DIALOG_DATA,
|
||||
MatDialog,
|
||||
MatDialogRef,
|
||||
} from '@angular/material/dialog';
|
||||
import { filter, switchMap, take } from 'rxjs';
|
||||
import { MatSnackBar } from '@angular/material/snack-bar';
|
||||
import { HttpErrorResponse } from '@angular/common/http';
|
||||
|
||||
@Component({
|
||||
selector: 'app-reset-lock-password-dialog',
|
||||
template: `
|
||||
<h2 mat-dialog-title>Please confirm the password reset:</h2>
|
||||
<mat-dialog-content>
|
||||
This will send a registry lock password reset email to
|
||||
{{ data.registryLockEmailAddress }}.
|
||||
</mat-dialog-content>
|
||||
<mat-dialog-actions>
|
||||
<button mat-button (click)="onCancel()">Cancel</button>
|
||||
<button mat-button color="warn" (click)="onSave()">Confirm</button>
|
||||
</mat-dialog-actions>
|
||||
`,
|
||||
imports: [CommonModule, MaterialModule],
|
||||
})
|
||||
export class ResetRegistryLockPasswordComponent {
|
||||
constructor(
|
||||
public dialogRef: MatDialogRef<ResetRegistryLockPasswordComponent>,
|
||||
@Inject(MAT_DIALOG_DATA)
|
||||
public data: { registryLockEmailAddress: string }
|
||||
) {}
|
||||
|
||||
onSave(): void {
|
||||
this.dialogRef.close(true);
|
||||
}
|
||||
|
||||
onCancel(): void {
|
||||
this.dialogRef.close(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'app-user-edit-form',
|
||||
@@ -39,12 +82,22 @@ export class UserEditFormComponent {
|
||||
{
|
||||
emailAddress: '',
|
||||
role: 'ACCOUNT_MANAGER',
|
||||
registryLockEmailAddress: '',
|
||||
},
|
||||
{ transform: (user: User) => structuredClone(user) }
|
||||
);
|
||||
|
||||
@Output() onEditComplete = new EventEmitter<User>();
|
||||
|
||||
constructor(
|
||||
protected userDataService: UserDataService,
|
||||
private backendService: BackendService,
|
||||
private resetRegistryLockPasswordDialog: MatDialog,
|
||||
private registrarService: RegistrarService,
|
||||
private usersService: UsersService,
|
||||
private _snackBar: MatSnackBar
|
||||
) {}
|
||||
|
||||
saveEdit(e: SubmitEvent) {
|
||||
e.preventDefault();
|
||||
if (this.form.nativeElement.checkValidity()) {
|
||||
@@ -53,4 +106,34 @@ export class UserEditFormComponent {
|
||||
this.form.nativeElement.reportValidity();
|
||||
}
|
||||
}
|
||||
|
||||
sendRegistryLockPasswordResetRequest() {
|
||||
return this.backendService.requestRegistryLockPasswordReset(
|
||||
this.registrarService.registrarId(),
|
||||
this.user().registryLockEmailAddress!
|
||||
);
|
||||
}
|
||||
|
||||
requestRegistryLockPasswordReset() {
|
||||
const dialogRef = this.resetRegistryLockPasswordDialog.open(
|
||||
ResetRegistryLockPasswordComponent,
|
||||
{
|
||||
data: {
|
||||
registryLockEmailAddress: this.user().registryLockEmailAddress,
|
||||
},
|
||||
}
|
||||
);
|
||||
dialogRef
|
||||
.afterClosed()
|
||||
.pipe(
|
||||
take(1),
|
||||
filter((result) => !!result)
|
||||
)
|
||||
.pipe(switchMap((_) => this.sendRegistryLockPasswordResetRequest()))
|
||||
.subscribe({
|
||||
next: (_) => this.usersService.currentlyOpenUserEmail.set(''),
|
||||
error: (err: HttpErrorResponse) =>
|
||||
this._snackBar.open(err.error || err.message),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ export interface User {
|
||||
emailAddress: string;
|
||||
role: string;
|
||||
password?: string;
|
||||
registryLockEmailAddress?: string;
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
|
||||
@@ -17,7 +17,7 @@ import java.util.Optional
|
||||
|
||||
plugins {
|
||||
id 'java-library'
|
||||
id "org.flywaydb.flyway" version "11.0.1"
|
||||
id "org.flywaydb.flyway" version "9.22.3"
|
||||
id 'maven-publish'
|
||||
}
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ public class User extends UpdateAutoTimestampEntity implements Buildable {
|
||||
@Id @Expose String emailAddress;
|
||||
|
||||
/** Optional external email address to use for registry lock confirmation emails. */
|
||||
@Column String registryLockEmailAddress;
|
||||
@Column @Expose String registryLockEmailAddress;
|
||||
|
||||
/** Roles (which grant permissions) associated with this user. */
|
||||
@Expose
|
||||
@@ -250,51 +250,50 @@ public class User extends UpdateAutoTimestampEntity implements Buildable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder<? extends User, ?> asBuilder() {
|
||||
return new Builder<>(clone(this));
|
||||
public Builder asBuilder() {
|
||||
return new Builder(clone(this));
|
||||
}
|
||||
|
||||
/** Builder for constructing immutable {@link User} objects. */
|
||||
public static class Builder<T extends User, B extends Builder<T, B>>
|
||||
extends GenericBuilder<T, B> {
|
||||
public static class Builder extends Buildable.Builder<User> {
|
||||
|
||||
public Builder() {}
|
||||
|
||||
public Builder(T abstractUser) {
|
||||
super(abstractUser);
|
||||
public Builder(User user) {
|
||||
super(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T build() {
|
||||
public User build() {
|
||||
checkArgumentNotNull(getInstance().emailAddress, "Email address cannot be null");
|
||||
checkArgumentNotNull(getInstance().userRoles, "User roles cannot be null");
|
||||
return super.build();
|
||||
}
|
||||
|
||||
public B setEmailAddress(String emailAddress) {
|
||||
public Builder setEmailAddress(String emailAddress) {
|
||||
getInstance().emailAddress = checkValidEmail(emailAddress);
|
||||
return thisCastToDerived();
|
||||
return this;
|
||||
}
|
||||
|
||||
public B setRegistryLockEmailAddress(@Nullable String registryLockEmailAddress) {
|
||||
public Builder setRegistryLockEmailAddress(@Nullable String registryLockEmailAddress) {
|
||||
getInstance().registryLockEmailAddress =
|
||||
registryLockEmailAddress == null ? null : checkValidEmail(registryLockEmailAddress);
|
||||
return thisCastToDerived();
|
||||
return this;
|
||||
}
|
||||
|
||||
public B setUserRoles(UserRoles userRoles) {
|
||||
public Builder setUserRoles(UserRoles userRoles) {
|
||||
checkArgumentNotNull(userRoles, "User roles cannot be null");
|
||||
getInstance().userRoles = userRoles;
|
||||
return thisCastToDerived();
|
||||
return this;
|
||||
}
|
||||
|
||||
public B removeRegistryLockPassword() {
|
||||
public Builder removeRegistryLockPassword() {
|
||||
getInstance().registryLockPasswordHash = null;
|
||||
getInstance().registryLockPasswordSalt = null;
|
||||
return thisCastToDerived();
|
||||
return this;
|
||||
}
|
||||
|
||||
public B setRegistryLockPassword(String registryLockPassword) {
|
||||
public Builder setRegistryLockPassword(String registryLockPassword) {
|
||||
checkArgument(
|
||||
getInstance().hasAnyRegistryLockPermission(), "User has no registry lock permission");
|
||||
checkArgument(
|
||||
@@ -304,7 +303,7 @@ public class User extends UpdateAutoTimestampEntity implements Buildable {
|
||||
byte[] salt = SALT_SUPPLIER.get();
|
||||
getInstance().registryLockPasswordSalt = base64().encode(salt);
|
||||
getInstance().registryLockPasswordHash = hashPassword(registryLockPassword, salt);
|
||||
return thisCastToDerived();
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ import static google.registry.util.CollectionUtils.forceEmptyToNull;
|
||||
|
||||
import com.google.common.base.Ascii;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import google.registry.model.Buildable.GenericBuilder;
|
||||
import google.registry.model.Buildable;
|
||||
import google.registry.model.ImmutableObject;
|
||||
import google.registry.model.domain.Period;
|
||||
import google.registry.model.domain.fee.Fee;
|
||||
@@ -77,8 +77,7 @@ public class FeeCheckResponseExtensionItemCommandV12 extends ImmutableObject {
|
||||
}
|
||||
|
||||
/** Builder for {@link FeeCheckResponseExtensionItemCommandV12}. */
|
||||
public static class Builder
|
||||
extends GenericBuilder<FeeCheckResponseExtensionItemCommandV12, Builder> {
|
||||
public static class Builder extends Buildable.Builder<FeeCheckResponseExtensionItemCommandV12> {
|
||||
|
||||
public Builder setCommandName(CommandName commandName) {
|
||||
getInstance().commandName = Ascii.toLowerCase(commandName.name());
|
||||
|
||||
@@ -690,8 +690,8 @@ public class Registrar extends UpdateAutoTimestampEntity implements Buildable, J
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder<? extends Registrar, ?> asBuilder() {
|
||||
return new Builder<>(clone(this));
|
||||
public Builder asBuilder() {
|
||||
return new Builder(clone(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -706,59 +706,58 @@ public class Registrar extends UpdateAutoTimestampEntity implements Buildable, J
|
||||
}
|
||||
|
||||
/** A builder for constructing {@link Registrar}, since it is immutable. */
|
||||
public static class Builder<T extends Registrar, B extends Builder<T, B>>
|
||||
extends GenericBuilder<T, B> {
|
||||
public static class Builder extends Buildable.Builder<Registrar> {
|
||||
public Builder() {}
|
||||
|
||||
public Builder(T instance) {
|
||||
public Builder(Registrar instance) {
|
||||
super(instance);
|
||||
}
|
||||
|
||||
public B setRegistrarId(String registrarId) {
|
||||
public Builder setRegistrarId(String registrarId) {
|
||||
// Registrar id must be [3,16] chars long. See "clIDType" in the base EPP schema of RFC 5730.
|
||||
// (Need to validate this here as there's no matching EPP XSD for validation.)
|
||||
checkArgument(
|
||||
Range.closed(3, 16).contains(registrarId.length()),
|
||||
"Registrar ID must be 3-16 characters long.");
|
||||
getInstance().registrarId = registrarId;
|
||||
return thisCastToDerived();
|
||||
return this;
|
||||
}
|
||||
|
||||
public B setIanaIdentifier(@Nullable Long ianaIdentifier) {
|
||||
public Builder setIanaIdentifier(@Nullable Long ianaIdentifier) {
|
||||
checkArgument(
|
||||
ianaIdentifier == null || ianaIdentifier > 0, "IANA ID must be a positive number");
|
||||
getInstance().ianaIdentifier = ianaIdentifier;
|
||||
return thisCastToDerived();
|
||||
return this;
|
||||
}
|
||||
|
||||
public B setPoNumber(Optional<String> poNumber) {
|
||||
public Builder setPoNumber(Optional<String> poNumber) {
|
||||
getInstance().poNumber = poNumber.orElse(null);
|
||||
return thisCastToDerived();
|
||||
return this;
|
||||
}
|
||||
|
||||
public B setBillingAccountMap(@Nullable Map<CurrencyUnit, String> billingAccountMap) {
|
||||
public Builder setBillingAccountMap(@Nullable Map<CurrencyUnit, String> billingAccountMap) {
|
||||
getInstance().billingAccountMap = nullToEmptyImmutableCopy(billingAccountMap);
|
||||
return thisCastToDerived();
|
||||
return this;
|
||||
}
|
||||
|
||||
public B setRegistrarName(String registrarName) {
|
||||
public Builder setRegistrarName(String registrarName) {
|
||||
getInstance().registrarName = registrarName;
|
||||
return thisCastToDerived();
|
||||
return this;
|
||||
}
|
||||
|
||||
public B setType(Type type) {
|
||||
public Builder setType(Type type) {
|
||||
getInstance().type = type;
|
||||
return thisCastToDerived();
|
||||
return this;
|
||||
}
|
||||
|
||||
public B setState(State state) {
|
||||
public Builder setState(State state) {
|
||||
getInstance().state = state;
|
||||
return thisCastToDerived();
|
||||
return this;
|
||||
}
|
||||
|
||||
public B setAllowedTlds(Set<String> allowedTlds) {
|
||||
public Builder setAllowedTlds(Set<String> allowedTlds) {
|
||||
getInstance().allowedTlds = ImmutableSortedSet.copyOf(assertTldsExist(allowedTlds));
|
||||
return thisCastToDerived();
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -771,7 +770,7 @@ public class Registrar extends UpdateAutoTimestampEntity implements Buildable, J
|
||||
* {@code .now()} when saving the Registry entity to make sure it's actually saved before trying
|
||||
* to set the allowed TLDs.
|
||||
*/
|
||||
public B setAllowedTldsUncached(Set<String> allowedTlds) {
|
||||
public Builder setAllowedTldsUncached(Set<String> allowedTlds) {
|
||||
ImmutableSet<VKey<Tld>> newTldKeys =
|
||||
Sets.difference(allowedTlds, getInstance().getAllowedTlds()).stream()
|
||||
.map(Tld::createVKey)
|
||||
@@ -780,10 +779,10 @@ public class Registrar extends UpdateAutoTimestampEntity implements Buildable, J
|
||||
Sets.difference(newTldKeys, tm().loadByKeysIfPresent(newTldKeys).keySet());
|
||||
checkArgument(missingTldKeys.isEmpty(), "Trying to set nonexistent TLDs: %s", missingTldKeys);
|
||||
getInstance().allowedTlds = ImmutableSortedSet.copyOf(allowedTlds);
|
||||
return thisCastToDerived();
|
||||
return this;
|
||||
}
|
||||
|
||||
public B setClientCertificate(String clientCertificate, DateTime now) {
|
||||
public Builder setClientCertificate(String clientCertificate, DateTime now) {
|
||||
clientCertificate = emptyToNull(clientCertificate);
|
||||
String clientCertificateHash = calculateHash(clientCertificate);
|
||||
if (!Objects.equals(clientCertificate, getInstance().clientCertificate)
|
||||
@@ -792,23 +791,23 @@ public class Registrar extends UpdateAutoTimestampEntity implements Buildable, J
|
||||
getInstance().clientCertificateHash = clientCertificateHash;
|
||||
getInstance().lastCertificateUpdateTime = now;
|
||||
}
|
||||
return thisCastToDerived();
|
||||
return this;
|
||||
}
|
||||
|
||||
public B setLastExpiringCertNotificationSentDate(DateTime now) {
|
||||
public Builder setLastExpiringCertNotificationSentDate(DateTime now) {
|
||||
checkArgumentNotNull(now, "Registrar lastExpiringCertNotificationSentDate cannot be null");
|
||||
getInstance().lastExpiringCertNotificationSentDate = now;
|
||||
return thisCastToDerived();
|
||||
return this;
|
||||
}
|
||||
|
||||
public B setLastExpiringFailoverCertNotificationSentDate(DateTime now) {
|
||||
public Builder setLastExpiringFailoverCertNotificationSentDate(DateTime now) {
|
||||
checkArgumentNotNull(
|
||||
now, "Registrar lastExpiringFailoverCertNotificationSentDate cannot be null");
|
||||
getInstance().lastExpiringFailoverCertNotificationSentDate = now;
|
||||
return thisCastToDerived();
|
||||
return this;
|
||||
}
|
||||
|
||||
public B setFailoverClientCertificate(String clientCertificate, DateTime now) {
|
||||
public Builder setFailoverClientCertificate(String clientCertificate, DateTime now) {
|
||||
clientCertificate = emptyToNull(clientCertificate);
|
||||
String clientCertificateHash = calculateHash(clientCertificate);
|
||||
if (!Objects.equals(clientCertificate, getInstance().failoverClientCertificate)
|
||||
@@ -817,13 +816,13 @@ public class Registrar extends UpdateAutoTimestampEntity implements Buildable, J
|
||||
getInstance().failoverClientCertificateHash = clientCertificateHash;
|
||||
getInstance().lastCertificateUpdateTime = now;
|
||||
}
|
||||
return thisCastToDerived();
|
||||
return this;
|
||||
}
|
||||
|
||||
public B setLastPocVerificationDate(DateTime now) {
|
||||
public Builder setLastPocVerificationDate(DateTime now) {
|
||||
checkArgumentNotNull(now, "Registrar lastPocVerificationDate cannot be null");
|
||||
getInstance().lastPocVerificationDate = now;
|
||||
return thisCastToDerived();
|
||||
return this;
|
||||
}
|
||||
|
||||
private static String calculateHash(String clientCertificate) {
|
||||
@@ -855,75 +854,75 @@ public class Registrar extends UpdateAutoTimestampEntity implements Buildable, J
|
||||
Objects.equals(newInstance.ianaIdentifier, registrar.getIanaIdentifier()));
|
||||
}
|
||||
|
||||
public B setContactsRequireSyncing(boolean contactsRequireSyncing) {
|
||||
public Builder setContactsRequireSyncing(boolean contactsRequireSyncing) {
|
||||
getInstance().contactsRequireSyncing = contactsRequireSyncing;
|
||||
return thisCastToDerived();
|
||||
return this;
|
||||
}
|
||||
|
||||
public B setIpAddressAllowList(Iterable<CidrAddressBlock> ipAddressAllowList) {
|
||||
public Builder setIpAddressAllowList(Iterable<CidrAddressBlock> ipAddressAllowList) {
|
||||
getInstance().ipAddressAllowList = ImmutableList.copyOf(ipAddressAllowList);
|
||||
return thisCastToDerived();
|
||||
return this;
|
||||
}
|
||||
|
||||
public B setLocalizedAddress(RegistrarAddress localizedAddress) {
|
||||
public Builder setLocalizedAddress(RegistrarAddress localizedAddress) {
|
||||
getInstance().localizedAddress = localizedAddress;
|
||||
return thisCastToDerived();
|
||||
return this;
|
||||
}
|
||||
|
||||
public B setInternationalizedAddress(RegistrarAddress internationalizedAddress) {
|
||||
public Builder setInternationalizedAddress(RegistrarAddress internationalizedAddress) {
|
||||
getInstance().internationalizedAddress = internationalizedAddress;
|
||||
return thisCastToDerived();
|
||||
return this;
|
||||
}
|
||||
|
||||
public B setPhoneNumber(String phoneNumber) {
|
||||
public Builder setPhoneNumber(String phoneNumber) {
|
||||
getInstance().phoneNumber = (phoneNumber == null) ? null : checkValidPhoneNumber(phoneNumber);
|
||||
return thisCastToDerived();
|
||||
return this;
|
||||
}
|
||||
|
||||
public B setFaxNumber(String faxNumber) {
|
||||
public Builder setFaxNumber(String faxNumber) {
|
||||
getInstance().faxNumber = (faxNumber == null) ? null : checkValidPhoneNumber(faxNumber);
|
||||
return thisCastToDerived();
|
||||
return this;
|
||||
}
|
||||
|
||||
public B setEmailAddress(String emailAddress) {
|
||||
public Builder setEmailAddress(String emailAddress) {
|
||||
getInstance().emailAddress = checkValidEmail(emailAddress);
|
||||
return thisCastToDerived();
|
||||
return this;
|
||||
}
|
||||
|
||||
public B setWhoisServer(String whoisServer) {
|
||||
public Builder setWhoisServer(String whoisServer) {
|
||||
getInstance().whoisServer = whoisServer;
|
||||
return thisCastToDerived();
|
||||
return this;
|
||||
}
|
||||
|
||||
public B setRdapBaseUrls(Set<String> rdapBaseUrls) {
|
||||
public Builder setRdapBaseUrls(Set<String> rdapBaseUrls) {
|
||||
getInstance().rdapBaseUrls = ImmutableSet.copyOf(rdapBaseUrls);
|
||||
return thisCastToDerived();
|
||||
return this;
|
||||
}
|
||||
|
||||
public B setBlockPremiumNames(boolean blockPremiumNames) {
|
||||
public Builder setBlockPremiumNames(boolean blockPremiumNames) {
|
||||
getInstance().blockPremiumNames = blockPremiumNames;
|
||||
return thisCastToDerived();
|
||||
return this;
|
||||
}
|
||||
|
||||
public B setUrl(String url) {
|
||||
public Builder setUrl(String url) {
|
||||
getInstance().url = url;
|
||||
return thisCastToDerived();
|
||||
return this;
|
||||
}
|
||||
|
||||
public B setIcannReferralEmail(String icannReferralEmail) {
|
||||
public Builder setIcannReferralEmail(String icannReferralEmail) {
|
||||
getInstance().icannReferralEmail = checkValidEmail(icannReferralEmail);
|
||||
return thisCastToDerived();
|
||||
return this;
|
||||
}
|
||||
|
||||
public B setDriveFolderId(@Nullable String driveFolderId) {
|
||||
public Builder setDriveFolderId(@Nullable String driveFolderId) {
|
||||
checkArgument(
|
||||
driveFolderId == null || !driveFolderId.contains("/"),
|
||||
"Drive folder ID must not be a full URL");
|
||||
getInstance().driveFolderId = driveFolderId;
|
||||
return thisCastToDerived();
|
||||
return this;
|
||||
}
|
||||
|
||||
public B setPassword(String password) {
|
||||
public Builder setPassword(String password) {
|
||||
// Passwords must be [6,16] chars long. See "pwType" in the base EPP schema of RFC 5730.
|
||||
checkArgument(
|
||||
Range.closed(6, 16).contains(nullToEmpty(password).length()),
|
||||
@@ -931,7 +930,7 @@ public class Registrar extends UpdateAutoTimestampEntity implements Buildable, J
|
||||
byte[] salt = SALT_SUPPLIER.get();
|
||||
getInstance().salt = base64().encode(salt);
|
||||
getInstance().passwordHash = hashPassword(password, salt);
|
||||
return thisCastToDerived();
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -939,18 +938,18 @@ public class Registrar extends UpdateAutoTimestampEntity implements Buildable, J
|
||||
*
|
||||
* @throws IllegalArgumentException if provided passcode is not 5-digit numeric
|
||||
*/
|
||||
public B setPhonePasscode(String phonePasscode) {
|
||||
public Builder setPhonePasscode(String phonePasscode) {
|
||||
checkArgument(
|
||||
phonePasscode == null || PHONE_PASSCODE_PATTERN.matcher(phonePasscode).matches(),
|
||||
"Not a valid telephone passcode (must be 5 digits long): %s",
|
||||
phonePasscode);
|
||||
getInstance().phonePasscode = phonePasscode;
|
||||
return thisCastToDerived();
|
||||
return this;
|
||||
}
|
||||
|
||||
public B setRegistryLockAllowed(boolean registryLockAllowed) {
|
||||
public Builder setRegistryLockAllowed(boolean registryLockAllowed) {
|
||||
getInstance().registryLockAllowed = registryLockAllowed;
|
||||
return thisCastToDerived();
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -958,14 +957,14 @@ public class Registrar extends UpdateAutoTimestampEntity implements Buildable, J
|
||||
* and breaks the verification that an object has not been updated since it was copied.
|
||||
*/
|
||||
@VisibleForTesting
|
||||
public B setLastUpdateTime(DateTime timestamp) {
|
||||
public Builder setLastUpdateTime(DateTime timestamp) {
|
||||
getInstance().setUpdateTimestamp(UpdateAutoTimestamp.create(timestamp));
|
||||
return thisCastToDerived();
|
||||
return this;
|
||||
}
|
||||
|
||||
/** Build the registrar, nullifying empty fields. */
|
||||
@Override
|
||||
public T build() {
|
||||
public Registrar build() {
|
||||
checkArgumentNotNull(getInstance().type, "Registrar type cannot be null");
|
||||
checkArgumentNotNull(getInstance().registrarName, "Registrar name cannot be null");
|
||||
checkArgument(
|
||||
|
||||
@@ -31,7 +31,7 @@ import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.ImmutableSortedSet;
|
||||
import com.google.gson.annotations.Expose;
|
||||
import google.registry.model.Buildable.GenericBuilder;
|
||||
import google.registry.model.Buildable;
|
||||
import google.registry.model.ImmutableObject;
|
||||
import google.registry.model.JsonMapBuilder;
|
||||
import google.registry.model.Jsonifiable;
|
||||
@@ -225,8 +225,8 @@ public class RegistrarPoc extends ImmutableObject implements Jsonifiable, Unsafe
|
||||
return visibleInDomainWhoisAsAbuse;
|
||||
}
|
||||
|
||||
public Builder<? extends RegistrarPoc, ?> asBuilder() {
|
||||
return new Builder<>(clone(this));
|
||||
public Builder asBuilder() {
|
||||
return new Builder(clone(this));
|
||||
}
|
||||
|
||||
public boolean isAllowedToSetRegistryLockPassword() {
|
||||
@@ -332,17 +332,16 @@ public class RegistrarPoc extends ImmutableObject implements Jsonifiable, Unsafe
|
||||
}
|
||||
|
||||
/** A builder for constructing a {@link RegistrarPoc}, since it is immutable. */
|
||||
public static class Builder<T extends RegistrarPoc, B extends Builder<T, B>>
|
||||
extends GenericBuilder<T, B> {
|
||||
public static class Builder extends Buildable.Builder<RegistrarPoc> {
|
||||
public Builder() {}
|
||||
|
||||
protected Builder(T instance) {
|
||||
protected Builder(RegistrarPoc instance) {
|
||||
super(instance);
|
||||
}
|
||||
|
||||
/** Build the registrar, nullifying empty fields. */
|
||||
@Override
|
||||
public T build() {
|
||||
public RegistrarPoc build() {
|
||||
checkNotNull(getInstance().registrarId, "Registrar ID cannot be null");
|
||||
checkValidEmail(getInstance().emailAddress);
|
||||
// Check allowedToSetRegistryLockPassword here because if we want to allow the user to set
|
||||
@@ -356,71 +355,71 @@ public class RegistrarPoc extends ImmutableObject implements Jsonifiable, Unsafe
|
||||
return cloneEmptyToNull(super.build());
|
||||
}
|
||||
|
||||
public B setName(String name) {
|
||||
public Builder setName(String name) {
|
||||
getInstance().name = name;
|
||||
return thisCastToDerived();
|
||||
return this;
|
||||
}
|
||||
|
||||
public B setEmailAddress(String emailAddress) {
|
||||
public Builder setEmailAddress(String emailAddress) {
|
||||
getInstance().emailAddress = emailAddress;
|
||||
return thisCastToDerived();
|
||||
return this;
|
||||
}
|
||||
|
||||
public B setRegistryLockEmailAddress(@Nullable String registryLockEmailAddress) {
|
||||
public Builder setRegistryLockEmailAddress(@Nullable String registryLockEmailAddress) {
|
||||
getInstance().registryLockEmailAddress = registryLockEmailAddress;
|
||||
return thisCastToDerived();
|
||||
return this;
|
||||
}
|
||||
|
||||
public B setPhoneNumber(String phoneNumber) {
|
||||
public Builder setPhoneNumber(String phoneNumber) {
|
||||
getInstance().phoneNumber = phoneNumber;
|
||||
return thisCastToDerived();
|
||||
return this;
|
||||
}
|
||||
|
||||
public B setRegistrarId(String registrarId) {
|
||||
public Builder setRegistrarId(String registrarId) {
|
||||
getInstance().registrarId = registrarId;
|
||||
return thisCastToDerived();
|
||||
return this;
|
||||
}
|
||||
|
||||
public B setRegistrar(Registrar registrar) {
|
||||
public Builder setRegistrar(Registrar registrar) {
|
||||
getInstance().registrarId = registrar.getRegistrarId();
|
||||
return thisCastToDerived();
|
||||
return this;
|
||||
}
|
||||
|
||||
public B setFaxNumber(String faxNumber) {
|
||||
public Builder setFaxNumber(String faxNumber) {
|
||||
getInstance().faxNumber = faxNumber;
|
||||
return thisCastToDerived();
|
||||
return this;
|
||||
}
|
||||
|
||||
public B setTypes(Iterable<Type> types) {
|
||||
public Builder setTypes(Iterable<Type> types) {
|
||||
getInstance().types = ImmutableSet.copyOf(types);
|
||||
return thisCastToDerived();
|
||||
return this;
|
||||
}
|
||||
|
||||
public B setVisibleInWhoisAsAdmin(boolean visible) {
|
||||
public Builder setVisibleInWhoisAsAdmin(boolean visible) {
|
||||
getInstance().visibleInWhoisAsAdmin = visible;
|
||||
return thisCastToDerived();
|
||||
return this;
|
||||
}
|
||||
|
||||
public B setVisibleInWhoisAsTech(boolean visible) {
|
||||
public Builder setVisibleInWhoisAsTech(boolean visible) {
|
||||
getInstance().visibleInWhoisAsTech = visible;
|
||||
return thisCastToDerived();
|
||||
return this;
|
||||
}
|
||||
|
||||
public B setVisibleInDomainWhoisAsAbuse(boolean visible) {
|
||||
public Builder setVisibleInDomainWhoisAsAbuse(boolean visible) {
|
||||
getInstance().visibleInDomainWhoisAsAbuse = visible;
|
||||
return thisCastToDerived();
|
||||
return this;
|
||||
}
|
||||
|
||||
public B setAllowedToSetRegistryLockPassword(boolean allowedToSetRegistryLockPassword) {
|
||||
public Builder setAllowedToSetRegistryLockPassword(boolean allowedToSetRegistryLockPassword) {
|
||||
if (allowedToSetRegistryLockPassword) {
|
||||
getInstance().registryLockPasswordSalt = null;
|
||||
getInstance().registryLockPasswordHash = null;
|
||||
}
|
||||
getInstance().allowedToSetRegistryLockPassword = allowedToSetRegistryLockPassword;
|
||||
return thisCastToDerived();
|
||||
return this;
|
||||
}
|
||||
|
||||
public B setRegistryLockPassword(String registryLockPassword) {
|
||||
public Builder setRegistryLockPassword(String registryLockPassword) {
|
||||
checkArgument(
|
||||
getInstance().allowedToSetRegistryLockPassword,
|
||||
"Not allowed to set registry lock password for this contact");
|
||||
@@ -430,7 +429,7 @@ public class RegistrarPoc extends ImmutableObject implements Jsonifiable, Unsafe
|
||||
getInstance().registryLockPasswordSalt = base64().encode(salt);
|
||||
getInstance().registryLockPasswordHash = hashPassword(registryLockPassword, salt);
|
||||
getInstance().allowedToSetRegistryLockPassword = false;
|
||||
return thisCastToDerived();
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -119,6 +119,7 @@ public class ConsoleUsersAction extends ConsoleApiAction {
|
||||
u ->
|
||||
new UserData(
|
||||
u.getEmailAddress(),
|
||||
u.getRegistryLockEmailAddress().orElse(null),
|
||||
u.getUserRoles().getRegistrarRoles().get(registrarId).toString(),
|
||||
null))
|
||||
.collect(Collectors.toList());
|
||||
@@ -237,7 +238,9 @@ public class ConsoleUsersAction extends ConsoleApiAction {
|
||||
.setPayload(
|
||||
consoleApiParams
|
||||
.gson()
|
||||
.toJson(new UserData(newEmail, ACCOUNT_MANAGER.toString(), newUser.getPassword())));
|
||||
.toJson(
|
||||
new UserData(
|
||||
newEmail, null, ACCOUNT_MANAGER.toString(), newUser.getPassword())));
|
||||
finishAndPersistConsoleUpdateHistory(
|
||||
new ConsoleUpdateHistory.Builder()
|
||||
.setType(ConsoleUpdateHistory.Type.USER_CREATE)
|
||||
@@ -345,5 +348,8 @@ public class ConsoleUsersAction extends ConsoleApiAction {
|
||||
}
|
||||
|
||||
public record UserData(
|
||||
@Expose String emailAddress, @Expose String role, @Expose @Nullable String password) {}
|
||||
@Expose String emailAddress,
|
||||
@Expose String registryLockEmailAddress,
|
||||
@Expose String role,
|
||||
@Expose @Nullable String password) {}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@ import static google.registry.testing.DatabaseHelper.persistActiveHost;
|
||||
import static google.registry.testing.DatabaseHelper.persistDeletedDomain;
|
||||
import static google.registry.testing.DatabaseHelper.persistDomainAsDeleted;
|
||||
import static google.registry.testing.DatabaseHelper.persistResource;
|
||||
import static google.registry.testing.DatabaseHelper.persistSimpleResource;
|
||||
import static google.registry.util.DateTimeUtils.END_OF_TIME;
|
||||
import static org.joda.time.DateTimeZone.UTC;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
@@ -287,7 +286,7 @@ class DeleteProberDataActionTest {
|
||||
private static Set<ImmutableObject> persistDomainAndDescendants(String fqdn) {
|
||||
Domain domain = persistDeletedDomain(fqdn, DELETION_TIME);
|
||||
DomainHistory historyEntry =
|
||||
persistSimpleResource(
|
||||
persistResource(
|
||||
new DomainHistory.Builder()
|
||||
.setDomain(domain)
|
||||
.setType(HistoryEntry.Type.DOMAIN_CREATE)
|
||||
@@ -295,7 +294,7 @@ class DeleteProberDataActionTest {
|
||||
.setModificationTime(DELETION_TIME.minusYears(3))
|
||||
.build());
|
||||
BillingEvent billingEvent =
|
||||
persistSimpleResource(
|
||||
persistResource(
|
||||
new BillingEvent.Builder()
|
||||
.setDomainHistory(historyEntry)
|
||||
.setBillingTime(DELETION_TIME.plusYears(1))
|
||||
@@ -307,7 +306,7 @@ class DeleteProberDataActionTest {
|
||||
.setTargetId(fqdn)
|
||||
.build());
|
||||
PollMessage.OneTime pollMessage =
|
||||
persistSimpleResource(
|
||||
persistResource(
|
||||
new PollMessage.OneTime.Builder()
|
||||
.setHistoryEntry(historyEntry)
|
||||
.setEventTime(DELETION_TIME)
|
||||
@@ -315,7 +314,7 @@ class DeleteProberDataActionTest {
|
||||
.setMsg("Domain registered")
|
||||
.build());
|
||||
GracePeriod gracePeriod =
|
||||
persistSimpleResource(
|
||||
persistResource(
|
||||
GracePeriod.create(
|
||||
ADD,
|
||||
domain.getRepoId(),
|
||||
|
||||
@@ -18,7 +18,7 @@ import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.persistence.transaction.JpaTransactionManagerExtension.makeRegistrar1;
|
||||
import static google.registry.testing.DatabaseHelper.loadByEntity;
|
||||
import static google.registry.testing.DatabaseHelper.persistResource;
|
||||
import static google.registry.testing.DatabaseHelper.persistSimpleResources;
|
||||
import static google.registry.testing.DatabaseHelper.persistResources;
|
||||
import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
||||
import static org.apache.http.HttpStatus.SC_OK;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
@@ -62,7 +62,8 @@ class SendExpiringCertificateNotificationEmailActionTest {
|
||||
Kind update your account using the following steps:
|
||||
1. Navigate to support and login using your %4$s@registry.example credentials.
|
||||
2. Click Settings -> Privacy on the top left corner.
|
||||
3. Click Edit and enter certificate string. 3. Click SaveRegards,Example Registry""";
|
||||
3. Click Edit and enter certificate string. 3. Click SaveRegards,Example Registry\
|
||||
""";
|
||||
|
||||
private static final String EXPIRATION_WARNING_EMAIL_SUBJECT_TEXT = "Expiration Warning Email";
|
||||
|
||||
@@ -223,7 +224,7 @@ class SendExpiringCertificateNotificationEmailActionTest {
|
||||
.setVisibleInWhoisAsAdmin(true)
|
||||
.setVisibleInWhoisAsTech(false)
|
||||
.build());
|
||||
persistSimpleResources(contacts);
|
||||
persistResources(contacts);
|
||||
RuntimeException thrown =
|
||||
assertThrows(
|
||||
RuntimeException.class,
|
||||
@@ -548,7 +549,7 @@ class SendExpiringCertificateNotificationEmailActionTest {
|
||||
.setTypes(ImmutableSet.of(RegistrarPoc.Type.ADMIN))
|
||||
.setVisibleInWhoisAsTech(true)
|
||||
.build());
|
||||
persistSimpleResources(contacts);
|
||||
persistResources(contacts);
|
||||
assertThat(action.getEmailAddresses(registrar, Type.TECH))
|
||||
.containsExactly(
|
||||
new InternetAddress("will@example-registrar.tld"),
|
||||
@@ -700,7 +701,7 @@ class SendExpiringCertificateNotificationEmailActionTest {
|
||||
/** Returns persisted sample contacts with a customized contact email type. */
|
||||
private static ImmutableList<RegistrarPoc> persistSampleContacts(
|
||||
Registrar registrar, RegistrarPoc.Type emailType) {
|
||||
return persistSimpleResources(
|
||||
return persistResources(
|
||||
ImmutableList.of(
|
||||
new RegistrarPoc.Builder()
|
||||
.setRegistrar(registrar)
|
||||
|
||||
@@ -15,9 +15,10 @@
|
||||
package google.registry.beam.common;
|
||||
|
||||
import static google.registry.persistence.transaction.JpaTransactionManagerExtension.makeRegistrar1;
|
||||
import static google.registry.testing.DatabaseHelper.insertInDb;
|
||||
import static google.registry.testing.DatabaseHelper.newContact;
|
||||
import static google.registry.testing.DatabaseHelper.newTld;
|
||||
import static google.registry.testing.DatabaseHelper.persistResource;
|
||||
import static google.registry.testing.DatabaseHelper.persistResources;
|
||||
import static google.registry.util.DateTimeUtils.END_OF_TIME;
|
||||
import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
||||
|
||||
@@ -75,7 +76,7 @@ public class RegistryJpaReadTest {
|
||||
@BeforeEach
|
||||
void beforeEach() {
|
||||
Registrar ofyRegistrar = JpaIntegrationTestExtension.makeRegistrar2();
|
||||
insertInDb(ofyRegistrar);
|
||||
persistResource(ofyRegistrar);
|
||||
|
||||
ImmutableList.Builder<Contact> builder = new ImmutableList.Builder<>();
|
||||
|
||||
@@ -84,7 +85,7 @@ public class RegistryJpaReadTest {
|
||||
builder.add(contact);
|
||||
}
|
||||
contacts = builder.build();
|
||||
insertInDb(contacts);
|
||||
persistResources(contacts);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -211,6 +212,6 @@ public class RegistryJpaReadTest {
|
||||
null,
|
||||
100L))
|
||||
.build();
|
||||
insertInDb(registry, registrar, contact, domain);
|
||||
persistResources(registry, registrar, contact, domain);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,6 @@ import static google.registry.rde.RdeResourceType.DOMAIN;
|
||||
import static google.registry.rde.RdeResourceType.HOST;
|
||||
import static google.registry.rde.RdeResourceType.REGISTRAR;
|
||||
import static google.registry.testing.DatabaseHelper.createTld;
|
||||
import static google.registry.testing.DatabaseHelper.insertSimpleResources;
|
||||
import static google.registry.testing.DatabaseHelper.newDomain;
|
||||
import static google.registry.testing.DatabaseHelper.persistActiveContact;
|
||||
import static google.registry.testing.DatabaseHelper.persistActiveDomain;
|
||||
@@ -38,6 +37,7 @@ import static google.registry.testing.DatabaseHelper.persistActiveHost;
|
||||
import static google.registry.testing.DatabaseHelper.persistEppResource;
|
||||
import static google.registry.testing.DatabaseHelper.persistNewRegistrar;
|
||||
import static google.registry.testing.DatabaseHelper.persistResource;
|
||||
import static google.registry.testing.DatabaseHelper.persistResources;
|
||||
import static google.registry.util.ResourceUtils.readResourceUtf8;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.junit.Assert.assertThrows;
|
||||
@@ -223,7 +223,7 @@ public class RdePipelineTest {
|
||||
|
||||
@BeforeEach
|
||||
void beforeEach() throws Exception {
|
||||
insertSimpleResources(ImmutableList.of(makeRegistrar1(), makeRegistrar2()));
|
||||
persistResources(ImmutableList.of(makeRegistrar1(), makeRegistrar2()));
|
||||
|
||||
// Two real registrars have been created by loadInitialData(), named "New Registrar" and "The
|
||||
// Registrar". Create one included registrar (external_monitoring) and two excluded ones.
|
||||
@@ -403,7 +403,8 @@ public class RdePipelineTest {
|
||||
<rdeDomain:crRr>TheRegistrar</rdeDomain:crRr>
|
||||
<rdeDomain:crDate>1970-01-01T00:00:00Z</rdeDomain:crDate>
|
||||
<rdeDomain:exDate>294247-01-10T04:00:54Z</rdeDomain:exDate>
|
||||
</rdeDomain:domain>""");
|
||||
</rdeDomain:domain>\
|
||||
""");
|
||||
}
|
||||
if (kv.getKey().mode().equals(FULL)) {
|
||||
// Contact fragments for hello.soy.
|
||||
@@ -441,7 +442,8 @@ public class RdePipelineTest {
|
||||
<rdeDomain:crRr>TheRegistrar</rdeDomain:crRr>
|
||||
<rdeDomain:crDate>1970-01-01T00:00:00Z</rdeDomain:crDate>
|
||||
<rdeDomain:exDate>294247-01-10T04:00:54Z</rdeDomain:exDate>
|
||||
</rdeDomain:domain>""");
|
||||
</rdeDomain:domain>\
|
||||
""");
|
||||
} else {
|
||||
// Contact fragments for cat.fun.
|
||||
assertThat(
|
||||
@@ -484,7 +486,8 @@ public class RdePipelineTest {
|
||||
<rdeDomain:crRr>TheRegistrar</rdeDomain:crRr>
|
||||
<rdeDomain:crDate>1970-01-01T00:00:00Z</rdeDomain:crDate>
|
||||
<rdeDomain:exDate>294247-01-10T04:00:54Z</rdeDomain:exDate>
|
||||
</rdeDomain:domain>""");
|
||||
</rdeDomain:domain>\
|
||||
""");
|
||||
}
|
||||
});
|
||||
return null;
|
||||
|
||||
@@ -23,7 +23,7 @@ import static google.registry.testing.DatabaseHelper.createTld;
|
||||
import static google.registry.testing.DatabaseHelper.loadByKey;
|
||||
import static google.registry.testing.DatabaseHelper.persistNewRegistrar;
|
||||
import static google.registry.testing.DatabaseHelper.persistResource;
|
||||
import static google.registry.testing.DatabaseHelper.persistSimpleResources;
|
||||
import static google.registry.testing.DatabaseHelper.persistResources;
|
||||
import static org.joda.money.CurrencyUnit.JPY;
|
||||
import static org.joda.money.CurrencyUnit.USD;
|
||||
import static org.joda.time.DateTimeZone.UTC;
|
||||
@@ -179,7 +179,7 @@ public class SyncRegistrarsSheetTest {
|
||||
.build());
|
||||
// Use registrar key for contacts' parent.
|
||||
DateTime registrarCreationTime = persistResource(registrar).getCreationTime();
|
||||
persistSimpleResources(contacts);
|
||||
persistResources(contacts);
|
||||
|
||||
clock.advanceBy(standardMinutes(1));
|
||||
newSyncRegistrarsSheet().run("foobar");
|
||||
|
||||
@@ -150,53 +150,50 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, Domain>
|
||||
StatusValue... statusValues)
|
||||
throws Exception {
|
||||
Domain domain = DatabaseHelper.newDomain(getUniqueIdFromCommand());
|
||||
tm().transact(
|
||||
() -> {
|
||||
try {
|
||||
DomainHistory historyEntryDomainCreate =
|
||||
new DomainHistory.Builder()
|
||||
.setDomain(domain)
|
||||
.setType(HistoryEntry.Type.DOMAIN_CREATE)
|
||||
.setModificationTime(clock.nowUtc())
|
||||
.setRegistrarId(domain.getCreationRegistrarId())
|
||||
.build();
|
||||
BillingRecurrence autorenewEvent =
|
||||
new BillingRecurrence.Builder()
|
||||
.setReason(Reason.RENEW)
|
||||
.setFlags(ImmutableSet.of(Flag.AUTO_RENEW))
|
||||
.setTargetId(getUniqueIdFromCommand())
|
||||
.setRegistrarId("TheRegistrar")
|
||||
.setEventTime(expirationTime)
|
||||
.setRecurrenceEndTime(END_OF_TIME)
|
||||
.setDomainHistory(historyEntryDomainCreate)
|
||||
.setRenewalPriceBehavior(renewalPriceBehavior)
|
||||
.setRenewalPrice(renewalPrice)
|
||||
.build();
|
||||
PollMessage.Autorenew autorenewPollMessage =
|
||||
new PollMessage.Autorenew.Builder()
|
||||
.setTargetId(getUniqueIdFromCommand())
|
||||
.setRegistrarId("TheRegistrar")
|
||||
.setEventTime(expirationTime)
|
||||
.setAutorenewEndTime(END_OF_TIME)
|
||||
.setMsg("Domain was auto-renewed.")
|
||||
.setHistoryEntry(historyEntryDomainCreate)
|
||||
.build();
|
||||
Domain newDomain =
|
||||
domain
|
||||
.asBuilder()
|
||||
.setRegistrationExpirationTime(expirationTime)
|
||||
.setStatusValues(ImmutableSet.copyOf(statusValues))
|
||||
.setAutorenewBillingEvent(autorenewEvent.createVKey())
|
||||
.setAutorenewPollMessage(autorenewPollMessage.createVKey())
|
||||
.build();
|
||||
persistResources(
|
||||
ImmutableSet.of(
|
||||
historyEntryDomainCreate, autorenewEvent,
|
||||
autorenewPollMessage, newDomain));
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Error persisting domain", e);
|
||||
}
|
||||
});
|
||||
try {
|
||||
DomainHistory historyEntryDomainCreate =
|
||||
new DomainHistory.Builder()
|
||||
.setDomain(domain)
|
||||
.setType(HistoryEntry.Type.DOMAIN_CREATE)
|
||||
.setModificationTime(clock.nowUtc())
|
||||
.setRegistrarId(domain.getCreationRegistrarId())
|
||||
.build();
|
||||
BillingRecurrence autorenewEvent =
|
||||
new BillingRecurrence.Builder()
|
||||
.setReason(Reason.RENEW)
|
||||
.setFlags(ImmutableSet.of(Flag.AUTO_RENEW))
|
||||
.setTargetId(getUniqueIdFromCommand())
|
||||
.setRegistrarId("TheRegistrar")
|
||||
.setEventTime(expirationTime)
|
||||
.setRecurrenceEndTime(END_OF_TIME)
|
||||
.setDomainHistory(historyEntryDomainCreate)
|
||||
.setRenewalPriceBehavior(renewalPriceBehavior)
|
||||
.setRenewalPrice(renewalPrice)
|
||||
.build();
|
||||
PollMessage.Autorenew autorenewPollMessage =
|
||||
new PollMessage.Autorenew.Builder()
|
||||
.setTargetId(getUniqueIdFromCommand())
|
||||
.setRegistrarId("TheRegistrar")
|
||||
.setEventTime(expirationTime)
|
||||
.setAutorenewEndTime(END_OF_TIME)
|
||||
.setMsg("Domain was auto-renewed.")
|
||||
.setHistoryEntry(historyEntryDomainCreate)
|
||||
.build();
|
||||
Domain newDomain =
|
||||
domain
|
||||
.asBuilder()
|
||||
.setRegistrationExpirationTime(expirationTime)
|
||||
.setStatusValues(ImmutableSet.copyOf(statusValues))
|
||||
.setAutorenewBillingEvent(autorenewEvent.createVKey())
|
||||
.setAutorenewPollMessage(autorenewPollMessage.createVKey())
|
||||
.build();
|
||||
persistResources(
|
||||
ImmutableSet.of(
|
||||
historyEntryDomainCreate, autorenewEvent,
|
||||
autorenewPollMessage, newDomain));
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Error persisting domain", e);
|
||||
}
|
||||
clock.advanceOneMilli();
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ import static google.registry.testing.CertificateSamples.SAMPLE_CERT_HASH;
|
||||
import static google.registry.testing.DatabaseHelper.createTld;
|
||||
import static google.registry.testing.DatabaseHelper.loadByKeyIfPresent;
|
||||
import static google.registry.testing.DatabaseHelper.persistPremiumList;
|
||||
import static google.registry.testing.DatabaseHelper.persistSimpleResource;
|
||||
import static google.registry.testing.DatabaseHelper.persistResource;
|
||||
import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
||||
import static org.joda.money.CurrencyUnit.USD;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
@@ -275,7 +275,7 @@ public final class OteAccountBuilderTest {
|
||||
|
||||
@Test
|
||||
void testCreateOteEntities_registrarExists_failsWhenNotReplaceExisting() {
|
||||
persistSimpleResource(makeRegistrar1().asBuilder().setRegistrarId("myclientid-1").build());
|
||||
persistResource(makeRegistrar1().asBuilder().setRegistrarId("myclientid-1").build());
|
||||
|
||||
OteAccountBuilder oteSetupHelper = OteAccountBuilder.forRegistrarId("myclientid");
|
||||
|
||||
@@ -301,7 +301,7 @@ public final class OteAccountBuilderTest {
|
||||
|
||||
@Test
|
||||
void testCreateOteEntities_entitiesExist_succeedsWhenReplaceExisting() {
|
||||
persistSimpleResource(makeRegistrar1().asBuilder().setRegistrarId("myclientid-1").build());
|
||||
persistResource(makeRegistrar1().asBuilder().setRegistrarId("myclientid-1").build());
|
||||
// we intentionally create the -ga TLD with the wrong state, to make sure it's overwritten.
|
||||
createTld("myclientid-ga", START_DATE_SUNRISE);
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ package google.registry.model.common;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.model.ImmutableObjectSubject.assertAboutImmutableObjects;
|
||||
import static google.registry.testing.DatabaseHelper.insertInDb;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||
import static google.registry.testing.DatabaseHelper.loadAllOf;
|
||||
import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
@@ -41,7 +41,7 @@ public class DnsRefreshRequestTest extends EntityTestCase {
|
||||
void testPersistence() {
|
||||
assertThat(request.getLastProcessTime()).isEqualTo(START_OF_TIME);
|
||||
fakeClock.advanceOneMilli();
|
||||
insertInDb(request);
|
||||
tm().transact(() -> tm().insert(request));
|
||||
fakeClock.advanceOneMilli();
|
||||
ImmutableList<DnsRefreshRequest> requests = loadAllOf(DnsRefreshRequest.class);
|
||||
assertThat(requests.size()).isEqualTo(1);
|
||||
|
||||
@@ -20,7 +20,6 @@ import static google.registry.model.ImmutableObjectSubject.assertAboutImmutableO
|
||||
import static google.registry.testing.ContactSubject.assertAboutContacts;
|
||||
import static google.registry.testing.DatabaseHelper.cloneAndSetAutoTimestamps;
|
||||
import static google.registry.testing.DatabaseHelper.createTld;
|
||||
import static google.registry.testing.DatabaseHelper.insertInDb;
|
||||
import static google.registry.testing.DatabaseHelper.loadByEntity;
|
||||
import static google.registry.testing.DatabaseHelper.persistResource;
|
||||
import static google.registry.testing.SqlHelper.assertThrowForeignKeyViolation;
|
||||
@@ -132,7 +131,7 @@ public class ContactTest extends EntityTestCase {
|
||||
void testCloudSqlPersistence_failWhenViolateForeignKeyConstraint() {
|
||||
assertThrowForeignKeyViolation(
|
||||
() ->
|
||||
insertInDb(
|
||||
persistResource(
|
||||
originalContact
|
||||
.asBuilder()
|
||||
.setRepoId("2-FOOBAR")
|
||||
|
||||
@@ -20,11 +20,10 @@ import static google.registry.model.domain.token.AllocationToken.TokenStatus.NOT
|
||||
import static google.registry.model.domain.token.AllocationToken.TokenType.BULK_PRICING;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||
import static google.registry.testing.DatabaseHelper.createTld;
|
||||
import static google.registry.testing.DatabaseHelper.insertInDb;
|
||||
import static google.registry.testing.DatabaseHelper.loadByEntity;
|
||||
import static google.registry.testing.DatabaseHelper.loadByKey;
|
||||
import static google.registry.testing.DatabaseHelper.persistResource;
|
||||
import static google.registry.testing.DatabaseHelper.updateInDb;
|
||||
import static google.registry.testing.DatabaseHelper.persistResources;
|
||||
import static google.registry.testing.SqlHelper.assertThrowForeignKeyViolation;
|
||||
import static google.registry.testing.SqlHelper.saveRegistrar;
|
||||
import static google.registry.util.DateTimeUtils.END_OF_TIME;
|
||||
@@ -169,13 +168,13 @@ public class DomainSqlTest {
|
||||
@Test
|
||||
void testHostForeignKeyConstraints() {
|
||||
// Persist the domain without the associated host object.
|
||||
assertThrowForeignKeyViolation(() -> insertInDb(contact, contact2, domain));
|
||||
assertThrowForeignKeyViolation(() -> persistResources(contact, contact2, domain));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testContactForeignKeyConstraints() {
|
||||
// Persist the domain without the associated contact objects.
|
||||
assertThrowForeignKeyViolation(() -> insertInDb(domain, host));
|
||||
assertThrowForeignKeyViolation(() -> persistResources(domain, host));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -358,7 +357,7 @@ public class DomainSqlTest {
|
||||
@Test
|
||||
void testSerializable() {
|
||||
createTld("com");
|
||||
insertInDb(contact, contact2, domain, host);
|
||||
persistResources(contact, contact2, domain, host);
|
||||
Domain persisted = tm().transact(() -> tm().loadByEntity(domain));
|
||||
assertThat(SerializeUtils.serializeDeserialize(persisted)).isEqualTo(persisted);
|
||||
}
|
||||
@@ -366,9 +365,9 @@ public class DomainSqlTest {
|
||||
@Test
|
||||
void testUpdates() {
|
||||
createTld("com");
|
||||
insertInDb(contact, contact2, domain, host);
|
||||
persistResources(contact, contact2, domain, host);
|
||||
domain = domain.asBuilder().setNameservers(ImmutableSet.of()).build();
|
||||
updateInDb(domain);
|
||||
persistResource(domain);
|
||||
assertAboutImmutableObjects()
|
||||
.that(loadByEntity(domain))
|
||||
.isEqualExceptFields(domain, "updateTimestamp", "creationTime");
|
||||
@@ -385,7 +384,7 @@ public class DomainSqlTest {
|
||||
|
||||
private void persistDomain() {
|
||||
createTld("com");
|
||||
insertInDb(contact, contact2, domain, host);
|
||||
persistResources(contact, contact2, domain, host);
|
||||
}
|
||||
|
||||
private <T> VKey<T> createKey(Class<T> clazz, String key) {
|
||||
@@ -414,24 +413,19 @@ public class DomainSqlTest {
|
||||
Domain persisted = loadByKey(domain.createVKey());
|
||||
DateTime originalUpdateTime = persisted.getUpdateTimestamp().getTimestamp();
|
||||
fakeClock.advanceOneMilli();
|
||||
DateTime transactionTime =
|
||||
tm().transact(
|
||||
() -> {
|
||||
Host host2 =
|
||||
new Host.Builder()
|
||||
.setRepoId("host2")
|
||||
.setHostName("ns2.example.com")
|
||||
.setCreationRegistrarId("registrar1")
|
||||
.setPersistedCurrentSponsorRegistrarId("registrar2")
|
||||
.build();
|
||||
insertInDb(host2);
|
||||
Host host2 =
|
||||
new Host.Builder()
|
||||
.setRepoId("host2")
|
||||
.setHostName("ns2.example.com")
|
||||
.setCreationRegistrarId("registrar1")
|
||||
.setPersistedCurrentSponsorRegistrarId("registrar2")
|
||||
.build();
|
||||
persistResource(host2);
|
||||
domain = persisted.asBuilder().addNameserver(host2.createVKey()).build();
|
||||
updateInDb(domain);
|
||||
return tm().getTransactionTime();
|
||||
});
|
||||
persistResource(domain);
|
||||
domain = loadByKey(domain.createVKey());
|
||||
assertThat(domain.getUpdateTimestamp().getTimestamp()).isEqualTo(transactionTime);
|
||||
assertThat(domain.getUpdateTimestamp().getTimestamp()).isNotEqualTo(originalUpdateTime);
|
||||
assertThat(domain.getUpdateTimestamp().getTimestamp())
|
||||
.isEqualTo(originalUpdateTime.plusMillis(1));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -440,20 +434,14 @@ public class DomainSqlTest {
|
||||
Domain persisted = loadByKey(domain.createVKey());
|
||||
DateTime originalUpdateTime = persisted.getUpdateTimestamp().getTimestamp();
|
||||
fakeClock.advanceOneMilli();
|
||||
DateTime transactionTime =
|
||||
tm().transact(
|
||||
() -> {
|
||||
domain =
|
||||
persisted
|
||||
.asBuilder()
|
||||
.setDsData(
|
||||
ImmutableSet.of(DomainDsData.create(1, 2, 3, new byte[] {0, 1, 2})))
|
||||
.build();
|
||||
updateInDb(domain);
|
||||
return tm().getTransactionTime();
|
||||
});
|
||||
domain =
|
||||
persisted
|
||||
.asBuilder()
|
||||
.setDsData(ImmutableSet.of(DomainDsData.create(1, 2, 3, new byte[] {0, 1, 2})))
|
||||
.build();
|
||||
persistResource(domain);
|
||||
domain = loadByKey(domain.createVKey());
|
||||
assertThat(domain.getUpdateTimestamp().getTimestamp()).isEqualTo(transactionTime);
|
||||
assertThat(domain.getUpdateTimestamp().getTimestamp()).isNotEqualTo(originalUpdateTime);
|
||||
assertThat(domain.getUpdateTimestamp().getTimestamp())
|
||||
.isEqualTo(originalUpdateTime.plusMillis(1));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,12 +23,12 @@ import static google.registry.model.domain.token.AllocationToken.TokenType.BULK_
|
||||
import static google.registry.model.domain.token.AllocationToken.TokenType.SINGLE_USE;
|
||||
import static google.registry.testing.DatabaseHelper.cloneAndSetAutoTimestamps;
|
||||
import static google.registry.testing.DatabaseHelper.createTld;
|
||||
import static google.registry.testing.DatabaseHelper.insertInDb;
|
||||
import static google.registry.testing.DatabaseHelper.newHost;
|
||||
import static google.registry.testing.DatabaseHelper.persistActiveContact;
|
||||
import static google.registry.testing.DatabaseHelper.persistActiveDomain;
|
||||
import static google.registry.testing.DatabaseHelper.persistActiveHost;
|
||||
import static google.registry.testing.DatabaseHelper.persistResource;
|
||||
import static google.registry.testing.DatabaseHelper.persistResources;
|
||||
import static google.registry.testing.DomainSubject.assertAboutDomains;
|
||||
import static google.registry.testing.SqlHelper.saveRegistrar;
|
||||
import static google.registry.util.DateTimeUtils.END_OF_TIME;
|
||||
@@ -162,7 +162,7 @@ public class DomainTest {
|
||||
.setRecurrenceEndTime(END_OF_TIME)
|
||||
.setDomainHistory(historyEntry)
|
||||
.build();
|
||||
insertInDb(historyEntry, billingEventBill, billingRecurrence);
|
||||
persistResources(historyEntry, billingEventBill, billingRecurrence);
|
||||
recurrenceBillKey = billingRecurrence.createVKey();
|
||||
VKey<PollMessage.Autorenew> autorenewPollKey = VKey.create(PollMessage.Autorenew.class, 3L);
|
||||
VKey<PollMessage.OneTime> onetimePollKey = VKey.create(PollMessage.OneTime.class, 1L);
|
||||
|
||||
@@ -16,8 +16,8 @@ package google.registry.model.eppcommon;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||
import static google.registry.testing.DatabaseHelper.insertInDb;
|
||||
import static google.registry.testing.DatabaseHelper.loadByEntity;
|
||||
import static google.registry.testing.DatabaseHelper.persistResource;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
@@ -50,25 +50,25 @@ class AddressTest {
|
||||
|
||||
private static final String ENTITY_XML =
|
||||
"""
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<testEntity>
|
||||
<address>
|
||||
<street>123 W 14th St</street>
|
||||
<street>8th Fl</street>
|
||||
<street>Rm 8</street>
|
||||
<city>New York</city>
|
||||
<sp>NY</sp>
|
||||
<pc>10011</pc>
|
||||
<cc>US</cc>
|
||||
</address>
|
||||
</testEntity>
|
||||
""";
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<testEntity>
|
||||
<address>
|
||||
<street>123 W 14th St</street>
|
||||
<street>8th Fl</street>
|
||||
<street>Rm 8</street>
|
||||
<city>New York</city>
|
||||
<sp>NY</sp>
|
||||
<pc>10011</pc>
|
||||
<cc>US</cc>
|
||||
</address>
|
||||
</testEntity>
|
||||
""";
|
||||
|
||||
private TestAddress address = createAddress("123 W 14th St", "8th Fl", "Rm 8");
|
||||
private TestEntity entity = new TestEntity(1L, address);
|
||||
|
||||
private static TestEntity saveAndLoad(TestEntity entity) {
|
||||
insertInDb(entity);
|
||||
persistResource(entity);
|
||||
return loadByEntity(entity);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,9 +17,9 @@ package google.registry.model.history;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.model.ImmutableObjectSubject.assertAboutImmutableObjects;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||
import static google.registry.testing.DatabaseHelper.insertInDb;
|
||||
import static google.registry.testing.DatabaseHelper.loadByEntity;
|
||||
import static google.registry.testing.DatabaseHelper.newContactWithRoid;
|
||||
import static google.registry.testing.DatabaseHelper.persistResource;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
@@ -45,10 +45,10 @@ public class ContactHistoryTest extends EntityTestCase {
|
||||
@Test
|
||||
void testPersistence() {
|
||||
Contact contact = newContactWithRoid("contactId", "contact1");
|
||||
insertInDb(contact);
|
||||
persistResource(contact);
|
||||
Contact contactFromDb = loadByEntity(contact);
|
||||
ContactHistory contactHistory = createContactHistory(contactFromDb);
|
||||
insertInDb(contactHistory);
|
||||
persistResource(contactHistory);
|
||||
tm().transact(
|
||||
() -> {
|
||||
ContactHistory fromDatabase = tm().loadByKey(contactHistory.createVKey());
|
||||
@@ -60,10 +60,10 @@ public class ContactHistoryTest extends EntityTestCase {
|
||||
@Test
|
||||
void testSerializable() {
|
||||
Contact contact = newContactWithRoid("contactId", "contact1");
|
||||
insertInDb(contact);
|
||||
persistResource(contact);
|
||||
Contact contactFromDb = loadByEntity(contact);
|
||||
ContactHistory contactHistory = createContactHistory(contactFromDb);
|
||||
insertInDb(contactHistory);
|
||||
persistResource(contactHistory);
|
||||
ContactHistory fromDatabase = tm().transact(() -> tm().loadByKey(contactHistory.createVKey()));
|
||||
assertThat(SerializeUtils.serializeDeserialize(fromDatabase)).isEqualTo(fromDatabase);
|
||||
}
|
||||
|
||||
@@ -18,10 +18,10 @@ import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.model.ImmutableObjectSubject.assertAboutImmutableObjects;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||
import static google.registry.testing.DatabaseHelper.createTld;
|
||||
import static google.registry.testing.DatabaseHelper.insertInDb;
|
||||
import static google.registry.testing.DatabaseHelper.newContactWithRoid;
|
||||
import static google.registry.testing.DatabaseHelper.newDomain;
|
||||
import static google.registry.testing.DatabaseHelper.newHostWithRoid;
|
||||
import static google.registry.testing.DatabaseHelper.persistResource;
|
||||
import static google.registry.util.DateTimeUtils.END_OF_TIME;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
@@ -60,7 +60,7 @@ public class DomainHistoryTest extends EntityTestCase {
|
||||
void testPersistence() {
|
||||
Domain domain = addGracePeriodForSql(createDomainWithContactsAndHosts());
|
||||
DomainHistory domainHistory = createDomainHistory(domain);
|
||||
insertInDb(domainHistory);
|
||||
persistResource(domainHistory);
|
||||
|
||||
tm().transact(
|
||||
() -> {
|
||||
@@ -74,7 +74,7 @@ public class DomainHistoryTest extends EntityTestCase {
|
||||
void testSerializable() {
|
||||
Domain domain = addGracePeriodForSql(createDomainWithContactsAndHosts());
|
||||
DomainHistory domainHistory = createDomainHistory(domain);
|
||||
insertInDb(domainHistory);
|
||||
persistResource(domainHistory);
|
||||
DomainHistory fromDatabase = tm().transact(() -> tm().loadByKey(domainHistory.createVKey()));
|
||||
assertThat(SerializeUtils.serializeDeserialize(fromDatabase)).isEqualTo(fromDatabase);
|
||||
}
|
||||
@@ -96,7 +96,7 @@ public class DomainHistoryTest extends EntityTestCase {
|
||||
.setNameservers(host.createVKey())
|
||||
.setDsData(ImmutableSet.of(DomainDsData.create(1, 2, 3, new byte[] {0, 1, 2})))
|
||||
.build();
|
||||
insertInDb(domain);
|
||||
persistResource(domain);
|
||||
return domain;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,9 +17,9 @@ package google.registry.model.history;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.model.ImmutableObjectSubject.assertAboutImmutableObjects;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||
import static google.registry.testing.DatabaseHelper.insertInDb;
|
||||
import static google.registry.testing.DatabaseHelper.loadByEntity;
|
||||
import static google.registry.testing.DatabaseHelper.newHostWithRoid;
|
||||
import static google.registry.testing.DatabaseHelper.persistResource;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
import google.registry.model.EntityTestCase;
|
||||
@@ -41,10 +41,10 @@ public class HostHistoryTest extends EntityTestCase {
|
||||
@Test
|
||||
void testPersistence() {
|
||||
Host host = newHostWithRoid("ns1.example.com", "host1");
|
||||
insertInDb(host);
|
||||
persistResource(host);
|
||||
Host hostFromDb = loadByEntity(host);
|
||||
HostHistory hostHistory = createHostHistory(hostFromDb);
|
||||
insertInDb(hostHistory);
|
||||
persistResource(hostHistory);
|
||||
tm().transact(
|
||||
() -> {
|
||||
HostHistory fromDatabase = tm().loadByKey(hostHistory.createVKey());
|
||||
@@ -56,10 +56,10 @@ public class HostHistoryTest extends EntityTestCase {
|
||||
@Test
|
||||
void testSerializable() {
|
||||
Host host = newHostWithRoid("ns1.example.com", "host1");
|
||||
insertInDb(host);
|
||||
persistResource(host);
|
||||
Host hostFromDb = loadByEntity(host);
|
||||
HostHistory hostHistory = createHostHistory(hostFromDb);
|
||||
insertInDb(hostHistory);
|
||||
persistResource(hostHistory);
|
||||
HostHistory fromDatabase = tm().transact(() -> tm().loadByKey(hostHistory.createVKey()));
|
||||
assertThat(SerializeUtils.serializeDeserialize(fromDatabase)).isEqualTo(fromDatabase);
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@ package google.registry.model.poll;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||
import static google.registry.testing.DatabaseHelper.createTld;
|
||||
import static google.registry.testing.DatabaseHelper.insertInDb;
|
||||
import static google.registry.testing.DatabaseHelper.loadByKey;
|
||||
import static google.registry.testing.DatabaseHelper.persistActiveContact;
|
||||
import static google.registry.testing.DatabaseHelper.persistResource;
|
||||
@@ -90,12 +89,12 @@ public class PollMessageTest extends EntityTestCase {
|
||||
|
||||
@Test
|
||||
void testCloudSqlSupportForPolymorphicVKey() {
|
||||
insertInDb(oneTime);
|
||||
persistResource(oneTime);
|
||||
PollMessage persistedOneTime = loadByKey(VKey.create(PollMessage.class, oneTime.getId()));
|
||||
assertThat(persistedOneTime).isInstanceOf(PollMessage.OneTime.class);
|
||||
assertThat(persistedOneTime).isEqualTo(oneTime);
|
||||
|
||||
insertInDb(autoRenew);
|
||||
persistResource(autoRenew);
|
||||
PollMessage persistedAutoRenew = loadByKey(VKey.create(PollMessage.class, autoRenew.getId()));
|
||||
assertThat(persistedAutoRenew).isInstanceOf(PollMessage.Autorenew.class);
|
||||
assertThat(persistedAutoRenew).isEqualTo(autoRenew);
|
||||
|
||||
@@ -25,8 +25,7 @@ import static google.registry.testing.DatabaseHelper.cloneAndSetAutoTimestamps;
|
||||
import static google.registry.testing.DatabaseHelper.createTld;
|
||||
import static google.registry.testing.DatabaseHelper.newTld;
|
||||
import static google.registry.testing.DatabaseHelper.persistResource;
|
||||
import static google.registry.testing.DatabaseHelper.persistSimpleResource;
|
||||
import static google.registry.testing.DatabaseHelper.persistSimpleResources;
|
||||
import static google.registry.testing.DatabaseHelper.persistResources;
|
||||
import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
||||
import static org.joda.money.CurrencyUnit.JPY;
|
||||
import static org.joda.money.CurrencyUnit.USD;
|
||||
@@ -132,7 +131,7 @@ class RegistrarTest extends EntityTestCase {
|
||||
.setFaxNumber("+1.2125551213")
|
||||
.setTypes(ImmutableSet.of(RegistrarPoc.Type.ABUSE, RegistrarPoc.Type.ADMIN))
|
||||
.build();
|
||||
persistSimpleResources(
|
||||
persistResources(
|
||||
ImmutableList.of(
|
||||
abuseAdminContact,
|
||||
new RegistrarPoc.Builder()
|
||||
@@ -301,7 +300,7 @@ class RegistrarTest extends EntityTestCase {
|
||||
|
||||
@Test
|
||||
void testSuccess_emptyContactTypesAllowed() {
|
||||
persistSimpleResource(
|
||||
persistResource(
|
||||
new RegistrarPoc.Builder()
|
||||
.setRegistrar(registrar)
|
||||
.setName("John Abussy")
|
||||
@@ -318,7 +317,7 @@ class RegistrarTest extends EntityTestCase {
|
||||
@Test
|
||||
void testSuccess_getContactsByType() {
|
||||
RegistrarPoc newTechContact =
|
||||
persistSimpleResource(
|
||||
persistResource(
|
||||
new RegistrarPoc.Builder()
|
||||
.setRegistrar(registrar)
|
||||
.setName("Jake Tech")
|
||||
@@ -330,7 +329,7 @@ class RegistrarTest extends EntityTestCase {
|
||||
.setTypes(ImmutableSet.of(RegistrarPoc.Type.TECH))
|
||||
.build());
|
||||
RegistrarPoc newTechAbuseContact =
|
||||
persistSimpleResource(
|
||||
persistResource(
|
||||
new RegistrarPoc.Builder()
|
||||
.setRegistrar(registrar)
|
||||
.setName("Jim Tech-Abuse")
|
||||
|
||||
@@ -17,9 +17,10 @@ package google.registry.model.reporting;
|
||||
import static google.registry.model.ImmutableObjectSubject.assertAboutImmutableObjects;
|
||||
import static google.registry.model.reporting.Spec11ThreatMatch.ThreatType.MALWARE;
|
||||
import static google.registry.model.reporting.Spec11ThreatMatch.ThreatType.UNWANTED_SOFTWARE;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||
import static google.registry.testing.DatabaseHelper.createTld;
|
||||
import static google.registry.testing.DatabaseHelper.insertInDb;
|
||||
import static google.registry.testing.DatabaseHelper.loadByEntity;
|
||||
import static google.registry.testing.DatabaseHelper.persistResources;
|
||||
import static google.registry.testing.SqlHelper.assertThrowForeignKeyViolation;
|
||||
import static google.registry.testing.SqlHelper.saveRegistrar;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
@@ -105,7 +106,7 @@ public final class Spec11ThreatMatchTest extends EntityTestCase {
|
||||
void testPersistence() {
|
||||
createTld("tld");
|
||||
saveRegistrar(REGISTRAR_ID);
|
||||
insertInDb(registrantContact, domain, host, threat);
|
||||
tm().transact(() -> tm().insertAll(registrantContact, domain, host, threat));
|
||||
assertAboutImmutableObjects().that(loadByEntity(threat)).isEqualExceptFields(threat, "id");
|
||||
}
|
||||
|
||||
@@ -113,12 +114,12 @@ public final class Spec11ThreatMatchTest extends EntityTestCase {
|
||||
@Disabled("We can't rely on foreign keys until we've migrated to SQL")
|
||||
void testThreatForeignKeyConstraints() {
|
||||
// Persist the threat without the associated registrar.
|
||||
assertThrowForeignKeyViolation(() -> insertInDb(host, registrantContact, domain, threat));
|
||||
assertThrowForeignKeyViolation(() -> persistResources(host, registrantContact, domain, threat));
|
||||
|
||||
saveRegistrar(REGISTRAR_ID);
|
||||
|
||||
// Persist the threat without the associated domain.
|
||||
assertThrowForeignKeyViolation(() -> insertInDb(registrantContact, host, threat));
|
||||
assertThrowForeignKeyViolation(() -> persistResources(registrantContact, host, threat));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -18,7 +18,7 @@ import static com.google.common.collect.ImmutableSet.toImmutableSet;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static com.google.common.truth.Truth.assertWithMessage;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||
import static google.registry.testing.DatabaseHelper.insertInDb;
|
||||
import static google.registry.testing.DatabaseHelper.persistResource;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import google.registry.model.ImmutableObject;
|
||||
@@ -51,7 +51,7 @@ class EntityCallbacksListenerTest {
|
||||
@Test
|
||||
void verifyAllCallbacks_executedExpectedTimes() {
|
||||
TestEntity testPersist = new TestEntity();
|
||||
insertInDb(testPersist);
|
||||
tm().transact(() -> tm().insert(testPersist));
|
||||
checkAll(testPersist, 1, 0, 0, 0);
|
||||
|
||||
TestEntity testUpdate = new TestEntity();
|
||||
@@ -99,7 +99,7 @@ class EntityCallbacksListenerTest {
|
||||
|
||||
@Test
|
||||
void verifyCallbacksNotCalledOnCommit() {
|
||||
insertInDb(new TestEntity());
|
||||
persistResource(new TestEntity());
|
||||
|
||||
TestEntity testLoad = tm().transact(() -> tm().loadByKey(VKey.create(TestEntity.class, "id")));
|
||||
assertThat(testLoad.entityPreUpdate).isEqualTo(0);
|
||||
|
||||
@@ -19,7 +19,7 @@ import static google.registry.model.domain.token.AllocationToken.TokenStatus.END
|
||||
import static google.registry.model.domain.token.AllocationToken.TokenStatus.NOT_STARTED;
|
||||
import static google.registry.model.domain.token.AllocationToken.TokenStatus.VALID;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||
import static google.registry.testing.DatabaseHelper.insertInDb;
|
||||
import static google.registry.testing.DatabaseHelper.persistResource;
|
||||
import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
||||
|
||||
import com.google.common.collect.ImmutableSortedMap;
|
||||
@@ -59,7 +59,7 @@ public class AllocationTokenStatusTransitionUserTypeTest {
|
||||
TimedTransitionProperty.fromValueMap(values);
|
||||
AllocationTokenStatusTransitionConverterTestEntity testEntity =
|
||||
new AllocationTokenStatusTransitionConverterTestEntity(timedTransitionProperty);
|
||||
insertInDb(testEntity);
|
||||
persistResource(testEntity);
|
||||
AllocationTokenStatusTransitionConverterTestEntity persisted =
|
||||
tm().transact(
|
||||
() ->
|
||||
|
||||
@@ -18,7 +18,7 @@ import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.model.domain.token.AllocationToken.TokenType.SINGLE_USE;
|
||||
import static google.registry.model.domain.token.AllocationToken.TokenType.UNLIMITED_USE;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||
import static google.registry.testing.DatabaseHelper.insertInDb;
|
||||
import static google.registry.testing.DatabaseHelper.persistResource;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import google.registry.model.ImmutableObject;
|
||||
@@ -51,7 +51,7 @@ public class AllocationTokenVkeyListUserTypeTest {
|
||||
List<VKey<AllocationToken>> tokens = ImmutableList.of(token1.createVKey(), token2.createVKey());
|
||||
TestAllocationTokenVKeyList testAllocationTokenVKeyList =
|
||||
new TestAllocationTokenVKeyList(tokens);
|
||||
insertInDb(testAllocationTokenVKeyList);
|
||||
persistResource(testAllocationTokenVKeyList);
|
||||
TestAllocationTokenVKeyList persisted =
|
||||
tm().transact(() -> tm().getEntityManager().find(TestAllocationTokenVKeyList.class, "id"));
|
||||
assertThat(persisted.tokenList).isEqualTo(tokens);
|
||||
|
||||
@@ -16,7 +16,7 @@ package google.registry.persistence.converter;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||
import static google.registry.testing.DatabaseHelper.insertInDb;
|
||||
import static google.registry.testing.DatabaseHelper.persistResource;
|
||||
import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
||||
import static org.joda.money.CurrencyUnit.USD;
|
||||
|
||||
@@ -52,7 +52,7 @@ public class BillingCostTransitionUserTypeTest {
|
||||
TimedTransitionProperty<Money> timedTransitionProperty =
|
||||
TimedTransitionProperty.fromValueMap(values);
|
||||
TestEntity testEntity = new TestEntity(timedTransitionProperty);
|
||||
insertInDb(testEntity);
|
||||
persistResource(testEntity);
|
||||
TestEntity persisted =
|
||||
tm().transact(() -> tm().getEntityManager().find(TestEntity.class, "id"));
|
||||
assertThat(persisted.timedTransitionProperty.toValueMap())
|
||||
|
||||
@@ -16,7 +16,7 @@ package google.registry.persistence.converter;
|
||||
import static com.google.common.hash.Funnels.stringFunnel;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||
import static google.registry.testing.DatabaseHelper.insertInDb;
|
||||
import static google.registry.testing.DatabaseHelper.persistResource;
|
||||
import static java.nio.charset.StandardCharsets.US_ASCII;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
@@ -41,7 +41,7 @@ class BloomFilterConverterTest {
|
||||
BloomFilter<String> bloomFilter = BloomFilter.create(stringFunnel(US_ASCII), 3);
|
||||
ImmutableSet.of("foo", "bar", "baz").forEach(bloomFilter::put);
|
||||
TestEntity entity = new TestEntity(bloomFilter);
|
||||
insertInDb(entity);
|
||||
persistResource(entity);
|
||||
TestEntity persisted =
|
||||
tm().transact(() -> tm().getEntityManager().find(TestEntity.class, "id"));
|
||||
assertThat(persisted.bloomFilter).isEqualTo(bloomFilter);
|
||||
|
||||
@@ -16,7 +16,7 @@ package google.registry.persistence.converter;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||
import static google.registry.testing.DatabaseHelper.insertInDb;
|
||||
import static google.registry.testing.DatabaseHelper.persistResource;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import google.registry.model.ImmutableObject;
|
||||
@@ -47,7 +47,7 @@ public class CidrBlockListUserTypeTest {
|
||||
CidrAddressBlock.create("8000::/1"),
|
||||
CidrAddressBlock.create("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff/128"));
|
||||
TestEntity testEntity = new TestEntity(addresses);
|
||||
insertInDb(testEntity);
|
||||
persistResource(testEntity);
|
||||
TestEntity persisted =
|
||||
tm().transact(() -> tm().getEntityManager().find(TestEntity.class, "id"));
|
||||
assertThat(persisted.addresses).isEqualTo(addresses);
|
||||
|
||||
@@ -16,7 +16,7 @@ package google.registry.persistence.converter;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||
import static google.registry.testing.DatabaseHelper.insertInDb;
|
||||
import static google.registry.testing.DatabaseHelper.persistResource;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import google.registry.model.ImmutableObject;
|
||||
@@ -44,7 +44,7 @@ public class CurrencyToStringMapUserTypeTest {
|
||||
CurrencyUnit.of("USD"), "accountId1",
|
||||
CurrencyUnit.of("CNY"), "accountId2");
|
||||
TestEntity testEntity = new TestEntity(currencyToBilling);
|
||||
insertInDb(testEntity);
|
||||
persistResource(testEntity);
|
||||
TestEntity persisted =
|
||||
tm().transact(() -> tm().getEntityManager().find(TestEntity.class, "id"));
|
||||
assertThat(persisted.currencyToBilling).containsExactlyEntriesIn(currencyToBilling);
|
||||
|
||||
@@ -16,7 +16,7 @@ package google.registry.persistence.converter;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||
import static google.registry.testing.DatabaseHelper.insertInDb;
|
||||
import static google.registry.testing.DatabaseHelper.persistResource;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import google.registry.model.ImmutableObject;
|
||||
@@ -39,7 +39,7 @@ public class CurrencyUnitConverterTest {
|
||||
@Test
|
||||
void roundTripConversion() {
|
||||
TestEntity entity = new TestEntity(CurrencyUnit.EUR);
|
||||
insertInDb(entity);
|
||||
persistResource(entity);
|
||||
assertThat(
|
||||
tm().transact(
|
||||
() ->
|
||||
|
||||
@@ -16,7 +16,7 @@ package google.registry.persistence.converter;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||
import static google.registry.testing.DatabaseHelper.insertInDb;
|
||||
import static google.registry.testing.DatabaseHelper.persistResource;
|
||||
import static java.time.ZoneOffset.UTC;
|
||||
|
||||
import google.registry.model.ImmutableObject;
|
||||
@@ -75,7 +75,7 @@ public class DateTimeConverterTest {
|
||||
void converter_generatesTimestampWithNormalizedZone() {
|
||||
DateTime dt = parseDateTime("2019-09-01T01:01:01Z");
|
||||
TestEntity entity = new TestEntity("normalized_utc_time", dt);
|
||||
insertInDb(entity);
|
||||
persistResource(entity);
|
||||
TestEntity retrievedEntity =
|
||||
tm().transact(() -> tm().getEntityManager().find(TestEntity.class, "normalized_utc_time"));
|
||||
assertThat(retrievedEntity.dt.toString()).isEqualTo("2019-09-01T01:01:01.000Z");
|
||||
@@ -86,7 +86,7 @@ public class DateTimeConverterTest {
|
||||
DateTime dt = parseDateTime("2019-09-01T01:01:01-05:00");
|
||||
TestEntity entity = new TestEntity("new_york_time", dt);
|
||||
|
||||
insertInDb(entity);
|
||||
persistResource(entity);
|
||||
TestEntity retrievedEntity =
|
||||
tm().transact(() -> tm().getEntityManager().find(TestEntity.class, "new_york_time"));
|
||||
assertThat(retrievedEntity.dt.toString()).isEqualTo("2019-09-01T06:01:01.000Z");
|
||||
|
||||
@@ -16,7 +16,7 @@ package google.registry.persistence.converter;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||
import static google.registry.testing.DatabaseHelper.insertInDb;
|
||||
import static google.registry.testing.DatabaseHelper.persistResource;
|
||||
|
||||
import google.registry.model.ImmutableObject;
|
||||
import google.registry.persistence.transaction.JpaTestExtensions;
|
||||
@@ -39,7 +39,7 @@ public class DurationUserTypeTest {
|
||||
@Test
|
||||
void testNulls() {
|
||||
DurationTestEntity entity = new DurationTestEntity(null);
|
||||
insertInDb(entity);
|
||||
persistResource(entity);
|
||||
DurationTestEntity persisted =
|
||||
tm().transact(() -> tm().getEntityManager().find(DurationTestEntity.class, "id"));
|
||||
assertThat(persisted.duration).isNull();
|
||||
@@ -90,7 +90,7 @@ public class DurationUserTypeTest {
|
||||
|
||||
private void assertPersistedEntityHasSameDuration(Duration duration) {
|
||||
DurationTestEntity entity = new DurationTestEntity(duration);
|
||||
insertInDb(entity);
|
||||
persistResource(entity);
|
||||
DurationTestEntity persisted =
|
||||
tm().transact(() -> tm().getEntityManager().find(DurationTestEntity.class, "id"));
|
||||
assertThat(persisted.duration.getMillis()).isEqualTo(duration.getMillis());
|
||||
|
||||
@@ -16,7 +16,7 @@ package google.registry.persistence.converter;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||
import static google.registry.testing.DatabaseHelper.insertInDb;
|
||||
import static google.registry.testing.DatabaseHelper.persistResource;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.net.InetAddresses;
|
||||
@@ -64,7 +64,7 @@ public class InetAddressSetUserTypeTest {
|
||||
|
||||
private void verifySaveAndLoad(@Nullable Set<InetAddress> inetAddresses) {
|
||||
InetAddressSetTestEntity testEntity = new InetAddressSetTestEntity(inetAddresses);
|
||||
insertInDb(testEntity);
|
||||
persistResource(testEntity);
|
||||
InetAddressSetTestEntity persisted =
|
||||
tm().transact(() -> tm().loadByKey(VKey.create(InetAddressSetTestEntity.class, "id")));
|
||||
assertThat(persisted.addresses).isEqualTo(inetAddresses);
|
||||
|
||||
@@ -15,7 +15,7 @@ package google.registry.persistence.converter;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||
import static google.registry.testing.DatabaseHelper.insertInDb;
|
||||
import static google.registry.testing.DatabaseHelper.persistResource;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
@@ -57,7 +57,7 @@ public class JodaMoneyTypeTest {
|
||||
Money money = Money.of(CurrencyUnit.USD, 100.12);
|
||||
assertThat(money.getAmount().scale()).isEqualTo(2);
|
||||
TestEntity entity = new TestEntity(money);
|
||||
insertInDb(entity);
|
||||
persistResource(entity);
|
||||
List<?> result =
|
||||
tm().transact(
|
||||
() ->
|
||||
@@ -81,7 +81,7 @@ public class JodaMoneyTypeTest {
|
||||
Money money = Money.ofMajor(CurrencyUnit.JPY, 100);
|
||||
assertThat(money.getAmount().scale()).isEqualTo(0); // JPY's amount has scale at 0.
|
||||
TestEntity entity = new TestEntity(money);
|
||||
insertInDb(entity);
|
||||
persistResource(entity);
|
||||
List<?> result =
|
||||
tm().transact(
|
||||
() ->
|
||||
@@ -121,7 +121,7 @@ public class JodaMoneyTypeTest {
|
||||
"dos", Money.ofMajor(CurrencyUnit.JPY, 2000),
|
||||
"tres", Money.of(CurrencyUnit.GBP, 20));
|
||||
ComplexTestEntity entity = new ComplexTestEntity(moneyMap, myMoney, yourMoney);
|
||||
insertInDb(entity);
|
||||
persistResource(entity);
|
||||
List<?> result =
|
||||
tm().transact(
|
||||
() ->
|
||||
|
||||
@@ -16,7 +16,7 @@ package google.registry.persistence.converter;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||
import static google.registry.testing.DatabaseHelper.insertInDb;
|
||||
import static google.registry.testing.DatabaseHelper.persistResource;
|
||||
|
||||
import google.registry.model.ImmutableObject;
|
||||
import google.registry.persistence.VKey;
|
||||
@@ -54,7 +54,7 @@ public class LocalDateConverterTest {
|
||||
|
||||
private LocalDateConverterTestEntity persistAndLoadTestEntity(LocalDate date) {
|
||||
LocalDateConverterTestEntity entity = new LocalDateConverterTestEntity(date);
|
||||
insertInDb(entity);
|
||||
persistResource(entity);
|
||||
return tm().transact(
|
||||
() -> tm().loadByKey(VKey.create(LocalDateConverterTestEntity.class, "id")));
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ public class RegistrarToRoleMapUserTypeTest {
|
||||
"FooRegistrar",
|
||||
RegistrarRole.TECH_CONTACT);
|
||||
TestEntity entity = new TestEntity(map);
|
||||
DatabaseHelper.insertInDb(entity);
|
||||
DatabaseHelper.persistResource(entity);
|
||||
TestEntity persisted = Iterables.getOnlyElement(DatabaseHelper.loadAllOf(TestEntity.class));
|
||||
assertThat(persisted.map).isEqualTo(map);
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ package google.registry.persistence.converter;
|
||||
import static com.google.common.collect.ImmutableList.toImmutableList;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||
import static google.registry.testing.DatabaseHelper.insertInDb;
|
||||
import static google.registry.testing.DatabaseHelper.persistResource;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
@@ -45,7 +45,7 @@ public class StringCollectionUserTypeTest {
|
||||
List<ListElement> value =
|
||||
ImmutableList.of(new ListElement("app"), new ListElement("dev"), new ListElement("com"));
|
||||
TestEntity testEntity = new TestEntity(value);
|
||||
insertInDb(testEntity);
|
||||
persistResource(testEntity);
|
||||
TestEntity persisted =
|
||||
tm().transact(() -> tm().getEntityManager().find(TestEntity.class, "id"));
|
||||
assertThat(persisted.value).containsExactlyElementsIn(value);
|
||||
@@ -56,7 +56,7 @@ public class StringCollectionUserTypeTest {
|
||||
List<ListElement> value =
|
||||
ImmutableList.of(new ListElement("app"), new ListElement("dev"), new ListElement("com"));
|
||||
TestEntity testEntity = new TestEntity(value);
|
||||
insertInDb(testEntity);
|
||||
persistResource(testEntity);
|
||||
TestEntity persisted =
|
||||
tm().transact(() -> tm().getEntityManager().find(TestEntity.class, "id"));
|
||||
persisted.value = ImmutableList.of(new ListElement("app"), new ListElement("org"));
|
||||
@@ -68,7 +68,7 @@ public class StringCollectionUserTypeTest {
|
||||
@Test
|
||||
void testNullValue_writesAndReadsNullSuccessfully() {
|
||||
TestEntity testEntity = new TestEntity(null);
|
||||
insertInDb(testEntity);
|
||||
persistResource(testEntity);
|
||||
TestEntity persisted =
|
||||
tm().transact(() -> tm().getEntityManager().find(TestEntity.class, "id"));
|
||||
assertThat(persisted.value).isNull();
|
||||
@@ -77,7 +77,7 @@ public class StringCollectionUserTypeTest {
|
||||
@Test
|
||||
void testEmptyCollection_writesAndReadsEmptyCollectionSuccessfully() {
|
||||
TestEntity testEntity = new TestEntity(ImmutableList.of());
|
||||
insertInDb(testEntity);
|
||||
persistResource(testEntity);
|
||||
TestEntity persisted =
|
||||
tm().transact(() -> tm().getEntityManager().find(TestEntity.class, "id"));
|
||||
assertThat(persisted.value).isEmpty();
|
||||
|
||||
@@ -16,7 +16,7 @@ package google.registry.persistence.converter;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||
import static google.registry.testing.DatabaseHelper.insertInDb;
|
||||
import static google.registry.testing.DatabaseHelper.persistResource;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
@@ -41,7 +41,7 @@ public class StringListConversionTest {
|
||||
void roundTripConversion_returnsSameStringList() {
|
||||
List<String> tlds = ImmutableList.of("app", "dev", "how");
|
||||
TestEntity testEntity = new TestEntity(tlds);
|
||||
insertInDb(testEntity);
|
||||
persistResource(testEntity);
|
||||
TestEntity persisted =
|
||||
tm().transact(() -> tm().getEntityManager().find(TestEntity.class, "id"));
|
||||
assertThat(persisted.tlds).containsExactly("app", "dev", "how");
|
||||
@@ -51,7 +51,7 @@ public class StringListConversionTest {
|
||||
void testMerge_succeeds() {
|
||||
List<String> tlds = ImmutableList.of("app", "dev", "how");
|
||||
TestEntity testEntity = new TestEntity(tlds);
|
||||
insertInDb(testEntity);
|
||||
persistResource(testEntity);
|
||||
TestEntity persisted =
|
||||
tm().transact(() -> tm().getEntityManager().find(TestEntity.class, "id"));
|
||||
persisted.tlds = ImmutableList.of("com", "gov");
|
||||
@@ -63,7 +63,7 @@ public class StringListConversionTest {
|
||||
@Test
|
||||
void testNullValue_writesAndReadsNullSuccessfully() {
|
||||
TestEntity testEntity = new TestEntity(null);
|
||||
insertInDb(testEntity);
|
||||
persistResource(testEntity);
|
||||
TestEntity persisted =
|
||||
tm().transact(() -> tm().getEntityManager().find(TestEntity.class, "id"));
|
||||
assertThat(persisted.tlds).isNull();
|
||||
@@ -72,7 +72,7 @@ public class StringListConversionTest {
|
||||
@Test
|
||||
void testEmptyCollection_writesAndReadsEmptyCollectionSuccessfully() {
|
||||
TestEntity testEntity = new TestEntity(ImmutableList.of());
|
||||
insertInDb(testEntity);
|
||||
persistResource(testEntity);
|
||||
TestEntity persisted =
|
||||
tm().transact(() -> tm().getEntityManager().find(TestEntity.class, "id"));
|
||||
assertThat(persisted.tlds).isEmpty();
|
||||
|
||||
@@ -16,7 +16,7 @@ package google.registry.persistence.converter;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||
import static google.registry.testing.DatabaseHelper.insertInDb;
|
||||
import static google.registry.testing.DatabaseHelper.persistResource;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
@@ -47,7 +47,7 @@ public class StringMapUserTypeTest {
|
||||
@Test
|
||||
void roundTripConversion_returnsSameMap() {
|
||||
TestEntity testEntity = new TestEntity(MAP);
|
||||
insertInDb(testEntity);
|
||||
persistResource(testEntity);
|
||||
TestEntity persisted =
|
||||
tm().transact(() -> tm().getEntityManager().find(TestEntity.class, "id"));
|
||||
assertThat(persisted.map).containsExactlyEntriesIn(MAP);
|
||||
@@ -56,7 +56,7 @@ public class StringMapUserTypeTest {
|
||||
@Test
|
||||
void testUpdateColumn_succeeds() {
|
||||
TestEntity testEntity = new TestEntity(MAP);
|
||||
insertInDb(testEntity);
|
||||
persistResource(testEntity);
|
||||
TestEntity persisted =
|
||||
tm().transact(() -> tm().getEntityManager().find(TestEntity.class, "id"));
|
||||
assertThat(persisted.map).containsExactlyEntriesIn(MAP);
|
||||
@@ -69,7 +69,7 @@ public class StringMapUserTypeTest {
|
||||
@Test
|
||||
void testNullValue_writesAndReadsNullSuccessfully() {
|
||||
TestEntity testEntity = new TestEntity(null);
|
||||
insertInDb(testEntity);
|
||||
persistResource(testEntity);
|
||||
TestEntity persisted =
|
||||
tm().transact(() -> tm().getEntityManager().find(TestEntity.class, "id"));
|
||||
assertThat(persisted.map).isNull();
|
||||
@@ -78,7 +78,7 @@ public class StringMapUserTypeTest {
|
||||
@Test
|
||||
void testEmptyMap_writesAndReadsEmptyCollectionSuccessfully() {
|
||||
TestEntity testEntity = new TestEntity(ImmutableMap.of());
|
||||
insertInDb(testEntity);
|
||||
persistResource(testEntity);
|
||||
TestEntity persisted =
|
||||
tm().transact(() -> tm().getEntityManager().find(TestEntity.class, "id"));
|
||||
assertThat(persisted.map).isEmpty();
|
||||
|
||||
@@ -16,7 +16,7 @@ package google.registry.persistence.converter;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||
import static google.registry.testing.DatabaseHelper.insertInDb;
|
||||
import static google.registry.testing.DatabaseHelper.persistResource;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import google.registry.model.ImmutableObject;
|
||||
@@ -39,7 +39,7 @@ public class StringSetConversionTest {
|
||||
void roundTripConversion_returnsSameStringList() {
|
||||
Set<String> tlds = ImmutableSet.of("app", "dev", "how");
|
||||
TestEntity testEntity = new TestEntity(tlds);
|
||||
insertInDb(testEntity);
|
||||
persistResource(testEntity);
|
||||
TestEntity persisted =
|
||||
tm().transact(() -> tm().getEntityManager().find(TestEntity.class, "id"));
|
||||
assertThat(persisted.tlds).containsExactly("app", "dev", "how");
|
||||
@@ -48,7 +48,7 @@ public class StringSetConversionTest {
|
||||
@Test
|
||||
void testNullValue_writesAndReadsNullSuccessfully() {
|
||||
TestEntity testEntity = new TestEntity(null);
|
||||
insertInDb(testEntity);
|
||||
persistResource(testEntity);
|
||||
TestEntity persisted =
|
||||
tm().transact(() -> tm().getEntityManager().find(TestEntity.class, "id"));
|
||||
assertThat(persisted.tlds).isNull();
|
||||
@@ -57,7 +57,7 @@ public class StringSetConversionTest {
|
||||
@Test
|
||||
void testEmptyCollection_writesAndReadsEmptyCollectionSuccessfully() {
|
||||
TestEntity testEntity = new TestEntity(ImmutableSet.of());
|
||||
insertInDb(testEntity);
|
||||
persistResource(testEntity);
|
||||
TestEntity persisted =
|
||||
tm().transact(() -> tm().getEntityManager().find(TestEntity.class, "id"));
|
||||
assertThat(persisted.tlds).isEmpty();
|
||||
|
||||
@@ -16,7 +16,7 @@ package google.registry.persistence.converter;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||
import static google.registry.testing.DatabaseHelper.insertInDb;
|
||||
import static google.registry.testing.DatabaseHelper.persistResource;
|
||||
|
||||
import google.registry.model.ImmutableObject;
|
||||
import google.registry.model.registrar.Registrar.State;
|
||||
@@ -39,7 +39,7 @@ public class StringValueEnumeratedTest {
|
||||
@Test
|
||||
void roundTripConversion_returnsSameEnum() {
|
||||
TestEntity testEntity = new TestEntity(State.ACTIVE);
|
||||
insertInDb(testEntity);
|
||||
persistResource(testEntity);
|
||||
TestEntity persisted =
|
||||
tm().transact(() -> tm().getEntityManager().find(TestEntity.class, "id"));
|
||||
assertThat(persisted.state).isEqualTo(State.ACTIVE);
|
||||
@@ -48,7 +48,7 @@ public class StringValueEnumeratedTest {
|
||||
@Test
|
||||
void testNativeQuery_succeeds() {
|
||||
TestEntity testEntity = new TestEntity(State.DISABLED);
|
||||
insertInDb(testEntity);
|
||||
persistResource(testEntity);
|
||||
|
||||
assertThat(
|
||||
tm().transact(
|
||||
|
||||
@@ -16,7 +16,7 @@ package google.registry.persistence.converter;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||
import static google.registry.testing.DatabaseHelper.insertInDb;
|
||||
import static google.registry.testing.DatabaseHelper.persistResource;
|
||||
import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
@@ -55,7 +55,7 @@ class TimedTransitionBaseUserTypeTest {
|
||||
@Test
|
||||
void roundTripConversion_returnsSameTimedTransitionProperty() {
|
||||
TestEntity testEntity = new TestEntity(TIMED_TRANSITION_PROPERTY);
|
||||
insertInDb(testEntity);
|
||||
persistResource(testEntity);
|
||||
TestEntity persisted =
|
||||
tm().transact(() -> tm().getEntityManager().find(TestEntity.class, "id"));
|
||||
assertThat(persisted.property.toValueMap())
|
||||
@@ -65,7 +65,7 @@ class TimedTransitionBaseUserTypeTest {
|
||||
@Test
|
||||
void testUpdateColumn_succeeds() {
|
||||
TestEntity testEntity = new TestEntity(TIMED_TRANSITION_PROPERTY);
|
||||
insertInDb(testEntity);
|
||||
persistResource(testEntity);
|
||||
TestEntity persisted =
|
||||
tm().transact(() -> tm().getEntityManager().find(TestEntity.class, "id"));
|
||||
assertThat(persisted.property.toValueMap())
|
||||
@@ -80,7 +80,7 @@ class TimedTransitionBaseUserTypeTest {
|
||||
@Test
|
||||
void testNullValue_writesAndReadsNullSuccessfully() {
|
||||
TestEntity testEntity = new TestEntity(null);
|
||||
insertInDb(testEntity);
|
||||
persistResource(testEntity);
|
||||
TestEntity persisted =
|
||||
tm().transact(() -> tm().getEntityManager().find(TestEntity.class, "id"));
|
||||
assertThat(persisted.property).isNull();
|
||||
|
||||
@@ -16,7 +16,7 @@ package google.registry.persistence.converter;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||
import static google.registry.testing.DatabaseHelper.insertInDb;
|
||||
import static google.registry.testing.DatabaseHelper.persistResource;
|
||||
import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
||||
|
||||
import com.google.common.collect.ImmutableSortedMap;
|
||||
@@ -55,7 +55,7 @@ class TldStateTransitionUserTypeTest {
|
||||
TimedTransitionProperty<TldState> timedTransitionProperty =
|
||||
TimedTransitionProperty.fromValueMap(values);
|
||||
TestEntity testEntity = new TestEntity(timedTransitionProperty);
|
||||
insertInDb(testEntity);
|
||||
persistResource(testEntity);
|
||||
TestEntity persisted =
|
||||
tm().transact(() -> tm().getEntityManager().find(TestEntity.class, "id"));
|
||||
assertThat(persisted.timedTransitionProperty.toValueMap())
|
||||
|
||||
@@ -16,7 +16,7 @@ package google.registry.persistence.converter;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||
import static google.registry.testing.DatabaseHelper.insertInDb;
|
||||
import static google.registry.testing.DatabaseHelper.persistResources;
|
||||
|
||||
import google.registry.model.ImmutableObject;
|
||||
import google.registry.persistence.VKey;
|
||||
@@ -50,7 +50,7 @@ public class VKeyConverterTest {
|
||||
TestLongEntity longEntity = new TestLongEntity(300L);
|
||||
VKey<TestLongEntity> longKey = VKey.create(TestLongEntity.class, 300L);
|
||||
TestEntity original = new TestEntity(1984L, stringKey, longKey);
|
||||
insertInDb(stringEntity, longEntity, original);
|
||||
persistResources(stringEntity, longEntity, original);
|
||||
|
||||
TestEntity retrieved =
|
||||
tm().transact(() -> tm().getEntityManager().find(TestEntity.class, 1984L));
|
||||
|
||||
@@ -16,7 +16,7 @@ package google.registry.persistence.transaction;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||
import static google.registry.testing.DatabaseHelper.insertInDb;
|
||||
import static google.registry.testing.DatabaseHelper.persistResources;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import google.registry.model.ImmutableObject;
|
||||
@@ -50,7 +50,7 @@ class CriteriaQueryBuilderTest {
|
||||
|
||||
@BeforeEach
|
||||
void beforeEach() {
|
||||
insertInDb(entity1, entity2, entity3);
|
||||
persistResources(entity1, entity2, entity3);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -17,7 +17,7 @@ package google.registry.persistence.transaction;
|
||||
import static com.google.common.base.Preconditions.checkState;
|
||||
import static com.google.common.collect.ImmutableList.toImmutableList;
|
||||
import static com.google.common.truth.Truth.assertWithMessage;
|
||||
import static google.registry.testing.DatabaseHelper.insertSimpleResources;
|
||||
import static google.registry.testing.DatabaseHelper.persistResources;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.testcontainers.containers.PostgreSQLContainer.POSTGRESQL_PORT;
|
||||
|
||||
@@ -444,7 +444,7 @@ public abstract class JpaTransactionManagerExtension
|
||||
|
||||
/** Create some fake registrars. */
|
||||
public static void loadInitialData() {
|
||||
insertSimpleResources(
|
||||
persistResources(
|
||||
ImmutableList.of(
|
||||
makeRegistrar1(),
|
||||
makeRegistrarContact1(),
|
||||
|
||||
@@ -17,7 +17,7 @@ package google.registry.persistence.transaction;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.replicaTm;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||
import static google.registry.testing.DatabaseHelper.insertInDb;
|
||||
import static google.registry.testing.DatabaseHelper.persistResource;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import google.registry.model.ImmutableObject;
|
||||
@@ -76,7 +76,7 @@ public class JpaTransactionManagerExtensionTest {
|
||||
// This test verifies that 1) withEntityClass() has registered TestEntity and 2) The table
|
||||
// has been created, implying withProperty(HBM2DDL_AUTO, "update") worked.
|
||||
TestEntity original = new TestEntity("key", "value");
|
||||
insertInDb(original);
|
||||
persistResource(original);
|
||||
TestEntity retrieved =
|
||||
tm().transact(() -> tm().getEntityManager().find(TestEntity.class, "key"));
|
||||
assertThat(retrieved).isEqualTo(original);
|
||||
|
||||
@@ -24,8 +24,9 @@ import static google.registry.persistence.transaction.TransactionManagerFactory.
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||
import static google.registry.testing.DatabaseHelper.assertDetachedFromEntityManager;
|
||||
import static google.registry.testing.DatabaseHelper.existsInDb;
|
||||
import static google.registry.testing.DatabaseHelper.insertInDb;
|
||||
import static google.registry.testing.DatabaseHelper.loadByKey;
|
||||
import static google.registry.testing.DatabaseHelper.persistResource;
|
||||
import static google.registry.testing.DatabaseHelper.persistResources;
|
||||
import static google.registry.testing.TestDataHelper.fileClassPath;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
@@ -397,7 +398,7 @@ class JpaTransactionManagerImplTest {
|
||||
@Test
|
||||
void saveAllNew_succeeds() {
|
||||
moreEntities.forEach(entity -> assertThat(tm().transact(() -> tm().exists(entity))).isFalse());
|
||||
insertInDb(moreEntities);
|
||||
persistResources(moreEntities);
|
||||
moreEntities.forEach(entity -> assertThat(tm().transact(() -> tm().exists(entity))).isTrue());
|
||||
assertThat(tm().transact(() -> tm().loadAllOf(TestEntity.class)))
|
||||
.containsExactlyElementsIn(moreEntities);
|
||||
@@ -406,8 +407,12 @@ class JpaTransactionManagerImplTest {
|
||||
@Test
|
||||
void saveAllNew_rollsBackWhenFailure() {
|
||||
moreEntities.forEach(entity -> assertThat(tm().transact(() -> tm().exists(entity))).isFalse());
|
||||
insertInDb(moreEntities.get(0));
|
||||
assertThat(assertThrows(PersistenceException.class, () -> insertInDb(moreEntities)).getCause())
|
||||
persistResource(moreEntities.get(0));
|
||||
assertThat(
|
||||
assertThrows(
|
||||
PersistenceException.class,
|
||||
() -> tm().transact(() -> tm().insertAll(moreEntities)))
|
||||
.getCause())
|
||||
.isInstanceOf(RollbackException.class);
|
||||
assertThat(tm().transact(() -> tm().exists(moreEntities.get(0)))).isTrue();
|
||||
assertThat(tm().transact(() -> tm().exists(moreEntities.get(1)))).isFalse();
|
||||
@@ -424,7 +429,7 @@ class JpaTransactionManagerImplTest {
|
||||
|
||||
@Test
|
||||
void put_updatesExistingEntity() {
|
||||
insertInDb(theEntity);
|
||||
persistResource(theEntity);
|
||||
TestEntity persisted = tm().transact(() -> tm().loadByKey(theEntityKey));
|
||||
assertThat(persisted.data).isEqualTo("foo");
|
||||
theEntity.data = "bar";
|
||||
@@ -444,7 +449,7 @@ class JpaTransactionManagerImplTest {
|
||||
|
||||
@Test
|
||||
void update_succeeds() {
|
||||
insertInDb(theEntity);
|
||||
persistResource(theEntity);
|
||||
TestEntity persisted =
|
||||
tm().transact(() -> tm().loadByKey(VKey.create(TestEntity.class, "theEntity")));
|
||||
assertThat(persisted.data).isEqualTo("foo");
|
||||
@@ -456,7 +461,7 @@ class JpaTransactionManagerImplTest {
|
||||
|
||||
@Test
|
||||
void updateCompoundIdEntity_succeeds() {
|
||||
insertInDb(compoundIdEntity);
|
||||
persistResource(compoundIdEntity);
|
||||
TestCompoundIdEntity persisted = tm().transact(() -> tm().loadByKey(compoundIdEntityKey));
|
||||
assertThat(persisted.data).isEqualTo("foo");
|
||||
compoundIdEntity.data = "bar";
|
||||
@@ -474,7 +479,7 @@ class JpaTransactionManagerImplTest {
|
||||
|
||||
@Test
|
||||
void updateAll_succeeds() {
|
||||
insertInDb(moreEntities);
|
||||
persistResources(moreEntities);
|
||||
ImmutableList<TestEntity> updated =
|
||||
ImmutableList.of(
|
||||
new TestEntity("entity1", "foo_updated"),
|
||||
@@ -487,7 +492,7 @@ class JpaTransactionManagerImplTest {
|
||||
|
||||
@Test
|
||||
void updateAll_rollsBackWhenFailure() {
|
||||
insertInDb(moreEntities);
|
||||
persistResources(moreEntities);
|
||||
ImmutableList<TestEntity> updated =
|
||||
ImmutableList.of(
|
||||
new TestEntity("entity1", "foo_updated"),
|
||||
@@ -503,7 +508,7 @@ class JpaTransactionManagerImplTest {
|
||||
@Test
|
||||
void load_succeeds() {
|
||||
assertThat(tm().transact(() -> tm().exists(theEntity))).isFalse();
|
||||
insertInDb(theEntity);
|
||||
persistResource(theEntity);
|
||||
TestEntity persisted =
|
||||
tm().transact(() -> assertDetachedFromEntityManager(tm().loadByKey(theEntityKey)));
|
||||
assertThat(persisted.name).isEqualTo("theEntity");
|
||||
@@ -519,7 +524,7 @@ class JpaTransactionManagerImplTest {
|
||||
|
||||
@Test
|
||||
void loadByEntity_succeeds() {
|
||||
insertInDb(theEntity);
|
||||
persistResource(theEntity);
|
||||
TestEntity persisted =
|
||||
tm().transact(() -> assertDetachedFromEntityManager(tm().loadByEntity(theEntity)));
|
||||
assertThat(persisted.name).isEqualTo("theEntity");
|
||||
@@ -529,7 +534,7 @@ class JpaTransactionManagerImplTest {
|
||||
@Test
|
||||
void maybeLoad_succeeds() {
|
||||
assertThat(tm().transact(() -> tm().exists(theEntity))).isFalse();
|
||||
insertInDb(theEntity);
|
||||
persistResource(theEntity);
|
||||
TestEntity persisted =
|
||||
tm().transact(
|
||||
() -> assertDetachedFromEntityManager(tm().loadByKeyIfPresent(theEntityKey).get()));
|
||||
@@ -546,7 +551,7 @@ class JpaTransactionManagerImplTest {
|
||||
@Test
|
||||
void loadCompoundIdEntity_succeeds() {
|
||||
assertThat(tm().transact(() -> tm().exists(compoundIdEntity))).isFalse();
|
||||
insertInDb(compoundIdEntity);
|
||||
persistResource(compoundIdEntity);
|
||||
TestCompoundIdEntity persisted =
|
||||
tm().transact(() -> assertDetachedFromEntityManager(tm().loadByKey(compoundIdEntityKey)));
|
||||
assertThat(persisted.name).isEqualTo("compoundIdEntity");
|
||||
@@ -556,7 +561,7 @@ class JpaTransactionManagerImplTest {
|
||||
|
||||
@Test
|
||||
void loadByKeysIfPresent() {
|
||||
insertInDb(theEntity);
|
||||
persistResource(theEntity);
|
||||
tm().transact(
|
||||
() -> {
|
||||
ImmutableMap<VKey<? extends TestEntity>, TestEntity> results =
|
||||
@@ -571,7 +576,7 @@ class JpaTransactionManagerImplTest {
|
||||
|
||||
@Test
|
||||
void loadByKeys_succeeds() {
|
||||
insertInDb(theEntity);
|
||||
persistResource(theEntity);
|
||||
tm().transact(
|
||||
() -> {
|
||||
ImmutableMap<VKey<? extends TestEntity>, TestEntity> results =
|
||||
@@ -583,7 +588,7 @@ class JpaTransactionManagerImplTest {
|
||||
|
||||
@Test
|
||||
void loadByEntitiesIfPresent_succeeds() {
|
||||
insertInDb(theEntity);
|
||||
persistResource(theEntity);
|
||||
tm().transact(
|
||||
() -> {
|
||||
ImmutableList<TestEntity> results =
|
||||
@@ -596,7 +601,7 @@ class JpaTransactionManagerImplTest {
|
||||
|
||||
@Test
|
||||
void loadByEntities_succeeds() {
|
||||
insertInDb(theEntity);
|
||||
persistResource(theEntity);
|
||||
tm().transact(
|
||||
() -> {
|
||||
ImmutableList<TestEntity> results = tm().loadByEntities(ImmutableList.of(theEntity));
|
||||
@@ -607,7 +612,7 @@ class JpaTransactionManagerImplTest {
|
||||
|
||||
@Test
|
||||
void loadAll_succeeds() {
|
||||
insertInDb(moreEntities);
|
||||
persistResources(moreEntities);
|
||||
ImmutableList<TestEntity> persisted =
|
||||
tm().transact(
|
||||
() ->
|
||||
@@ -619,7 +624,7 @@ class JpaTransactionManagerImplTest {
|
||||
|
||||
@Test
|
||||
void loadSingleton_detaches() {
|
||||
insertInDb(theEntity);
|
||||
persistResource(theEntity);
|
||||
tm().transact(
|
||||
() ->
|
||||
assertThat(
|
||||
@@ -629,7 +634,7 @@ class JpaTransactionManagerImplTest {
|
||||
|
||||
@Test
|
||||
void delete_succeeds() {
|
||||
insertInDb(theEntity);
|
||||
persistResource(theEntity);
|
||||
assertThat(tm().transact(() -> tm().exists(theEntity))).isTrue();
|
||||
tm().transact(() -> tm().delete(theEntityKey));
|
||||
assertThat(tm().transact(() -> tm().exists(theEntity))).isFalse();
|
||||
@@ -644,7 +649,7 @@ class JpaTransactionManagerImplTest {
|
||||
|
||||
@Test
|
||||
void deleteCompoundIdEntity_succeeds() {
|
||||
insertInDb(compoundIdEntity);
|
||||
persistResource(compoundIdEntity);
|
||||
assertThat(tm().transact(() -> tm().exists(compoundIdEntity))).isTrue();
|
||||
tm().transact(() -> tm().delete(compoundIdEntityKey));
|
||||
assertThat(tm().transact(() -> tm().exists(compoundIdEntity))).isFalse();
|
||||
@@ -674,7 +679,7 @@ class JpaTransactionManagerImplTest {
|
||||
|
||||
@Test
|
||||
void loadAfterUpdate_fails() {
|
||||
insertInDb(theEntity);
|
||||
persistResource(theEntity);
|
||||
assertThat(
|
||||
assertThrows(
|
||||
IllegalStateException.class,
|
||||
@@ -690,7 +695,7 @@ class JpaTransactionManagerImplTest {
|
||||
|
||||
@Test
|
||||
void cqQuery_detaches() {
|
||||
insertInDb(moreEntities);
|
||||
persistResources(moreEntities);
|
||||
tm().transact(
|
||||
() ->
|
||||
assertThat(
|
||||
@@ -724,7 +729,7 @@ class JpaTransactionManagerImplTest {
|
||||
|
||||
@Test
|
||||
void query_detachesResults() {
|
||||
insertInDb(moreEntities);
|
||||
persistResources(moreEntities);
|
||||
tm().transact(
|
||||
() ->
|
||||
tm().query("FROM TestEntity", TestEntity.class)
|
||||
|
||||
@@ -21,7 +21,7 @@ import static google.registry.testing.DatabaseHelper.createTld;
|
||||
import static google.registry.testing.DatabaseHelper.persistActiveDomain;
|
||||
import static google.registry.testing.DatabaseHelper.persistDomainWithDependentResources;
|
||||
import static google.registry.testing.DatabaseHelper.persistResource;
|
||||
import static google.registry.testing.DatabaseHelper.persistSimpleResources;
|
||||
import static google.registry.testing.DatabaseHelper.persistResources;
|
||||
import static google.registry.testing.FullFieldsTestEntityHelper.makeAndPersistHost;
|
||||
import static google.registry.testing.FullFieldsTestEntityHelper.makeDomain;
|
||||
import static google.registry.testing.FullFieldsTestEntityHelper.makeHistoryEntry;
|
||||
@@ -78,7 +78,7 @@ class RdapDomainActionTest extends RdapActionBaseTestCase<RdapDomainAction> {
|
||||
createTld("lol");
|
||||
Registrar registrarLol = persistResource(makeRegistrar(
|
||||
"evilregistrar", "Yes Virginia <script>", Registrar.State.ACTIVE));
|
||||
persistSimpleResources(makeRegistrarPocs(registrarLol));
|
||||
persistResources(makeRegistrarPocs(registrarLol));
|
||||
registrantLol =
|
||||
FullFieldsTestEntityHelper.makeAndPersistContact(
|
||||
"5372808-ERL",
|
||||
@@ -152,7 +152,7 @@ class RdapDomainActionTest extends RdapActionBaseTestCase<RdapDomainAction> {
|
||||
createTld("xn--q9jyb4c");
|
||||
Registrar registrarIdn =
|
||||
persistResource(makeRegistrar("idnregistrar", "IDN Registrar", Registrar.State.ACTIVE));
|
||||
persistSimpleResources(makeRegistrarPocs(registrarIdn));
|
||||
persistResources(makeRegistrarPocs(registrarIdn));
|
||||
Contact registrantIdn =
|
||||
FullFieldsTestEntityHelper.makeAndPersistContact(
|
||||
"5372808-ERL",
|
||||
@@ -188,7 +188,7 @@ class RdapDomainActionTest extends RdapActionBaseTestCase<RdapDomainAction> {
|
||||
createTld("1.tld");
|
||||
Registrar registrar1Tld = persistResource(
|
||||
makeRegistrar("1tldregistrar", "Multilevel Registrar", Registrar.State.ACTIVE));
|
||||
persistSimpleResources(makeRegistrarPocs(registrar1Tld));
|
||||
persistResources(makeRegistrarPocs(registrar1Tld));
|
||||
Contact registrant1Tld =
|
||||
FullFieldsTestEntityHelper.makeAndPersistContact(
|
||||
"5372808-ERL",
|
||||
|
||||
@@ -21,7 +21,6 @@ import static google.registry.testing.DatabaseHelper.createTld;
|
||||
import static google.registry.testing.DatabaseHelper.persistDomainAsDeleted;
|
||||
import static google.registry.testing.DatabaseHelper.persistResource;
|
||||
import static google.registry.testing.DatabaseHelper.persistResources;
|
||||
import static google.registry.testing.DatabaseHelper.persistSimpleResources;
|
||||
import static google.registry.testing.FullFieldsTestEntityHelper.makeDomain;
|
||||
import static google.registry.testing.FullFieldsTestEntityHelper.makeHistoryEntry;
|
||||
import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrar;
|
||||
@@ -131,7 +130,7 @@ class RdapDomainSearchActionTest extends RdapSearchActionTestCase<RdapDomainSear
|
||||
registrar =
|
||||
persistResource(
|
||||
makeRegistrar("evilregistrar", "Yes Virginia <script>", Registrar.State.ACTIVE));
|
||||
persistSimpleResources(makeRegistrarPocs(registrar));
|
||||
persistResources(makeRegistrarPocs(registrar));
|
||||
contact1 =
|
||||
FullFieldsTestEntityHelper.makeAndPersistContact(
|
||||
"5372808-ERL", "Goblin Market", "lol@cat.lol", clock.nowUtc().minusYears(1), registrar);
|
||||
@@ -209,7 +208,7 @@ class RdapDomainSearchActionTest extends RdapSearchActionTestCase<RdapDomainSear
|
||||
registrar =
|
||||
persistResource(
|
||||
makeRegistrar("goodregistrar", "St. John Chrysostom", Registrar.State.ACTIVE));
|
||||
persistSimpleResources(makeRegistrarPocs(registrar));
|
||||
persistResources(makeRegistrarPocs(registrar));
|
||||
domainCatExample =
|
||||
persistResource(
|
||||
makeDomain(
|
||||
@@ -246,7 +245,7 @@ class RdapDomainSearchActionTest extends RdapSearchActionTestCase<RdapDomainSear
|
||||
// cat.みんな
|
||||
createTld("xn--q9jyb4c");
|
||||
registrar = persistResource(makeRegistrar("unicoderegistrar", "みんな", Registrar.State.ACTIVE));
|
||||
persistSimpleResources(makeRegistrarPocs(registrar));
|
||||
persistResources(makeRegistrarPocs(registrar));
|
||||
domainIdn =
|
||||
persistResource(
|
||||
makeDomain(
|
||||
@@ -285,7 +284,7 @@ class RdapDomainSearchActionTest extends RdapSearchActionTestCase<RdapDomainSear
|
||||
// cat.1.test
|
||||
createTld("1.test");
|
||||
registrar = persistResource(makeRegistrar("multiregistrar", "1.test", Registrar.State.ACTIVE));
|
||||
persistSimpleResources(makeRegistrarPocs(registrar));
|
||||
persistResources(makeRegistrarPocs(registrar));
|
||||
domainMultipart =
|
||||
persistResource(
|
||||
makeDomain(
|
||||
|
||||
@@ -17,7 +17,7 @@ package google.registry.rdap;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.testing.DatabaseHelper.createTld;
|
||||
import static google.registry.testing.DatabaseHelper.persistResource;
|
||||
import static google.registry.testing.DatabaseHelper.persistSimpleResources;
|
||||
import static google.registry.testing.DatabaseHelper.persistResources;
|
||||
import static google.registry.testing.FullFieldsTestEntityHelper.makeAndPersistDeletedContact;
|
||||
import static google.registry.testing.FullFieldsTestEntityHelper.makeDomain;
|
||||
import static google.registry.testing.FullFieldsTestEntityHelper.makeHost;
|
||||
@@ -63,7 +63,7 @@ class RdapEntityActionTest extends RdapActionBaseTestCase<RdapEntityAction> {
|
||||
createTld("lol");
|
||||
registrarLol = persistResource(makeRegistrar(
|
||||
"evilregistrar", "Yes Virginia <script>", Registrar.State.ACTIVE, 101L));
|
||||
persistSimpleResources(makeRegistrarPocs(registrarLol));
|
||||
persistResources(makeRegistrarPocs(registrarLol));
|
||||
registrant =
|
||||
FullFieldsTestEntityHelper.makeAndPersistContact(
|
||||
"8372808-REG",
|
||||
@@ -96,16 +96,16 @@ class RdapEntityActionTest extends RdapActionBaseTestCase<RdapEntityAction> {
|
||||
createTld("xn--q9jyb4c");
|
||||
Registrar registrarIdn = persistResource(
|
||||
makeRegistrar("idnregistrar", "IDN Registrar", Registrar.State.ACTIVE, 102L));
|
||||
persistSimpleResources(makeRegistrarPocs(registrarIdn));
|
||||
persistResources(makeRegistrarPocs(registrarIdn));
|
||||
// 1.tld
|
||||
createTld("1.tld");
|
||||
Registrar registrar1tld = persistResource(
|
||||
makeRegistrar("1tldregistrar", "Multilevel Registrar", Registrar.State.ACTIVE, 103L));
|
||||
persistSimpleResources(makeRegistrarPocs(registrar1tld));
|
||||
persistResources(makeRegistrarPocs(registrar1tld));
|
||||
// deleted registrar
|
||||
Registrar registrarDeleted = persistResource(
|
||||
makeRegistrar("deletedregistrar", "Yes Virginia <script>", Registrar.State.PENDING, 104L));
|
||||
persistSimpleResources(makeRegistrarPocs(registrarDeleted));
|
||||
persistResources(makeRegistrarPocs(registrarDeleted));
|
||||
// other contacts
|
||||
disconnectedContact =
|
||||
FullFieldsTestEntityHelper.makeAndPersistContact(
|
||||
|
||||
@@ -20,7 +20,6 @@ import static google.registry.request.Action.Method.GET;
|
||||
import static google.registry.testing.DatabaseHelper.createTld;
|
||||
import static google.registry.testing.DatabaseHelper.persistResource;
|
||||
import static google.registry.testing.DatabaseHelper.persistResources;
|
||||
import static google.registry.testing.DatabaseHelper.persistSimpleResources;
|
||||
import static google.registry.testing.FullFieldsTestEntityHelper.makeAndPersistDeletedContact;
|
||||
import static google.registry.testing.FullFieldsTestEntityHelper.makeHistoryEntry;
|
||||
import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrar;
|
||||
@@ -109,12 +108,12 @@ class RdapEntitySearchActionTest extends RdapSearchActionTestCase<RdapEntitySear
|
||||
registrarDeleted =
|
||||
persistResource(
|
||||
makeRegistrar("2-Registrar", "Yes Virginia <script>", Registrar.State.ACTIVE, 20L));
|
||||
persistSimpleResources(makeRegistrarPocs(registrarDeleted));
|
||||
persistResources(makeRegistrarPocs(registrarDeleted));
|
||||
|
||||
// inactive
|
||||
registrarInactive =
|
||||
persistResource(makeRegistrar("2-RegistrarInact", "No Way", Registrar.State.PENDING, 21L));
|
||||
persistSimpleResources(makeRegistrarPocs(registrarInactive));
|
||||
persistResources(makeRegistrarPocs(registrarInactive));
|
||||
|
||||
// test
|
||||
registrarTest =
|
||||
@@ -124,7 +123,7 @@ class RdapEntitySearchActionTest extends RdapSearchActionTestCase<RdapEntitySear
|
||||
.setType(Registrar.Type.TEST)
|
||||
.setIanaIdentifier(null)
|
||||
.build());
|
||||
persistSimpleResources(makeRegistrarPocs(registrarTest));
|
||||
persistResources(makeRegistrarPocs(registrarTest));
|
||||
|
||||
FullFieldsTestEntityHelper.makeAndPersistContact(
|
||||
"blinky",
|
||||
|
||||
@@ -18,7 +18,7 @@ import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.rdap.RdapDataStructures.EventAction.TRANSFER;
|
||||
import static google.registry.testing.DatabaseHelper.createTld;
|
||||
import static google.registry.testing.DatabaseHelper.persistResource;
|
||||
import static google.registry.testing.DatabaseHelper.persistSimpleResources;
|
||||
import static google.registry.testing.DatabaseHelper.persistResources;
|
||||
import static google.registry.testing.FullFieldsTestEntityHelper.makeAndPersistHost;
|
||||
import static google.registry.testing.FullFieldsTestEntityHelper.makeDomain;
|
||||
import static google.registry.testing.FullFieldsTestEntityHelper.makeHistoryEntry;
|
||||
@@ -95,7 +95,7 @@ class RdapJsonFormatterTest {
|
||||
clock.setTo(DateTime.parse("2000-01-01T00:00:00Z"));
|
||||
registrar = persistResource(registrar);
|
||||
|
||||
persistSimpleResources(makeMoreRegistrarContacts(registrar));
|
||||
persistResources(makeMoreRegistrarContacts(registrar));
|
||||
|
||||
contactRegistrant =
|
||||
FullFieldsTestEntityHelper.makeAndPersistContact(
|
||||
|
||||
@@ -21,7 +21,6 @@ import static google.registry.request.Action.Method.GET;
|
||||
import static google.registry.testing.DatabaseHelper.createTld;
|
||||
import static google.registry.testing.DatabaseHelper.persistResource;
|
||||
import static google.registry.testing.DatabaseHelper.persistResources;
|
||||
import static google.registry.testing.DatabaseHelper.persistSimpleResources;
|
||||
import static google.registry.testing.FullFieldsTestEntityHelper.makeDomain;
|
||||
import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrar;
|
||||
import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrarPocs;
|
||||
@@ -103,7 +102,7 @@ class RdapNameserverSearchActionTest extends RdapSearchActionTestCase<RdapNamese
|
||||
Registrar registrar =
|
||||
persistResource(
|
||||
makeRegistrar("evilregistrar", "Yes Virginia <script>", Registrar.State.ACTIVE));
|
||||
persistSimpleResources(makeRegistrarPocs(registrar));
|
||||
persistResources(makeRegistrarPocs(registrar));
|
||||
hostNs1CatLol =
|
||||
FullFieldsTestEntityHelper.makeAndPersistHost(
|
||||
"ns1.cat.lol", "1.2.3.4", clock.nowUtc().minusYears(1));
|
||||
@@ -118,14 +117,14 @@ class RdapNameserverSearchActionTest extends RdapSearchActionTestCase<RdapNamese
|
||||
// cat.みんな
|
||||
createTld("xn--q9jyb4c");
|
||||
registrar = persistResource(makeRegistrar("unicoderegistrar", "みんな", Registrar.State.ACTIVE));
|
||||
persistSimpleResources(makeRegistrarPocs(registrar));
|
||||
persistResources(makeRegistrarPocs(registrar));
|
||||
FullFieldsTestEntityHelper.makeAndPersistHost(
|
||||
"ns1.cat.みんな", "1.2.3.5", clock.nowUtc().minusYears(1));
|
||||
|
||||
// cat.1.test
|
||||
createTld("1.test");
|
||||
registrar = persistResource(makeRegistrar("multiregistrar", "1.test", Registrar.State.ACTIVE));
|
||||
persistSimpleResources(makeRegistrarPocs(registrar));
|
||||
persistResources(makeRegistrarPocs(registrar));
|
||||
FullFieldsTestEntityHelper.makeAndPersistHost(
|
||||
"ns1.cat.1.test", "1.2.3.6", clock.nowUtc().minusYears(1));
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ package google.registry.rdap;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.testing.DatabaseHelper.createTld;
|
||||
import static google.registry.testing.DatabaseHelper.loadRegistrar;
|
||||
import static google.registry.testing.DatabaseHelper.persistSimpleResource;
|
||||
import static google.registry.testing.DatabaseHelper.persistResource;
|
||||
import static jakarta.servlet.http.HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
|
||||
import static jakarta.servlet.http.HttpServletResponse.SC_OK;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
@@ -94,7 +94,7 @@ public final class UpdateRegistrarRdapBaseUrlsActionTest {
|
||||
|
||||
private static void persistRegistrar(
|
||||
String registrarId, Long ianaId, Registrar.Type type, String... rdapBaseUrls) {
|
||||
persistSimpleResource(
|
||||
persistResource(
|
||||
new Registrar.Builder()
|
||||
.setRegistrarId(registrarId)
|
||||
.setRegistrarName(registrarId)
|
||||
|
||||
@@ -18,7 +18,6 @@ import static com.google.common.io.BaseEncoding.base16;
|
||||
import static google.registry.testing.DatabaseHelper.generateNewContactHostRoid;
|
||||
import static google.registry.testing.DatabaseHelper.generateNewDomainRoid;
|
||||
import static google.registry.testing.DatabaseHelper.persistResource;
|
||||
import static google.registry.testing.DatabaseHelper.persistSimpleResource;
|
||||
import static google.registry.util.DateTimeUtils.END_OF_TIME;
|
||||
import static org.joda.money.CurrencyUnit.USD;
|
||||
|
||||
@@ -168,7 +167,7 @@ final class RdeFixtures {
|
||||
.build())
|
||||
.createVKey())
|
||||
.setAutorenewPollMessage(
|
||||
persistSimpleResource(
|
||||
persistResource(
|
||||
new PollMessage.Autorenew.Builder()
|
||||
.setTargetId(tld)
|
||||
.setRegistrarId("TheRegistrar")
|
||||
|
||||
@@ -23,7 +23,6 @@ import static google.registry.model.rde.RdeMode.FULL;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||
import static google.registry.testing.DatabaseHelper.createTld;
|
||||
import static google.registry.testing.DatabaseHelper.persistResource;
|
||||
import static google.registry.testing.DatabaseHelper.persistSimpleResource;
|
||||
import static google.registry.testing.GpgSystemCommandExtension.GPG_BINARY;
|
||||
import static google.registry.testing.SystemInfo.hasCommand;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
@@ -375,7 +374,7 @@ public class RdeUploadActionTest {
|
||||
URI uploadUrl = URI.create(String.format("sftp://user:password@localhost:%d/", port));
|
||||
DateTime stagingCursor = DateTime.parse("2010-10-18TZ");
|
||||
DateTime uploadCursor = DateTime.parse("2010-10-17TZ");
|
||||
persistSimpleResource(Cursor.createScoped(RDE_STAGING, stagingCursor, Tld.get("tld")));
|
||||
persistResource(Cursor.createScoped(RDE_STAGING, stagingCursor, Tld.get("tld")));
|
||||
BlobId ghostrydeR1FileWithPrefix =
|
||||
BlobId.of("bucket", JOB_PREFIX + "-job-name/tld_2010-10-17_full_S1_R1.xml.ghostryde");
|
||||
BlobId lengthR1FileWithPrefix =
|
||||
|
||||
@@ -19,7 +19,7 @@ import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.request.auth.AuthModule.BEARER_PREFIX;
|
||||
import static google.registry.request.auth.AuthModule.IAP_HEADER_NAME;
|
||||
import static google.registry.testing.DatabaseHelper.createAdminUser;
|
||||
import static google.registry.testing.DatabaseHelper.insertInDb;
|
||||
import static google.registry.testing.DatabaseHelper.persistResource;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@@ -139,12 +139,12 @@ public class OidcTokenAuthenticationMechanismTest {
|
||||
@Test
|
||||
void testAuthenticate_bothUserAndServiceAccount() throws Exception {
|
||||
User serviceUser =
|
||||
new User.Builder()
|
||||
.setEmailAddress("service@email.test")
|
||||
.setUserRoles(
|
||||
new UserRoles.Builder().setIsAdmin(true).setGlobalRole(GlobalRole.FTE).build())
|
||||
.build();
|
||||
insertInDb(serviceUser);
|
||||
persistResource(
|
||||
new User.Builder()
|
||||
.setEmailAddress("service@email.test")
|
||||
.setUserRoles(
|
||||
new UserRoles.Builder().setIsAdmin(true).setGlobalRole(GlobalRole.FTE).build())
|
||||
.build());
|
||||
payload.setEmail("service@email.test");
|
||||
authResult = authenticationMechanism.authenticate(request);
|
||||
assertThat(authResult.isAuthenticated()).isTrue();
|
||||
|
||||
@@ -16,11 +16,9 @@ package google.registry.schema.registrar;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.testing.DatabaseHelper.existsInDb;
|
||||
import static google.registry.testing.DatabaseHelper.insertInDb;
|
||||
import static google.registry.testing.DatabaseHelper.loadByKey;
|
||||
import static google.registry.testing.DatabaseHelper.updateInDb;
|
||||
import static google.registry.testing.DatabaseHelper.persistResource;
|
||||
import static org.joda.time.DateTimeZone.UTC;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import google.registry.model.registrar.Registrar;
|
||||
@@ -68,30 +66,24 @@ public class RegistrarDaoTest {
|
||||
@Test
|
||||
void saveNew_worksSuccessfully() {
|
||||
assertThat(existsInDb(testRegistrar)).isFalse();
|
||||
insertInDb(testRegistrar);
|
||||
persistResource(testRegistrar);
|
||||
assertThat(existsInDb(testRegistrar)).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void update_worksSuccessfully() {
|
||||
insertInDb(testRegistrar);
|
||||
persistResource(testRegistrar);
|
||||
Registrar persisted = loadByKey(registrarKey);
|
||||
assertThat(persisted.getRegistrarName()).isEqualTo("registrarName");
|
||||
updateInDb(persisted.asBuilder().setRegistrarName("changedRegistrarName").build());
|
||||
persistResource(persisted.asBuilder().setRegistrarName("changedRegistrarName").build());
|
||||
Registrar updated = loadByKey(registrarKey);
|
||||
assertThat(updated.getRegistrarName()).isEqualTo("changedRegistrarName");
|
||||
}
|
||||
|
||||
@Test
|
||||
void update_throwsExceptionWhenEntityDoesNotExist() {
|
||||
assertThat(existsInDb(testRegistrar)).isFalse();
|
||||
assertThrows(IllegalArgumentException.class, () -> updateInDb(testRegistrar));
|
||||
}
|
||||
|
||||
@Test
|
||||
void load_worksSuccessfully() {
|
||||
assertThat(existsInDb(testRegistrar)).isFalse();
|
||||
insertInDb(testRegistrar);
|
||||
persistResource(testRegistrar);
|
||||
Registrar persisted = loadByKey(registrarKey);
|
||||
|
||||
assertThat(persisted.getRegistrarId()).isEqualTo("registrarId");
|
||||
|
||||
@@ -18,7 +18,7 @@ import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.model.ImmutableObjectSubject.assertAboutImmutableObjects;
|
||||
import static google.registry.model.registrar.RegistrarPoc.Type.WHOIS;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||
import static google.registry.testing.DatabaseHelper.insertInDb;
|
||||
import static google.registry.testing.DatabaseHelper.persistResource;
|
||||
import static google.registry.testing.SqlHelper.saveRegistrar;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
@@ -62,7 +62,7 @@ class RegistrarPocTest {
|
||||
|
||||
@Test
|
||||
void testPersistence_succeeds() {
|
||||
insertInDb(testRegistrarPoc);
|
||||
persistResource(testRegistrarPoc);
|
||||
assertAboutImmutableObjects()
|
||||
.that(testRegistrarPoc)
|
||||
.isEqualExceptFields(testRegistrarPoc, "id");
|
||||
@@ -70,7 +70,7 @@ class RegistrarPocTest {
|
||||
|
||||
@Test
|
||||
void testSerializable_succeeds() {
|
||||
insertInDb(testRegistrarPoc);
|
||||
persistResource(testRegistrarPoc);
|
||||
RegistrarPoc persisted = tm().transact(() -> tm().loadByEntity(testRegistrarPoc));
|
||||
assertThat(SerializeUtils.serializeDeserialize(persisted)).isEqualTo(persisted);
|
||||
}
|
||||
|
||||
@@ -762,7 +762,7 @@ public final class DatabaseHelper {
|
||||
String registrarName,
|
||||
Registrar.Type type,
|
||||
@Nullable Long ianaIdentifier) {
|
||||
return persistSimpleResource(
|
||||
return persistResource(
|
||||
new Registrar.Builder()
|
||||
.setRegistrarId(registrarId)
|
||||
.setRegistrarName(registrarName)
|
||||
@@ -986,7 +986,13 @@ public final class DatabaseHelper {
|
||||
}
|
||||
|
||||
/** Persists the specified resources to the DB. */
|
||||
public static <R extends ImmutableObject> void persistResources(final Iterable<R> resources) {
|
||||
public static <R extends ImmutableObject> ImmutableList<R> persistResources(R... resources) {
|
||||
return persistResources(ImmutableList.copyOf(resources));
|
||||
}
|
||||
|
||||
/** Persists the specified resources to the DB. */
|
||||
public static <R extends ImmutableObject> ImmutableList<R> persistResources(
|
||||
final Iterable<R> resources) {
|
||||
for (R resource : resources) {
|
||||
assertWithMessage("Attempting to persist a Builder is almost certainly an error in test code")
|
||||
.that(resource)
|
||||
@@ -994,6 +1000,7 @@ public final class DatabaseHelper {
|
||||
}
|
||||
tm().transact(() -> resources.forEach(e -> tm().put(e)));
|
||||
maybeAdvanceClock();
|
||||
return loadByEntitiesIfPresent(resources);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1149,29 +1156,6 @@ public final class DatabaseHelper {
|
||||
.build());
|
||||
}
|
||||
|
||||
/** Persists a single resource, without adjusting foreign resources or keys. */
|
||||
public static <R> R persistSimpleResource(final R resource) {
|
||||
return persistSimpleResources(ImmutableList.of(resource)).get(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Like persistResource but for multiple entities, with no helper for saving
|
||||
* ForeignKeyedEppResources.
|
||||
*/
|
||||
public static <R> ImmutableList<R> persistSimpleResources(final Iterable<R> resources) {
|
||||
insertSimpleResources(resources);
|
||||
return tm().transact(() -> tm().loadByEntities(resources));
|
||||
}
|
||||
|
||||
/**
|
||||
* Like {@link #persistSimpleResources(Iterable)} but without reloading/returning the saved
|
||||
* entities.
|
||||
*/
|
||||
public static <R> void insertSimpleResources(final Iterable<R> resources) {
|
||||
tm().transact(() -> tm().putAll(ImmutableList.copyOf(resources)));
|
||||
maybeAdvanceClock();
|
||||
}
|
||||
|
||||
public static void deleteResource(final Object resource) {
|
||||
tm().transact(() -> tm().delete(resource));
|
||||
}
|
||||
@@ -1232,8 +1216,8 @@ public final class DatabaseHelper {
|
||||
/**
|
||||
* Loads (i.e. reloads) the specified entity from the DB.
|
||||
*
|
||||
* <p>If the transaction manager is Cloud SQL, then this creates an inner wrapping transaction for
|
||||
* convenience, so you don't need to wrap it in a transaction at the call site.
|
||||
* <p>This creates an inner wrapping transaction for convenience, so you don't need to wrap it in
|
||||
* a transaction at the call site.
|
||||
*/
|
||||
public static <T> T loadByEntity(T entity) {
|
||||
return tm().transact(() -> tm().loadByEntity(entity));
|
||||
@@ -1242,8 +1226,8 @@ public final class DatabaseHelper {
|
||||
/**
|
||||
* Loads the specified entity by its key from the DB.
|
||||
*
|
||||
* <p>If the transaction manager is Cloud SQL, then this creates an inner wrapping transaction for
|
||||
* convenience, so you don't need to wrap it in a transaction at the call site.
|
||||
* <p>This creates an inner wrapping transaction for convenience, so you don't need to wrap it in
|
||||
* a transaction at the call site.
|
||||
*/
|
||||
public static <T> T loadByKey(VKey<T> key) {
|
||||
return tm().transact(() -> tm().loadByKey(key));
|
||||
@@ -1252,8 +1236,8 @@ public final class DatabaseHelper {
|
||||
/**
|
||||
* Loads the specified entity by its key from the DB or empty if it doesn't exist.
|
||||
*
|
||||
* <p>If the transaction manager is Cloud SQL, then this creates an inner wrapping transaction for
|
||||
* convenience, so you don't need to wrap it in a transaction at the call site.
|
||||
* <p>This creates an inner wrapping transaction for convenience, so you don't need to wrap it in
|
||||
* a transaction at the call site.
|
||||
*/
|
||||
public static <T> Optional<T> loadByKeyIfPresent(VKey<T> key) {
|
||||
return tm().transact(() -> tm().loadByKeyIfPresent(key));
|
||||
@@ -1262,8 +1246,8 @@ public final class DatabaseHelper {
|
||||
/**
|
||||
* Loads the specified entities by their keys from the DB.
|
||||
*
|
||||
* <p>If the transaction manager is Cloud SQL, then this creates an inner wrapping transaction for
|
||||
* convenience, so you don't need to wrap it in a transaction at the call site.
|
||||
* <p>This creates an inner wrapping transaction for convenience, so you don't need to wrap it in
|
||||
* a transaction at the call site.
|
||||
*/
|
||||
public static <T> ImmutableCollection<T> loadByKeys(Iterable<? extends VKey<? extends T>> keys) {
|
||||
return tm().transact(() -> tm().loadByKeys(keys).values());
|
||||
@@ -1272,8 +1256,8 @@ public final class DatabaseHelper {
|
||||
/**
|
||||
* Loads all the entities of the specified type from the DB.
|
||||
*
|
||||
* <p>If the transaction manager is Cloud SQL, then this creates an inner wrapping transaction for
|
||||
* convenience, so you don't need to wrap it in a transaction at the call site.
|
||||
* <p>This creates an inner wrapping transaction for convenience, so you don't need to wrap it in
|
||||
* a transaction at the call site.
|
||||
*/
|
||||
public static <T> ImmutableList<T> loadAllOf(Class<T> clazz) {
|
||||
return tm().transact(() -> tm().loadAllOf(clazz));
|
||||
@@ -1282,8 +1266,8 @@ public final class DatabaseHelper {
|
||||
/**
|
||||
* Loads the set of entities by their keys from the DB.
|
||||
*
|
||||
* <p>If the transaction manager is Cloud SQL, then this creates an inner wrapping transaction for
|
||||
* convenience, so you don't need to wrap it in a transaction at the call site.
|
||||
* <p>This creates an inner wrapping transaction for convenience, so you don't need to wrap it in
|
||||
* a transaction at the call site.
|
||||
*
|
||||
* <p>Nonexistent keys / entities are absent from the resulting map, but no {@link
|
||||
* NoSuchElementException} will be thrown.
|
||||
@@ -1296,8 +1280,8 @@ public final class DatabaseHelper {
|
||||
/**
|
||||
* Loads all given entities from the database if possible.
|
||||
*
|
||||
* <p>If the transaction manager is Cloud SQL, then this creates an inner wrapping transaction for
|
||||
* convenience, so you don't need to wrap it in a transaction at the call site.
|
||||
* <p>This creates an inner wrapping transaction for convenience, so you don't need to wrap it in
|
||||
* a transaction at the call site.
|
||||
*
|
||||
* <p>Nonexistent entities are absent from the resulting list, but no {@link
|
||||
* NoSuchElementException} will be thrown.
|
||||
@@ -1316,36 +1300,6 @@ public final class DatabaseHelper {
|
||||
return tm().transact(() -> tm().exists(object));
|
||||
}
|
||||
|
||||
/** Inserts the given entity/entities into Cloud SQL in a single transaction. */
|
||||
public static <T extends ImmutableObject> void insertInDb(T... entities) {
|
||||
tm().transact(() -> tm().insertAll(entities));
|
||||
}
|
||||
|
||||
/** Inserts the given entities into Cloud SQL in a single transaction. */
|
||||
public static <T extends ImmutableObject> void insertInDb(ImmutableCollection<T> entities) {
|
||||
tm().transact(() -> tm().insertAll(entities));
|
||||
}
|
||||
|
||||
/** Puts the given entity/entities into Cloud SQL in a single transaction. */
|
||||
public static <T extends ImmutableObject> void putInDb(T... entities) {
|
||||
tm().transact(() -> tm().putAll(entities));
|
||||
}
|
||||
|
||||
/** Puts the given entities into Cloud SQL in a single transaction. */
|
||||
public static <T extends ImmutableObject> void putInDb(ImmutableCollection<T> entities) {
|
||||
tm().transact(() -> tm().putAll(entities));
|
||||
}
|
||||
|
||||
/** Updates the given entities in Cloud SQL in a single transaction. */
|
||||
public static <T extends ImmutableObject> void updateInDb(T... entities) {
|
||||
tm().transact(() -> tm().updateAll(entities));
|
||||
}
|
||||
|
||||
/** Updates the given entities in Cloud SQL in a single transaction. */
|
||||
public static <T extends ImmutableObject> void updateInDb(ImmutableCollection<T> entities) {
|
||||
tm().transact(() -> tm().updateAll(entities));
|
||||
}
|
||||
|
||||
/**
|
||||
* In JPA mode, asserts that the given entity is detached from the current entity manager.
|
||||
*
|
||||
|
||||
@@ -20,7 +20,7 @@ import static google.registry.testing.DatabaseHelper.createTld;
|
||||
import static google.registry.testing.DatabaseHelper.createTlds;
|
||||
import static google.registry.testing.DatabaseHelper.persistActiveDomain;
|
||||
import static google.registry.testing.DatabaseHelper.persistResource;
|
||||
import static google.registry.testing.DatabaseHelper.persistSimpleResources;
|
||||
import static google.registry.testing.DatabaseHelper.persistResources;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import com.beust.jcommander.ParameterException;
|
||||
@@ -61,7 +61,7 @@ class GetAllocationTokenCommandTest extends CommandTestCase<GetAllocationTokenCo
|
||||
.build());
|
||||
runCommand("foo");
|
||||
assertStdoutIs(
|
||||
"""
|
||||
"""
|
||||
AllocationToken: {
|
||||
allowedClientIds=[TheRegistrar]
|
||||
allowedEppActions=[CREATE]
|
||||
@@ -94,7 +94,7 @@ Token foo was not redeemed.
|
||||
void testSuccess_multipleTokens() throws Exception {
|
||||
createTlds("baz");
|
||||
ImmutableList<AllocationToken> tokens =
|
||||
persistSimpleResources(
|
||||
persistResources(
|
||||
ImmutableList.of(
|
||||
new AllocationToken.Builder()
|
||||
.setToken("fee")
|
||||
|
||||
@@ -29,7 +29,7 @@ public class GetUserCommandTest extends CommandTestCase<GetUserCommand> {
|
||||
|
||||
@BeforeEach
|
||||
void beforeEach() {
|
||||
DatabaseHelper.putInDb(
|
||||
DatabaseHelper.persistResources(
|
||||
new User.Builder()
|
||||
.setEmailAddress("johndoe@theregistrar.com")
|
||||
.setUserRoles(
|
||||
|
||||
@@ -23,9 +23,7 @@ import static google.registry.model.registrar.RegistrarPoc.Type.WHOIS;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||
import static google.registry.testing.DatabaseHelper.loadRegistrar;
|
||||
import static google.registry.testing.DatabaseHelper.persistResource;
|
||||
import static google.registry.testing.DatabaseHelper.persistSimpleResource;
|
||||
import static google.registry.testing.DatabaseHelper.persistSimpleResources;
|
||||
import static google.registry.testing.DatabaseHelper.putInDb;
|
||||
import static google.registry.testing.DatabaseHelper.persistResources;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
@@ -89,7 +87,7 @@ class RegistrarPocCommandTest extends CommandTestCase<RegistrarPocCommand> {
|
||||
.setVisibleInWhoisAsTech(true)
|
||||
.setVisibleInDomainWhoisAsAbuse(false)
|
||||
.build());
|
||||
persistSimpleResources(contacts);
|
||||
persistResources(contacts);
|
||||
runCommandForced(
|
||||
"--mode=UPDATE",
|
||||
"--name=Judith Registrar",
|
||||
@@ -124,13 +122,13 @@ class RegistrarPocCommandTest extends CommandTestCase<RegistrarPocCommand> {
|
||||
@Test
|
||||
void testUpdate_unsetOtherWhoisAbuseFlags() throws Exception {
|
||||
Registrar registrar = loadRegistrar("NewRegistrar");
|
||||
persistSimpleResource(
|
||||
persistResource(
|
||||
new RegistrarPoc.Builder()
|
||||
.setRegistrar(registrar)
|
||||
.setName("John Doe")
|
||||
.setEmailAddress("john.doe@example.com")
|
||||
.build());
|
||||
persistSimpleResource(
|
||||
persistResource(
|
||||
new RegistrarPoc.Builder()
|
||||
.setRegistrar(registrar)
|
||||
.setName("Johnna Doe")
|
||||
@@ -156,7 +154,7 @@ class RegistrarPocCommandTest extends CommandTestCase<RegistrarPocCommand> {
|
||||
@Test
|
||||
void testUpdate_cannotUnsetOnlyWhoisAbuseContact() {
|
||||
Registrar registrar = loadRegistrar("NewRegistrar");
|
||||
persistSimpleResource(
|
||||
persistResource(
|
||||
new RegistrarPoc.Builder()
|
||||
.setRegistrar(registrar)
|
||||
.setName("John Doe")
|
||||
@@ -183,7 +181,7 @@ class RegistrarPocCommandTest extends CommandTestCase<RegistrarPocCommand> {
|
||||
void testUpdate_emptyCommandModifiesNothing() throws Exception {
|
||||
Registrar registrar = loadRegistrar("NewRegistrar");
|
||||
RegistrarPoc existingContact =
|
||||
persistSimpleResource(
|
||||
persistResource(
|
||||
new RegistrarPoc.Builder()
|
||||
.setRegistrar(registrar)
|
||||
.setName("John Doe")
|
||||
@@ -213,7 +211,7 @@ class RegistrarPocCommandTest extends CommandTestCase<RegistrarPocCommand> {
|
||||
@Test
|
||||
void testUpdate_listOfTypesWorks() throws Exception {
|
||||
Registrar registrar = loadRegistrar("NewRegistrar");
|
||||
persistSimpleResource(
|
||||
persistResource(
|
||||
new RegistrarPoc.Builder()
|
||||
.setRegistrar(registrar)
|
||||
.setName("John Doe")
|
||||
@@ -237,7 +235,7 @@ class RegistrarPocCommandTest extends CommandTestCase<RegistrarPocCommand> {
|
||||
@Test
|
||||
void testUpdate_clearAllTypes() throws Exception {
|
||||
Registrar registrar = loadRegistrar("NewRegistrar");
|
||||
persistSimpleResource(
|
||||
persistResource(
|
||||
new RegistrarPoc.Builder()
|
||||
.setRegistrar(registrar)
|
||||
.setName("John Doe")
|
||||
@@ -290,7 +288,7 @@ class RegistrarPocCommandTest extends CommandTestCase<RegistrarPocCommand> {
|
||||
@Test
|
||||
void testDelete_failsOnDomainWhoisAbuseContact() {
|
||||
RegistrarPoc registrarPoc = loadRegistrar("NewRegistrar").getContacts().asList().getFirst();
|
||||
putInDb(registrarPoc.asBuilder().setVisibleInDomainWhoisAsAbuse(true).build());
|
||||
persistResource(registrarPoc.asBuilder().setVisibleInDomainWhoisAsAbuse(true).build());
|
||||
IllegalArgumentException thrown =
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
@@ -338,7 +336,7 @@ class RegistrarPocCommandTest extends CommandTestCase<RegistrarPocCommand> {
|
||||
void testUpdate_setAllowedToSetRegistryLockPassword() throws Exception {
|
||||
Registrar registrar = loadRegistrar("NewRegistrar");
|
||||
RegistrarPoc registrarPoc =
|
||||
persistSimpleResource(
|
||||
persistResource(
|
||||
new RegistrarPoc.Builder()
|
||||
.setRegistrar(registrar)
|
||||
.setName("Jim Doe")
|
||||
@@ -381,7 +379,7 @@ class RegistrarPocCommandTest extends CommandTestCase<RegistrarPocCommand> {
|
||||
void testUpdate_setAllowedToSetRegistryLockPassword_removesOldPassword() throws Exception {
|
||||
Registrar registrar = loadRegistrar("NewRegistrar");
|
||||
RegistrarPoc registrarPoc =
|
||||
persistSimpleResource(
|
||||
persistResource(
|
||||
new RegistrarPoc.Builder()
|
||||
.setRegistrar(registrar)
|
||||
.setName("Jim Doe")
|
||||
|
||||
@@ -26,7 +26,6 @@ import static google.registry.testing.DatabaseHelper.loadExistingUser;
|
||||
import static google.registry.testing.DatabaseHelper.loadRegistrar;
|
||||
import static google.registry.testing.DatabaseHelper.persistPremiumList;
|
||||
import static google.registry.testing.DatabaseHelper.persistResource;
|
||||
import static google.registry.testing.DatabaseHelper.putInDb;
|
||||
import static org.joda.money.CurrencyUnit.USD;
|
||||
import static org.joda.time.DateTimeZone.UTC;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
@@ -448,7 +447,7 @@ class SetupOteCommandTest extends CommandTestCase<SetupOteCommand> {
|
||||
|
||||
@Test
|
||||
void testFailure_userExists() {
|
||||
putInDb(
|
||||
persistResource(
|
||||
new User.Builder()
|
||||
.setEmailAddress("contact@email.com")
|
||||
.setUserRoles(new UserRoles.Builder().setGlobalRole(GlobalRole.FTE).build())
|
||||
@@ -494,7 +493,7 @@ class SetupOteCommandTest extends CommandTestCase<SetupOteCommand> {
|
||||
|
||||
@Test
|
||||
void testSuccess_userExists_replaceExisting() throws Exception {
|
||||
putInDb(
|
||||
persistResource(
|
||||
new User.Builder()
|
||||
.setEmailAddress("contact@email.com")
|
||||
.setUserRoles(new UserRoles.Builder().setGlobalRole(GlobalRole.FTE).build())
|
||||
|
||||
@@ -17,7 +17,6 @@ package google.registry.tools;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.testing.DatabaseHelper.loadExistingUser;
|
||||
import static google.registry.testing.DatabaseHelper.persistResource;
|
||||
import static google.registry.testing.DatabaseHelper.putInDb;
|
||||
import static org.junit.Assert.assertThrows;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
@@ -33,7 +32,7 @@ public class UpdateUserCommandTest extends CommandTestCase<UpdateUserCommand> {
|
||||
|
||||
@BeforeEach
|
||||
void beforeEach() throws Exception {
|
||||
putInDb(
|
||||
persistResource(
|
||||
new User.Builder()
|
||||
.setEmailAddress("user@example.test")
|
||||
.setUserRoles(new UserRoles.Builder().build())
|
||||
@@ -53,7 +52,7 @@ public class UpdateUserCommandTest extends CommandTestCase<UpdateUserCommand> {
|
||||
|
||||
@Test
|
||||
void testSuccess_removeRegistryLockEmail() throws Exception {
|
||||
putInDb(
|
||||
persistResource(
|
||||
loadExistingUser("user@example.test")
|
||||
.asBuilder()
|
||||
.setRegistryLockEmailAddress("registrylock@otherexample.test")
|
||||
|
||||
@@ -153,7 +153,7 @@ class ConsoleUsersActionTest extends ConsoleActionBaseTestCase {
|
||||
createAction(
|
||||
Optional.of(ConsoleApiParamsUtils.createFake(authResult)),
|
||||
Optional.of("POST"),
|
||||
Optional.of(new UserData("a@d", RegistrarRole.ACCOUNT_MANAGER.toString(), null)));
|
||||
Optional.of(new UserData("a@d", null, RegistrarRole.ACCOUNT_MANAGER.toString(), null)));
|
||||
action.cloudTasksUtils = cloudTasksHelper.getTestCloudTasksUtils();
|
||||
when(directory.users()).thenReturn(users);
|
||||
when(users.insert(any(com.google.api.services.directory.model.User.class))).thenReturn(insert);
|
||||
@@ -170,7 +170,7 @@ class ConsoleUsersActionTest extends ConsoleActionBaseTestCase {
|
||||
createAction(
|
||||
Optional.of(ConsoleApiParamsUtils.createFake(authResult)),
|
||||
Optional.of("POST"),
|
||||
Optional.of(new UserData("lol", RegistrarRole.ACCOUNT_MANAGER.toString(), null)));
|
||||
Optional.of(new UserData("lol", null, RegistrarRole.ACCOUNT_MANAGER.toString(), null)));
|
||||
action.cloudTasksUtils = cloudTasksHelper.getTestCloudTasksUtils();
|
||||
when(directory.users()).thenReturn(users);
|
||||
when(users.insert(any(com.google.api.services.directory.model.User.class))).thenReturn(insert);
|
||||
@@ -195,7 +195,8 @@ class ConsoleUsersActionTest extends ConsoleActionBaseTestCase {
|
||||
Optional.of(ConsoleApiParamsUtils.createFake(authResult)),
|
||||
Optional.of("DELETE"),
|
||||
Optional.of(
|
||||
new UserData("test3@test.com", RegistrarRole.ACCOUNT_MANAGER.toString(), null)));
|
||||
new UserData(
|
||||
"test3@test.com", null, RegistrarRole.ACCOUNT_MANAGER.toString(), null)));
|
||||
when(directory.users()).thenReturn(users);
|
||||
when(users.delete(any(String.class))).thenReturn(delete);
|
||||
action.run();
|
||||
@@ -213,7 +214,8 @@ class ConsoleUsersActionTest extends ConsoleActionBaseTestCase {
|
||||
Optional.of(ConsoleApiParamsUtils.createFake(authResult)),
|
||||
Optional.of("DELETE"),
|
||||
Optional.of(
|
||||
new UserData("email-1@email.com", RegistrarRole.ACCOUNT_MANAGER.toString(), null)));
|
||||
new UserData(
|
||||
"email-1@email.com", null, RegistrarRole.ACCOUNT_MANAGER.toString(), null)));
|
||||
when(directory.users()).thenReturn(users);
|
||||
when(users.delete(any(String.class))).thenReturn(delete);
|
||||
action.run();
|
||||
@@ -235,7 +237,8 @@ class ConsoleUsersActionTest extends ConsoleActionBaseTestCase {
|
||||
Optional.of(ConsoleApiParamsUtils.createFake(authResult)),
|
||||
Optional.of("DELETE"),
|
||||
Optional.of(
|
||||
new UserData("test2@test.com", RegistrarRole.ACCOUNT_MANAGER.toString(), null)));
|
||||
new UserData(
|
||||
"test2@test.com", null, RegistrarRole.ACCOUNT_MANAGER.toString(), null)));
|
||||
action.cloudTasksUtils = cloudTasksHelper.getTestCloudTasksUtils();
|
||||
when(directory.users()).thenReturn(users);
|
||||
when(users.delete(any(String.class))).thenReturn(delete);
|
||||
@@ -274,7 +277,8 @@ class ConsoleUsersActionTest extends ConsoleActionBaseTestCase {
|
||||
Optional.of(ConsoleApiParamsUtils.createFake(authResult)),
|
||||
Optional.of("DELETE"),
|
||||
Optional.of(
|
||||
new UserData("test4@test.com", RegistrarRole.ACCOUNT_MANAGER.toString(), null)));
|
||||
new UserData(
|
||||
"test4@test.com", null, RegistrarRole.ACCOUNT_MANAGER.toString(), null)));
|
||||
|
||||
action.cloudTasksUtils = cloudTasksHelper.getTestCloudTasksUtils();
|
||||
when(directory.users()).thenReturn(users);
|
||||
@@ -318,7 +322,8 @@ class ConsoleUsersActionTest extends ConsoleActionBaseTestCase {
|
||||
Optional.of(ConsoleApiParamsUtils.createFake(authResult)),
|
||||
Optional.of("POST"),
|
||||
Optional.of(
|
||||
new UserData("test3@test.com", RegistrarRole.ACCOUNT_MANAGER.toString(), null)));
|
||||
new UserData(
|
||||
"test3@test.com", null, RegistrarRole.ACCOUNT_MANAGER.toString(), null)));
|
||||
action.cloudTasksUtils = cloudTasksHelper.getTestCloudTasksUtils();
|
||||
when(directory.users()).thenReturn(users);
|
||||
when(users.insert(any(com.google.api.services.directory.model.User.class))).thenReturn(insert);
|
||||
@@ -348,7 +353,8 @@ class ConsoleUsersActionTest extends ConsoleActionBaseTestCase {
|
||||
Optional.of(ConsoleApiParamsUtils.createFake(authResult)),
|
||||
Optional.of("PUT"),
|
||||
Optional.of(
|
||||
new UserData("test2@test.com", RegistrarRole.ACCOUNT_MANAGER.toString(), null)));
|
||||
new UserData(
|
||||
"test2@test.com", null, RegistrarRole.ACCOUNT_MANAGER.toString(), null)));
|
||||
action.cloudTasksUtils = cloudTasksHelper.getTestCloudTasksUtils();
|
||||
action.run();
|
||||
assertThat(response.getStatus()).isEqualTo(SC_OK);
|
||||
@@ -374,7 +380,8 @@ class ConsoleUsersActionTest extends ConsoleActionBaseTestCase {
|
||||
Optional.of(ConsoleApiParamsUtils.createFake(authResult)),
|
||||
Optional.of("PUT"),
|
||||
Optional.of(
|
||||
new UserData("test3@test.com", RegistrarRole.ACCOUNT_MANAGER.toString(), null)));
|
||||
new UserData(
|
||||
"test3@test.com", null, RegistrarRole.ACCOUNT_MANAGER.toString(), null)));
|
||||
action.run();
|
||||
assertThat(response.getStatus()).isEqualTo(SC_FORBIDDEN);
|
||||
assertThat(response.getPayload())
|
||||
|
||||
@@ -21,9 +21,9 @@ import static google.registry.model.registrar.RegistrarPoc.Type.ADMIN;
|
||||
import static google.registry.model.registrar.RegistrarPoc.Type.MARKETING;
|
||||
import static google.registry.model.registrar.RegistrarPoc.Type.TECH;
|
||||
import static google.registry.testing.DatabaseHelper.deleteResource;
|
||||
import static google.registry.testing.DatabaseHelper.insertInDb;
|
||||
import static google.registry.testing.DatabaseHelper.loadAllOf;
|
||||
import static google.registry.testing.DatabaseHelper.persistResource;
|
||||
import static google.registry.testing.DatabaseHelper.persistResources;
|
||||
import static google.registry.testing.SqlHelper.saveRegistrar;
|
||||
import static jakarta.servlet.http.HttpServletResponse.SC_BAD_REQUEST;
|
||||
import static jakarta.servlet.http.HttpServletResponse.SC_FORBIDDEN;
|
||||
@@ -168,7 +168,7 @@ class ContactActionTest extends ConsoleActionBaseTestCase {
|
||||
|
||||
@Test
|
||||
void testFailure_postUpdateContactInfo_duplicateEmails() throws IOException {
|
||||
insertInDb(techPoc);
|
||||
persistResource(techPoc);
|
||||
ContactAction action =
|
||||
createAction(
|
||||
Action.Method.POST,
|
||||
@@ -323,7 +323,7 @@ class ContactActionTest extends ConsoleActionBaseTestCase {
|
||||
|
||||
@Test
|
||||
void testSuccess_postDeleteContactInfo() throws IOException {
|
||||
insertInDb(techPoc, marketingPoc);
|
||||
persistResources(techPoc, marketingPoc);
|
||||
ContactAction action =
|
||||
createAction(Action.Method.DELETE, fteUser, testRegistrar.getRegistrarId(), marketingPoc);
|
||||
action.run();
|
||||
|
||||
@@ -17,7 +17,7 @@ package google.registry.whois;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.testing.DatabaseHelper.persistNewRegistrar;
|
||||
import static google.registry.testing.DatabaseHelper.persistResource;
|
||||
import static google.registry.testing.DatabaseHelper.persistSimpleResources;
|
||||
import static google.registry.testing.DatabaseHelper.persistResources;
|
||||
import static google.registry.whois.WhoisTestData.loadFile;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
@@ -113,7 +113,7 @@ class RegistrarWhoisResponseTest {
|
||||
.setVisibleInWhoisAsTech(true)
|
||||
.build());
|
||||
persistResource(registrar);
|
||||
persistSimpleResources(contacts);
|
||||
persistResources(contacts);
|
||||
|
||||
RegistrarWhoisResponse registrarWhoisResponse =
|
||||
new RegistrarWhoisResponse(registrar, clock.nowUtc());
|
||||
|
||||
@@ -24,7 +24,7 @@ import static google.registry.testing.DatabaseHelper.createTlds;
|
||||
import static google.registry.testing.DatabaseHelper.loadRegistrar;
|
||||
import static google.registry.testing.DatabaseHelper.persistActiveDomain;
|
||||
import static google.registry.testing.DatabaseHelper.persistResource;
|
||||
import static google.registry.testing.DatabaseHelper.persistSimpleResources;
|
||||
import static google.registry.testing.DatabaseHelper.persistResources;
|
||||
import static google.registry.testing.FullFieldsTestEntityHelper.makeDomain;
|
||||
import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrar;
|
||||
import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrarPocs;
|
||||
@@ -134,7 +134,7 @@ public class WhoisActionTest {
|
||||
Registrar registrar =
|
||||
persistResource(makeRegistrar("evilregistrar", "Yes Virginia", ACTIVE));
|
||||
persistResource(makeDomainWithRegistrar(registrar));
|
||||
persistSimpleResources(makeRegistrarPocs(registrar));
|
||||
persistResources(makeRegistrarPocs(registrar));
|
||||
newWhoisAction("domain cat.lol\r\n").run();
|
||||
assertThat(response.getStatus()).isEqualTo(200);
|
||||
assertThat(response.getPayload()).isEqualTo(loadFile("whois_action_domain.txt"));
|
||||
@@ -145,7 +145,7 @@ public class WhoisActionTest {
|
||||
Registrar registrar =
|
||||
persistResource(makeRegistrar("evilregistrar", "Yes Virginia", ACTIVE));
|
||||
persistResource(makeDomainWithRegistrar(registrar));
|
||||
persistSimpleResources(makeRegistrarPocs(registrar));
|
||||
persistResources(makeRegistrarPocs(registrar));
|
||||
// Populate the cache for both the domain and contact.
|
||||
Domain domain = loadByForeignKeyByCacheIfEnabled(Domain.class, "cat.lol", clock.nowUtc()).get();
|
||||
Contact contact =
|
||||
@@ -178,7 +178,7 @@ public class WhoisActionTest {
|
||||
|
||||
Registrar registrar = persistResource(makeRegistrar("evilregistrar", "Yes Virginia", ACTIVE));
|
||||
persistResource(makeDomainWithRegistrar(registrar));
|
||||
persistSimpleResources(makeRegistrarPocs(registrar));
|
||||
persistResources(makeRegistrarPocs(registrar));
|
||||
newWhoisAction("domain cat.lol\r\n").run();
|
||||
assertThat(response.getStatus()).isEqualTo(200);
|
||||
assertThat(response.getPayload()).isEqualTo(loadFile("whois_action_domain.txt"));
|
||||
@@ -214,7 +214,7 @@ public class WhoisActionTest {
|
||||
.setTransferRequestTrid(Trid.create("client-trid", "server-trid"))
|
||||
.build())
|
||||
.build());
|
||||
persistSimpleResources(makeRegistrarPocs(registrar));
|
||||
persistResources(makeRegistrarPocs(registrar));
|
||||
clock.setTo(DateTime.parse("2011-01-01T00:00:00Z"));
|
||||
|
||||
newWhoisAction("domain cat.lol\r\n").run();
|
||||
@@ -241,7 +241,7 @@ public class WhoisActionTest {
|
||||
persistResource(
|
||||
FullFieldsTestEntityHelper.makeHost("ns2.cat.みんな", "bad:f00d:cafe::15:beef")),
|
||||
registrar));
|
||||
persistSimpleResources(makeRegistrarPocs(registrar));
|
||||
persistResources(makeRegistrarPocs(registrar));
|
||||
newWhoisAction("domain cat.みんな\r\n").run();
|
||||
assertThat(response.getStatus()).isEqualTo(200);
|
||||
assertThat(response.getPayload()).isEqualTo(loadFile("whois_action_idn_punycode.txt"));
|
||||
@@ -265,7 +265,7 @@ public class WhoisActionTest {
|
||||
persistResource(
|
||||
FullFieldsTestEntityHelper.makeHost("ns2.cat.みんな", "bad:f00d:cafe::15:beef")),
|
||||
registrar));
|
||||
persistSimpleResources(makeRegistrarPocs(registrar));
|
||||
persistResources(makeRegistrarPocs(registrar));
|
||||
newWhoisAction("domain cat.xn--q9jyb4c\r\n").run();
|
||||
assertThat(response.getStatus()).isEqualTo(200);
|
||||
assertThat(response.getPayload()).isEqualTo(loadFile("whois_action_idn_punycode.txt"));
|
||||
@@ -311,7 +311,7 @@ public class WhoisActionTest {
|
||||
persistResource(
|
||||
FullFieldsTestEntityHelper.makeHost("ns2.cat.lol", "bad:f00d:cafe::15:beef")),
|
||||
registrar));
|
||||
persistSimpleResources(makeRegistrarPocs(registrar));
|
||||
persistResources(makeRegistrarPocs(registrar));
|
||||
newWhoisAction("domain cat.lol\r\n").run();
|
||||
assertThat(response.getStatus()).isEqualTo(200);
|
||||
assertThat(response.getPayload()).isEqualTo(loadFile("whois_action_domain_not_found.txt"));
|
||||
@@ -339,7 +339,7 @@ public class WhoisActionTest {
|
||||
.asBuilder()
|
||||
.setDeletionTime(clock.nowUtc().minusDays(1))
|
||||
.build());
|
||||
persistSimpleResources(makeRegistrarPocs(registrar));
|
||||
persistResources(makeRegistrarPocs(registrar));
|
||||
newWhoisAction("domain cat.lol\r\n").run();
|
||||
assertThat(response.getStatus()).isEqualTo(200);
|
||||
assertThat(response.getPayload()).isEqualTo(loadFile("whois_action_domain_not_found.txt"));
|
||||
@@ -396,7 +396,7 @@ public class WhoisActionTest {
|
||||
.asBuilder()
|
||||
.setCreationTimeForTest(clock.nowUtc())
|
||||
.build());
|
||||
persistSimpleResources(makeRegistrarPocs(registrar));
|
||||
persistResources(makeRegistrarPocs(registrar));
|
||||
assertThat(domain1.getRepoId()).isNotEqualTo(domain2.getRepoId());
|
||||
newWhoisAction("domain cat.lol\r\n").run();
|
||||
assertThat(response.getStatus()).isEqualTo(200);
|
||||
@@ -546,7 +546,7 @@ public class WhoisActionTest {
|
||||
void testRun_registrarLookup_works() {
|
||||
Registrar registrar = persistResource(
|
||||
makeRegistrar("example", "Example Registrar, Inc.", ACTIVE));
|
||||
persistSimpleResources(makeRegistrarPocs(registrar));
|
||||
persistResources(makeRegistrarPocs(registrar));
|
||||
// Notice the partial search without "inc".
|
||||
newWhoisAction("registrar example registrar").run();
|
||||
assertThat(response.getStatus()).isEqualTo(200);
|
||||
@@ -562,7 +562,7 @@ public class WhoisActionTest {
|
||||
.setIanaIdentifier(9995L)
|
||||
.setType(PDT)
|
||||
.build());
|
||||
persistSimpleResources(makeRegistrarPocs(registrar));
|
||||
persistResources(makeRegistrarPocs(registrar));
|
||||
// Notice the partial search without "inc".
|
||||
newWhoisAction("registrar example registrar").run();
|
||||
assertThat(response.getStatus()).isEqualTo(200);
|
||||
@@ -573,7 +573,7 @@ public class WhoisActionTest {
|
||||
void testRun_registrarLookupInPendingState_returnsNotFound() {
|
||||
Registrar registrar = persistResource(
|
||||
makeRegistrar("example", "Example Registrar, Inc.", Registrar.State.PENDING));
|
||||
persistSimpleResources(makeRegistrarPocs(registrar));
|
||||
persistResources(makeRegistrarPocs(registrar));
|
||||
newWhoisAction("registrar Example Registrar, Inc.").run();
|
||||
assertThat(response.getStatus()).isEqualTo(200);
|
||||
assertThat(response.getPayload()).isEqualTo(loadFile("whois_action_registrar_not_found.txt"));
|
||||
@@ -587,7 +587,7 @@ public class WhoisActionTest {
|
||||
.setIanaIdentifier(null)
|
||||
.setType(Registrar.Type.TEST)
|
||||
.build());
|
||||
persistSimpleResources(makeRegistrarPocs(registrar));
|
||||
persistResources(makeRegistrarPocs(registrar));
|
||||
newWhoisAction("registrar Example Registrar, Inc.").run();
|
||||
assertThat(response.getStatus()).isEqualTo(200);
|
||||
assertThat(response.getPayload()).isEqualTo(loadFile("whois_action_registrar_not_found.txt"));
|
||||
@@ -612,7 +612,7 @@ public class WhoisActionTest {
|
||||
persistResource(
|
||||
FullFieldsTestEntityHelper.makeHost("ns2.cat.1.test", "bad:f00d:cafe::15:beef")),
|
||||
registrar));
|
||||
persistSimpleResources(makeRegistrarPocs(registrar));
|
||||
persistResources(makeRegistrarPocs(registrar));
|
||||
|
||||
newWhoisAction("domain cat.1.test\r\n").run();
|
||||
assertThat(response.getStatus()).isEqualTo(200);
|
||||
|
||||
@@ -21,7 +21,7 @@ import static google.registry.model.registrar.Registrar.State.ACTIVE;
|
||||
import static google.registry.testing.DatabaseHelper.createTlds;
|
||||
import static google.registry.testing.DatabaseHelper.loadRegistrar;
|
||||
import static google.registry.testing.DatabaseHelper.persistResource;
|
||||
import static google.registry.testing.DatabaseHelper.persistSimpleResources;
|
||||
import static google.registry.testing.DatabaseHelper.persistResources;
|
||||
import static google.registry.testing.FullFieldsTestEntityHelper.makeDomain;
|
||||
import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrar;
|
||||
import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrarPocs;
|
||||
@@ -137,7 +137,7 @@ class WhoisHttpActionTest {
|
||||
persistResource(
|
||||
FullFieldsTestEntityHelper.makeHost("ns2.cat.lol", "bad:f00d:cafe::15:beef")),
|
||||
registrar));
|
||||
persistSimpleResources(makeRegistrarPocs(registrar));
|
||||
persistResources(makeRegistrarPocs(registrar));
|
||||
newWhoisHttpAction("/domain/cat.lol").run();
|
||||
assertThat(response.getStatus()).isEqualTo(404);
|
||||
assertThat(response.getContentType()).isEqualTo(PLAIN_TEXT_UTF_8);
|
||||
@@ -162,7 +162,7 @@ class WhoisHttpActionTest {
|
||||
persistResource(
|
||||
FullFieldsTestEntityHelper.makeHost("ns2.cat.みんな", "bad:f00d:cafe::15:beef")),
|
||||
registrar));
|
||||
persistSimpleResources(makeRegistrarPocs(registrar));
|
||||
persistResources(makeRegistrarPocs(registrar));
|
||||
newWhoisHttpAction("/domain/cat.みんな").run();
|
||||
assertThat(response.getStatus()).isEqualTo(200);
|
||||
assertThat(response.getPayload()).isEqualTo(loadFile("whois_action_idn_utf8.txt"));
|
||||
@@ -243,7 +243,7 @@ class WhoisHttpActionTest {
|
||||
persistResource(
|
||||
FullFieldsTestEntityHelper.makeHost("ns2.cat.lol", "bad:f00d:cafe::15:beef")),
|
||||
registrar));
|
||||
persistSimpleResources(makeRegistrarPocs(registrar));
|
||||
persistResources(makeRegistrarPocs(registrar));
|
||||
newWhoisHttpAction("domain cat.lol\r\n").run();
|
||||
assertThat(response.getStatus()).isEqualTo(200);
|
||||
assertThat(response.getPayload()).isEqualTo(loadFile("whois_action_domain.txt"));
|
||||
@@ -288,7 +288,7 @@ class WhoisHttpActionTest {
|
||||
persistResource(
|
||||
FullFieldsTestEntityHelper.makeHost("ns2.cat.みんな", "bad:f00d:cafe::15:beef")),
|
||||
registrar));
|
||||
persistSimpleResources(makeRegistrarPocs(registrar));
|
||||
persistResources(makeRegistrarPocs(registrar));
|
||||
newWhoisHttpAction("/domain/cat.xn--q9jyb4c").run();
|
||||
assertThat(response.getPayload()).isEqualTo(loadFile("whois_action_idn_utf8.txt"));
|
||||
}
|
||||
@@ -392,7 +392,7 @@ class WhoisHttpActionTest {
|
||||
void testRun_registrarLookup_works() {
|
||||
Registrar registrar = persistResource(
|
||||
makeRegistrar("example", "Example Registrar, Inc.", Registrar.State.ACTIVE));
|
||||
persistSimpleResources(makeRegistrarPocs(registrar));
|
||||
persistResources(makeRegistrarPocs(registrar));
|
||||
// Notice the partial search without "inc".
|
||||
newWhoisHttpAction("/registrar/Example%20Registrar").run();
|
||||
assertThat(response.getStatus()).isEqualTo(200);
|
||||
@@ -403,7 +403,7 @@ class WhoisHttpActionTest {
|
||||
void testRun_registrarLookupInPendingState_returnsNotFound() {
|
||||
Registrar registrar = persistResource(
|
||||
makeRegistrar("example", "Example Registrar, Inc.", Registrar.State.PENDING));
|
||||
persistSimpleResources(makeRegistrarPocs(registrar));
|
||||
persistResources(makeRegistrarPocs(registrar));
|
||||
newWhoisHttpAction("/registrar/Example%20Registrar,%20Inc.").run();
|
||||
assertThat(response.getStatus()).isEqualTo(404);
|
||||
assertThat(response.getPayload()).isEqualTo(loadFile("whois_action_registrar_not_found.txt"));
|
||||
@@ -414,7 +414,7 @@ class WhoisHttpActionTest {
|
||||
Registrar registrar = persistResource(
|
||||
makeRegistrar("example", "Example Registrar, Inc.", Registrar.State.ACTIVE)
|
||||
.asBuilder().setType(Registrar.Type.TEST).setIanaIdentifier(null).build());
|
||||
persistSimpleResources(makeRegistrarPocs(registrar));
|
||||
persistResources(makeRegistrarPocs(registrar));
|
||||
newWhoisHttpAction("/registrar/Example%20Registrar,%20Inc.").run();
|
||||
assertThat(response.getStatus()).isEqualTo(404);
|
||||
assertThat(response.getPayload()).isEqualTo(loadFile("whois_action_registrar_not_found.txt"));
|
||||
|
||||
@@ -23,7 +23,7 @@ buildscript {
|
||||
}
|
||||
|
||||
plugins {
|
||||
id "org.flywaydb.flyway" version "11.0.1"
|
||||
id "org.flywaydb.flyway" version "9.22.3"
|
||||
id 'maven-publish'
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# This file defines properties used by the gradle build. It must be kept in
|
||||
f# This file defines properties used by the gradle build. It must be kept in
|
||||
# sync with config/nom_build.py.
|
||||
#
|
||||
# To regenerate, run ./nom_build --generate-gradle-properties
|
||||
|
||||
Reference in New Issue
Block a user