mirror of
https://github.com/google/nomulus.git
synced 2025-08-03 16:32:11 +02:00
Update GCL dependency to avoid security alert (#1139)
* Update GCL dependency to avoid security alert This required a few changes in addition to the dependency update. - a few transitive / required dependency updates as well - updating soyutils_usegoog.js and adding checks.js because they're necessary as part of the Soy compilation process - Using a trustedResourceUri in the buildSrc Soy compilation instead of a string - changing the arguments to the Soy-to-Java compiler to comply with the new version - Moving all Soy UI files to be in the registrar directory. This was not the case before due to previous thinking that we'd have separate admin and registrar consoles -- this is no longer the case so it's no longer necessary. This necessitated various refactorings and reference changes. - The new soy-to-javascript compiler requires this, as it removes the "deps" param that we were previously using to say "use the general UI utils as dependencies for the registrar-console files". - Creating a SQL environment and loading test data in the test server main method -- previously, the local test server did not work. - Fix some JS code that was referencing now-deleted library functions - Removal of the Karma tests, as the karma-closure library hasn't been updated since 2018 and it no longer works. We never noticed any errors from the Karma tests, we never change the JS, and we have the Java+Selenium screenshot differ tests to test the UI anyway.
This commit is contained in:
parent
bf1c34cc3b
commit
16641e05a1
103 changed files with 1336 additions and 3282 deletions
|
@ -433,12 +433,9 @@ task soyToJava {
|
|||
// Relative paths of soy directories.
|
||||
def spec11SoyDir = "google/registry/reporting/spec11/soy"
|
||||
def toolsSoyDir = "google/registry/tools/soy"
|
||||
def uiSoyDir = "google/registry/ui/soy"
|
||||
def registrarSoyDir = "google/registry/ui/soy/registrar"
|
||||
|
||||
def soyRelativeDirs = [
|
||||
spec11SoyDir, toolsSoyDir, uiSoyDir, registrarSoyDir,
|
||||
]
|
||||
def soyRelativeDirs = [spec11SoyDir, toolsSoyDir, registrarSoyDir]
|
||||
soyRelativeDirs.each {
|
||||
inputs.dir "${resourcesSourceDir}/${it}"
|
||||
outputs.dir "${generatedDir}/${it}"
|
||||
|
@ -452,7 +449,8 @@ task soyToJava {
|
|||
"--outputDirectory", "${outputDirectory}",
|
||||
"--javaClassNameSource", "filename",
|
||||
"--allowExternalCalls", "true",
|
||||
"--srcs", "${soyFiles.join(',')}"
|
||||
"--srcs", "${soyFiles.join(',')}",
|
||||
"--compileTimeGlobalsFile", "${resourcesSourceDir}/google/registry/ui/globals.txt"
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -469,14 +467,6 @@ task soyToJava {
|
|||
dir: "${resourcesSourceDir}/${registrarSoyDir}",
|
||||
include: ['**/*.soy']))
|
||||
|
||||
soyToJava('google.registry.ui.soy',
|
||||
"${generatedDir}/${uiSoyDir}",
|
||||
files {
|
||||
file("${resourcesSourceDir}/${uiSoyDir}").listFiles()
|
||||
}.filter {
|
||||
it.name.endsWith(".soy")
|
||||
})
|
||||
|
||||
soyToJava('google.registry.reporting.spec11.soy',
|
||||
"${generatedDir}/${spec11SoyDir}",
|
||||
fileTree(
|
||||
|
@ -485,42 +475,24 @@ task soyToJava {
|
|||
}
|
||||
}
|
||||
|
||||
task soyToJS {
|
||||
def rootSoyDirectory = "${resourcesSourceDir}/google/registry/ui/soy"
|
||||
def outputSoyDirectory = "${generatedDir}/google/registry/ui/soy"
|
||||
task soyToJS(type: JavaExec) {
|
||||
def rootSoyDirectory = "${resourcesSourceDir}/google/registry/ui/soy/registrar"
|
||||
def outputSoyDirectory = "${generatedDir}/google/registry/ui/soy/registrar"
|
||||
inputs.dir rootSoyDirectory
|
||||
outputs.dir outputSoyDirectory
|
||||
|
||||
ext.soyToJS = { outputDirectory, soyFiles , deps->
|
||||
javaexec {
|
||||
main = "com.google.template.soy.SoyToJsSrcCompiler"
|
||||
classpath configurations.soy
|
||||
def inputSoyFiles = files {
|
||||
file("${rootSoyDirectory}").listFiles()
|
||||
}.filter {
|
||||
it.name.endsWith(".soy")
|
||||
}
|
||||
|
||||
args "--outputPathFormat", "${outputDirectory}/{INPUT_FILE_NAME}.js",
|
||||
classpath configurations.soy
|
||||
main = "com.google.template.soy.SoyToJsSrcCompiler"
|
||||
args "--outputPathFormat", "${outputSoyDirectory}/{INPUT_FILE_NAME}.js",
|
||||
"--allowExternalCalls", "false",
|
||||
"--srcs", "${soyFiles.join(',')}",
|
||||
"--shouldProvideRequireSoyNamespaces", "true",
|
||||
"--srcs", "${inputSoyFiles.join(',')}",
|
||||
"--compileTimeGlobalsFile", "${resourcesSourceDir}/google/registry/ui/globals.txt"
|
||||
if (deps != "") {
|
||||
args "--deps", "${deps.join(',')}"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
doLast {
|
||||
def rootSoyFiles =
|
||||
fileTree(
|
||||
dir: "${rootSoyDirectory}",
|
||||
include: ['*.soy'])
|
||||
|
||||
soyToJS("${outputSoyDirectory}", rootSoyFiles, "")
|
||||
soyToJS("${outputSoyDirectory}/registrar",
|
||||
files {
|
||||
file("${rootSoyDirectory}/registrar").listFiles()
|
||||
}.filter {
|
||||
it.name.endsWith(".soy")
|
||||
}, rootSoyFiles)
|
||||
}
|
||||
}
|
||||
|
||||
task stylesheetsToJavascript {
|
||||
|
@ -603,8 +575,8 @@ task compileProdJS(type: JavaExec) {
|
|||
closureArgs << "--generate_exports"
|
||||
|
||||
// manually include all the required js files
|
||||
closureArgs << "--js=${nodeModulesDir}/google-closure-library/**.js"
|
||||
closureArgs << "--js=${jsDir}/soyutils_usegoog.js"
|
||||
closureArgs << "--js=${nodeModulesDir}/google-closure-library/**/*.js"
|
||||
closureArgs << "--js=${jsDir}/*.js"
|
||||
closureArgs << "--js=${cssSourceDir}/registrar_bin.css.js"
|
||||
closureArgs << "--js=${jsSourceDir}/**.js"
|
||||
closureArgs << "--js=${externsDir}/json.js"
|
||||
|
@ -631,15 +603,6 @@ compileProdJS.dependsOn processResources
|
|||
compileProdJS.dependsOn processTestResources
|
||||
compileProdJS.dependsOn soyToJS
|
||||
|
||||
task karmaTest(type: Exec) {
|
||||
dependsOn ':npmInstall'
|
||||
workingDir rootProject.projectDir
|
||||
executable '.gradle/nodejs/node-v14.15.5-linux-x64/bin/node'
|
||||
args('node_modules/karma/bin/karma', 'start', "${project.projectDir}/karma.conf.js")
|
||||
}
|
||||
|
||||
test.dependsOn karmaTest
|
||||
|
||||
// Make testing artifacts available to be depended up on by other projects.
|
||||
// TODO: factor out google.registry.testing to be a separate project.
|
||||
task testJar(type: Jar) {
|
||||
|
|
|
@ -1,15 +1,4 @@
|
|||
# This is a Gradle generated file for dependency locking.
|
||||
# Manual edits can break the build and are not advised.
|
||||
# This file is expected to be part of source control.
|
||||
args4j:args4j:2.0.26
|
||||
com.google.code.findbugs:jsr305:3.0.2
|
||||
com.google.code.gson:gson:2.7
|
||||
com.google.errorprone:error_prone_annotations:2.3.1
|
||||
com.google.guava:guava:25.1-jre
|
||||
com.google.j2objc:j2objc-annotations:1.1
|
||||
com.google.javascript:closure-compiler-externs:v20190301
|
||||
com.google.javascript:closure-compiler:v20190301
|
||||
com.google.jsinterop:jsinterop-annotations:1.0.0
|
||||
com.google.protobuf:protobuf-java:3.0.2
|
||||
org.checkerframework:checker-qual:2.0.0
|
||||
org.codehaus.mojo:animal-sniffer-annotations:1.14
|
||||
com.google.javascript:closure-compiler:v20210505
|
||||
|
|
|
@ -105,9 +105,10 @@ com.google.cloud:google-cloud-secretmanager:1.4.0
|
|||
com.google.cloud:google-cloud-spanner:2.0.2
|
||||
com.google.code.findbugs:jsr305:3.0.2
|
||||
com.google.code.gson:gson:2.8.6
|
||||
com.google.common.html.types:types:1.0.4
|
||||
com.google.common.html.types:types:1.0.6
|
||||
com.google.dagger:dagger:2.33
|
||||
com.google.errorprone:error_prone_annotations:2.5.1
|
||||
com.google.escapevelocity:escapevelocity:0.9.1
|
||||
com.google.flogger:flogger-system-backend:0.5.1
|
||||
com.google.flogger:flogger:0.5.1
|
||||
com.google.flogger:google-extensions:0.5.1
|
||||
|
@ -135,7 +136,7 @@ com.google.oauth-client:google-oauth-client:1.31.4
|
|||
com.google.protobuf:protobuf-java-util:3.15.2
|
||||
com.google.protobuf:protobuf-java:3.15.2
|
||||
com.google.re2j:re2j:1.6
|
||||
com.google.template:soy:2018-03-14
|
||||
com.google.template:soy:2021-02-01
|
||||
com.googlecode.charts4j:charts4j:1.3
|
||||
com.googlecode.json-simple:json-simple:1.1.1
|
||||
com.ibm.icu:icu4j:68.2
|
||||
|
|
|
@ -104,9 +104,10 @@ com.google.cloud:google-cloud-secretmanager:1.4.0
|
|||
com.google.cloud:google-cloud-spanner:2.0.2
|
||||
com.google.code.findbugs:jsr305:3.0.2
|
||||
com.google.code.gson:gson:2.8.6
|
||||
com.google.common.html.types:types:1.0.4
|
||||
com.google.common.html.types:types:1.0.6
|
||||
com.google.dagger:dagger:2.33
|
||||
com.google.errorprone:error_prone_annotations:2.5.1
|
||||
com.google.escapevelocity:escapevelocity:0.9.1
|
||||
com.google.flogger:flogger:0.5.1
|
||||
com.google.flogger:google-extensions:0.5.1
|
||||
com.google.guava:failureaccess:1.0.1
|
||||
|
@ -133,7 +134,7 @@ com.google.oauth-client:google-oauth-client:1.31.4
|
|||
com.google.protobuf:protobuf-java-util:3.14.0
|
||||
com.google.protobuf:protobuf-java:3.15.2
|
||||
com.google.re2j:re2j:1.6
|
||||
com.google.template:soy:2018-03-14
|
||||
com.google.template:soy:2021-02-01
|
||||
com.googlecode.charts4j:charts4j:1.3
|
||||
com.googlecode.json-simple:json-simple:1.1.1
|
||||
com.ibm.icu:icu4j:68.2
|
||||
|
|
|
@ -110,9 +110,10 @@ com.google.cloud:google-cloud-secretmanager:1.4.0
|
|||
com.google.cloud:google-cloud-spanner:2.0.2
|
||||
com.google.code.findbugs:jsr305:3.0.2
|
||||
com.google.code.gson:gson:2.8.6
|
||||
com.google.common.html.types:types:1.0.4
|
||||
com.google.common.html.types:types:1.0.6
|
||||
com.google.dagger:dagger:2.33
|
||||
com.google.errorprone:error_prone_annotations:2.5.1
|
||||
com.google.escapevelocity:escapevelocity:0.9.1
|
||||
com.google.flogger:flogger-system-backend:0.5.1
|
||||
com.google.flogger:flogger:0.5.1
|
||||
com.google.flogger:google-extensions:0.5.1
|
||||
|
@ -140,7 +141,7 @@ com.google.oauth-client:google-oauth-client:1.31.4
|
|||
com.google.protobuf:protobuf-java-util:3.15.2
|
||||
com.google.protobuf:protobuf-java:3.15.2
|
||||
com.google.re2j:re2j:1.6
|
||||
com.google.template:soy:2018-03-14
|
||||
com.google.template:soy:2021-02-01
|
||||
com.googlecode.charts4j:charts4j:1.3
|
||||
com.googlecode.json-simple:json-simple:1.1.1
|
||||
com.ibm.icu:icu4j:68.2
|
||||
|
|
|
@ -110,9 +110,10 @@ com.google.cloud:google-cloud-secretmanager:1.4.0
|
|||
com.google.cloud:google-cloud-spanner:2.0.2
|
||||
com.google.code.findbugs:jsr305:3.0.2
|
||||
com.google.code.gson:gson:2.8.6
|
||||
com.google.common.html.types:types:1.0.4
|
||||
com.google.common.html.types:types:1.0.6
|
||||
com.google.dagger:dagger:2.33
|
||||
com.google.errorprone:error_prone_annotations:2.5.1
|
||||
com.google.escapevelocity:escapevelocity:0.9.1
|
||||
com.google.flogger:flogger-system-backend:0.5.1
|
||||
com.google.flogger:flogger:0.5.1
|
||||
com.google.flogger:google-extensions:0.5.1
|
||||
|
@ -140,7 +141,7 @@ com.google.oauth-client:google-oauth-client:1.31.4
|
|||
com.google.protobuf:protobuf-java-util:3.15.2
|
||||
com.google.protobuf:protobuf-java:3.15.2
|
||||
com.google.re2j:re2j:1.6
|
||||
com.google.template:soy:2018-03-14
|
||||
com.google.template:soy:2021-02-01
|
||||
com.googlecode.charts4j:charts4j:1.3
|
||||
com.googlecode.json-simple:json-simple:1.1.1
|
||||
com.ibm.icu:icu4j:68.2
|
||||
|
|
|
@ -105,9 +105,10 @@ com.google.cloud:google-cloud-secretmanager:1.4.0
|
|||
com.google.cloud:google-cloud-spanner:2.0.2
|
||||
com.google.code.findbugs:jsr305:3.0.2
|
||||
com.google.code.gson:gson:2.8.6
|
||||
com.google.common.html.types:types:1.0.4
|
||||
com.google.common.html.types:types:1.0.6
|
||||
com.google.dagger:dagger:2.33
|
||||
com.google.errorprone:error_prone_annotations:2.5.1
|
||||
com.google.escapevelocity:escapevelocity:0.9.1
|
||||
com.google.flogger:flogger-system-backend:0.5.1
|
||||
com.google.flogger:flogger:0.5.1
|
||||
com.google.flogger:google-extensions:0.5.1
|
||||
|
@ -135,7 +136,7 @@ com.google.oauth-client:google-oauth-client:1.31.4
|
|||
com.google.protobuf:protobuf-java-util:3.15.2
|
||||
com.google.protobuf:protobuf-java:3.15.2
|
||||
com.google.re2j:re2j:1.6
|
||||
com.google.template:soy:2018-03-14
|
||||
com.google.template:soy:2021-02-01
|
||||
com.googlecode.charts4j:charts4j:1.3
|
||||
com.googlecode.json-simple:json-simple:1.1.1
|
||||
com.ibm.icu:icu4j:68.2
|
||||
|
|
|
@ -104,9 +104,10 @@ com.google.cloud:google-cloud-secretmanager:1.4.0
|
|||
com.google.cloud:google-cloud-spanner:2.0.2
|
||||
com.google.code.findbugs:jsr305:3.0.2
|
||||
com.google.code.gson:gson:2.8.6
|
||||
com.google.common.html.types:types:1.0.4
|
||||
com.google.common.html.types:types:1.0.6
|
||||
com.google.dagger:dagger:2.33
|
||||
com.google.errorprone:error_prone_annotations:2.5.1
|
||||
com.google.escapevelocity:escapevelocity:0.9.1
|
||||
com.google.flogger:flogger:0.5.1
|
||||
com.google.flogger:google-extensions:0.5.1
|
||||
com.google.guava:failureaccess:1.0.1
|
||||
|
@ -133,7 +134,7 @@ com.google.oauth-client:google-oauth-client:1.31.4
|
|||
com.google.protobuf:protobuf-java-util:3.14.0
|
||||
com.google.protobuf:protobuf-java:3.15.2
|
||||
com.google.re2j:re2j:1.6
|
||||
com.google.template:soy:2018-03-14
|
||||
com.google.template:soy:2021-02-01
|
||||
com.googlecode.charts4j:charts4j:1.3
|
||||
com.googlecode.json-simple:json-simple:1.1.1
|
||||
com.ibm.icu:icu4j:68.2
|
||||
|
|
|
@ -109,9 +109,10 @@ com.google.cloud:google-cloud-secretmanager:1.4.0
|
|||
com.google.cloud:google-cloud-spanner:2.0.2
|
||||
com.google.code.findbugs:jsr305:3.0.2
|
||||
com.google.code.gson:gson:2.8.6
|
||||
com.google.common.html.types:types:1.0.4
|
||||
com.google.common.html.types:types:1.0.6
|
||||
com.google.dagger:dagger:2.33
|
||||
com.google.errorprone:error_prone_annotations:2.5.1
|
||||
com.google.escapevelocity:escapevelocity:0.9.1
|
||||
com.google.flogger:flogger-system-backend:0.5.1
|
||||
com.google.flogger:flogger:0.5.1
|
||||
com.google.flogger:google-extensions:0.5.1
|
||||
|
@ -139,7 +140,7 @@ com.google.oauth-client:google-oauth-client:1.31.4
|
|||
com.google.protobuf:protobuf-java-util:3.15.2
|
||||
com.google.protobuf:protobuf-java:3.15.2
|
||||
com.google.re2j:re2j:1.6
|
||||
com.google.template:soy:2018-03-14
|
||||
com.google.template:soy:2021-02-01
|
||||
com.googlecode.charts4j:charts4j:1.3
|
||||
com.googlecode.json-simple:json-simple:1.1.1
|
||||
com.ibm.icu:icu4j:68.2
|
||||
|
|
|
@ -109,9 +109,10 @@ com.google.cloud:google-cloud-secretmanager:1.4.0
|
|||
com.google.cloud:google-cloud-spanner:2.0.2
|
||||
com.google.code.findbugs:jsr305:3.0.2
|
||||
com.google.code.gson:gson:2.8.6
|
||||
com.google.common.html.types:types:1.0.4
|
||||
com.google.common.html.types:types:1.0.6
|
||||
com.google.dagger:dagger:2.33
|
||||
com.google.errorprone:error_prone_annotations:2.5.1
|
||||
com.google.escapevelocity:escapevelocity:0.9.1
|
||||
com.google.flogger:flogger-system-backend:0.5.1
|
||||
com.google.flogger:flogger:0.5.1
|
||||
com.google.flogger:google-extensions:0.5.1
|
||||
|
@ -139,7 +140,7 @@ com.google.oauth-client:google-oauth-client:1.31.4
|
|||
com.google.protobuf:protobuf-java-util:3.15.2
|
||||
com.google.protobuf:protobuf-java:3.15.2
|
||||
com.google.re2j:re2j:1.6
|
||||
com.google.template:soy:2018-03-14
|
||||
com.google.template:soy:2021-02-01
|
||||
com.googlecode.charts4j:charts4j:1.3
|
||||
com.googlecode.json-simple:json-simple:1.1.1
|
||||
com.ibm.icu:icu4j:68.2
|
||||
|
|
|
@ -109,9 +109,10 @@ com.google.cloud:google-cloud-secretmanager:1.4.0
|
|||
com.google.cloud:google-cloud-spanner:2.0.2
|
||||
com.google.code.findbugs:jsr305:3.0.2
|
||||
com.google.code.gson:gson:2.8.6
|
||||
com.google.common.html.types:types:1.0.4
|
||||
com.google.common.html.types:types:1.0.6
|
||||
com.google.dagger:dagger:2.33
|
||||
com.google.errorprone:error_prone_annotations:2.5.1
|
||||
com.google.escapevelocity:escapevelocity:0.9.1
|
||||
com.google.flogger:flogger-system-backend:0.5.1
|
||||
com.google.flogger:flogger:0.5.1
|
||||
com.google.flogger:google-extensions:0.5.1
|
||||
|
@ -139,7 +140,7 @@ com.google.oauth-client:google-oauth-client:1.31.4
|
|||
com.google.protobuf:protobuf-java-util:3.15.2
|
||||
com.google.protobuf:protobuf-java:3.15.2
|
||||
com.google.re2j:re2j:1.6
|
||||
com.google.template:soy:2018-03-14
|
||||
com.google.template:soy:2021-02-01
|
||||
com.googlecode.charts4j:charts4j:1.3
|
||||
com.googlecode.json-simple:json-simple:1.1.1
|
||||
com.ibm.icu:icu4j:68.2
|
||||
|
|
|
@ -110,9 +110,10 @@ com.google.cloud:google-cloud-secretmanager:1.4.0
|
|||
com.google.cloud:google-cloud-spanner:2.0.2
|
||||
com.google.code.findbugs:jsr305:3.0.2
|
||||
com.google.code.gson:gson:2.8.6
|
||||
com.google.common.html.types:types:1.0.4
|
||||
com.google.common.html.types:types:1.0.6
|
||||
com.google.dagger:dagger:2.33
|
||||
com.google.errorprone:error_prone_annotations:2.5.1
|
||||
com.google.escapevelocity:escapevelocity:0.9.1
|
||||
com.google.flogger:flogger-system-backend:0.5.1
|
||||
com.google.flogger:flogger:0.5.1
|
||||
com.google.flogger:google-extensions:0.5.1
|
||||
|
@ -140,7 +141,7 @@ com.google.oauth-client:google-oauth-client:1.31.4
|
|||
com.google.protobuf:protobuf-java-util:3.15.2
|
||||
com.google.protobuf:protobuf-java:3.15.2
|
||||
com.google.re2j:re2j:1.6
|
||||
com.google.template:soy:2018-03-14
|
||||
com.google.template:soy:2021-02-01
|
||||
com.googlecode.charts4j:charts4j:1.3
|
||||
com.googlecode.json-simple:json-simple:1.1.1
|
||||
com.ibm.icu:icu4j:68.2
|
||||
|
|
|
@ -5,25 +5,25 @@ aopalliance:aopalliance:1.0
|
|||
args4j:args4j:2.0.23
|
||||
com.google.code.findbugs:jsr305:3.0.2
|
||||
com.google.code.gson:gson:2.7
|
||||
com.google.common.html.types:types:1.0.4
|
||||
com.google.common.html.types:types:1.0.6
|
||||
com.google.errorprone:error_prone_annotations:2.3.4
|
||||
com.google.escapevelocity:escapevelocity:0.9.1
|
||||
com.google.guava:failureaccess:1.0.1
|
||||
com.google.guava:guava:30.1-jre
|
||||
com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava
|
||||
com.google.gwt:gwt-user:2.8.0-beta1
|
||||
com.google.inject.extensions:guice-multibindings:4.1.0
|
||||
com.google.inject:guice:5.0.1
|
||||
com.google.j2objc:j2objc-annotations:1.3
|
||||
com.google.jsinterop:jsinterop-annotations:1.0.1
|
||||
com.google.protobuf:protobuf-java:3.13.0
|
||||
com.google.template:soy:2018-03-14
|
||||
com.google.template:soy:2021-02-01
|
||||
com.ibm.icu:icu4j:57.1
|
||||
javax.annotation:jsr250-api:1.0
|
||||
javax.inject:javax.inject:1
|
||||
javax.validation:validation-api:1.0.0.GA
|
||||
org.checkerframework:checker-qual:3.5.0
|
||||
org.json:json:20160212
|
||||
org.ow2.asm:asm-analysis:6.0
|
||||
org.ow2.asm:asm-commons:6.0
|
||||
org.ow2.asm:asm-tree:6.0
|
||||
org.ow2.asm:asm-util:6.0
|
||||
org.ow2.asm:asm:6.0
|
||||
org.ow2.asm:asm-analysis:7.0
|
||||
org.ow2.asm:asm-commons:7.0
|
||||
org.ow2.asm:asm-tree:7.0
|
||||
org.ow2.asm:asm-util:7.0
|
||||
org.ow2.asm:asm:7.0
|
||||
|
|
|
@ -106,9 +106,10 @@ com.google.cloud:google-cloud-secretmanager:1.4.0
|
|||
com.google.cloud:google-cloud-spanner:2.0.2
|
||||
com.google.code.findbugs:jsr305:3.0.2
|
||||
com.google.code.gson:gson:2.8.6
|
||||
com.google.common.html.types:types:1.0.4
|
||||
com.google.common.html.types:types:1.0.6
|
||||
com.google.dagger:dagger:2.33
|
||||
com.google.errorprone:error_prone_annotations:2.5.1
|
||||
com.google.escapevelocity:escapevelocity:0.9.1
|
||||
com.google.flogger:flogger-system-backend:0.5.1
|
||||
com.google.flogger:flogger:0.5.1
|
||||
com.google.flogger:google-extensions:0.5.1
|
||||
|
@ -138,7 +139,7 @@ com.google.oauth-client:google-oauth-client:1.31.4
|
|||
com.google.protobuf:protobuf-java-util:3.15.2
|
||||
com.google.protobuf:protobuf-java:3.15.2
|
||||
com.google.re2j:re2j:1.6
|
||||
com.google.template:soy:2018-03-14
|
||||
com.google.template:soy:2021-02-01
|
||||
com.google.truth.extensions:truth-java8-extension:1.1.2
|
||||
com.google.truth:truth:1.1.2
|
||||
com.googlecode.charts4j:charts4j:1.3
|
||||
|
|
|
@ -105,9 +105,10 @@ com.google.cloud:google-cloud-secretmanager:1.4.0
|
|||
com.google.cloud:google-cloud-spanner:2.0.2
|
||||
com.google.code.findbugs:jsr305:3.0.2
|
||||
com.google.code.gson:gson:2.8.6
|
||||
com.google.common.html.types:types:1.0.4
|
||||
com.google.common.html.types:types:1.0.6
|
||||
com.google.dagger:dagger:2.33
|
||||
com.google.errorprone:error_prone_annotations:2.5.1
|
||||
com.google.escapevelocity:escapevelocity:0.9.1
|
||||
com.google.flogger:flogger:0.5.1
|
||||
com.google.flogger:google-extensions:0.5.1
|
||||
com.google.guava:failureaccess:1.0.1
|
||||
|
@ -136,7 +137,7 @@ com.google.oauth-client:google-oauth-client:1.31.4
|
|||
com.google.protobuf:protobuf-java-util:3.14.0
|
||||
com.google.protobuf:protobuf-java:3.15.2
|
||||
com.google.re2j:re2j:1.6
|
||||
com.google.template:soy:2018-03-14
|
||||
com.google.template:soy:2021-02-01
|
||||
com.google.truth.extensions:truth-java8-extension:1.1.2
|
||||
com.google.truth:truth:1.1.2
|
||||
com.googlecode.charts4j:charts4j:1.3
|
||||
|
|
|
@ -111,9 +111,10 @@ com.google.cloud:google-cloud-secretmanager:1.4.0
|
|||
com.google.cloud:google-cloud-spanner:2.0.2
|
||||
com.google.code.findbugs:jsr305:3.0.2
|
||||
com.google.code.gson:gson:2.8.6
|
||||
com.google.common.html.types:types:1.0.4
|
||||
com.google.common.html.types:types:1.0.6
|
||||
com.google.dagger:dagger:2.33
|
||||
com.google.errorprone:error_prone_annotations:2.5.1
|
||||
com.google.escapevelocity:escapevelocity:0.9.1
|
||||
com.google.flogger:flogger-system-backend:0.5.1
|
||||
com.google.flogger:flogger:0.5.1
|
||||
com.google.flogger:google-extensions:0.5.1
|
||||
|
@ -143,7 +144,7 @@ com.google.oauth-client:google-oauth-client:1.31.4
|
|||
com.google.protobuf:protobuf-java-util:3.15.2
|
||||
com.google.protobuf:protobuf-java:3.15.2
|
||||
com.google.re2j:re2j:1.6
|
||||
com.google.template:soy:2018-03-14
|
||||
com.google.template:soy:2021-02-01
|
||||
com.google.truth.extensions:truth-java8-extension:1.1.2
|
||||
com.google.truth:truth:1.1.2
|
||||
com.googlecode.charts4j:charts4j:1.3
|
||||
|
|
|
@ -111,9 +111,10 @@ com.google.cloud:google-cloud-secretmanager:1.4.0
|
|||
com.google.cloud:google-cloud-spanner:2.0.2
|
||||
com.google.code.findbugs:jsr305:3.0.2
|
||||
com.google.code.gson:gson:2.8.6
|
||||
com.google.common.html.types:types:1.0.4
|
||||
com.google.common.html.types:types:1.0.6
|
||||
com.google.dagger:dagger:2.33
|
||||
com.google.errorprone:error_prone_annotations:2.5.1
|
||||
com.google.escapevelocity:escapevelocity:0.9.1
|
||||
com.google.flogger:flogger-system-backend:0.5.1
|
||||
com.google.flogger:flogger:0.5.1
|
||||
com.google.flogger:google-extensions:0.5.1
|
||||
|
@ -143,7 +144,7 @@ com.google.oauth-client:google-oauth-client:1.31.4
|
|||
com.google.protobuf:protobuf-java-util:3.15.2
|
||||
com.google.protobuf:protobuf-java:3.15.2
|
||||
com.google.re2j:re2j:1.6
|
||||
com.google.template:soy:2018-03-14
|
||||
com.google.template:soy:2021-02-01
|
||||
com.google.truth.extensions:truth-java8-extension:1.1.2
|
||||
com.google.truth:truth:1.1.2
|
||||
com.googlecode.charts4j:charts4j:1.3
|
||||
|
|
|
@ -1,75 +0,0 @@
|
|||
// Copyright 2019 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.
|
||||
|
||||
process.env.CHROME_BIN = require('puppeteer').executablePath()
|
||||
|
||||
module.exports = function(config) {
|
||||
config.set({
|
||||
basePath: '..',
|
||||
browsers: ['ChromeHeadlessNoSandbox'],
|
||||
customLaunchers: {
|
||||
ChromeHeadlessNoSandbox: {
|
||||
base: 'ChromeHeadless',
|
||||
flags: ['--no-sandbox']
|
||||
}
|
||||
},
|
||||
frameworks: ['jasmine', 'closure'],
|
||||
singleRun: true,
|
||||
autoWatch: false,
|
||||
files: [
|
||||
'node_modules/google-closure-library/closure/goog/base.js',
|
||||
'core/src/test/javascript/**/*_test.js',
|
||||
{
|
||||
pattern: 'core/src/test/javascript/**/!(*_test).js',
|
||||
included: false
|
||||
},
|
||||
{
|
||||
pattern: 'core/src/main/javascript/**/*.js',
|
||||
included: false
|
||||
},
|
||||
{
|
||||
pattern: 'core/build/generated/sources/custom/java/main/**/*.soy.js',
|
||||
included: false
|
||||
},
|
||||
{
|
||||
pattern: 'node_modules/google-closure-library/closure/goog/deps.js',
|
||||
included: false,
|
||||
served: false
|
||||
},
|
||||
{
|
||||
pattern: 'node_modules/google-closure-library/closure/goog/**/*.js',
|
||||
included: false
|
||||
},
|
||||
{
|
||||
pattern: 'core/build/resources/main/google/registry/ui/assets/images/*.png',
|
||||
included: false
|
||||
},
|
||||
{
|
||||
pattern: 'core/build/resources/main/google/registry/ui/assets/images/icons/svg/*.svg',
|
||||
included: false
|
||||
}
|
||||
],
|
||||
preprocessors: {
|
||||
'node_modules/google-closure-library/closure/goog/deps.js': ['closure', 'closure-deps'],
|
||||
'node_modules/google-closure-library/closure/goog/base.js': ['closure'],
|
||||
'node_modules/google-closure-library/closure/**/*.js': ['closure'],
|
||||
'core/src/*/javascript/**/*.js': ['closure'],
|
||||
'core/build/generated/sources/custom/java/main/**/*.soy.js': ['closure'],
|
||||
},
|
||||
proxies: {
|
||||
"/assets/": "/base/core/build/resources/main/google/registry/ui/assets/"
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
@ -203,7 +203,7 @@ public final class RegistryConfig {
|
|||
* Configuration for analytics services installed in the web console.
|
||||
*
|
||||
* @see google.registry.ui.server.registrar.ConsoleUiAction
|
||||
* @see google.registry.ui.soy.AnalyticsSoyInfo
|
||||
* @see google.registry.ui.soy.registrar.AnalyticsSoyInfo
|
||||
*/
|
||||
@Provides
|
||||
@Config("analyticsConfig")
|
||||
|
|
|
@ -61,9 +61,10 @@ public final class ConsoleOteSetupAction extends HtmlAction {
|
|||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
private static final Supplier<SoyTofu> TOFU_SUPPLIER =
|
||||
SoyTemplateUtils.createTofuSupplier(
|
||||
google.registry.ui.soy.ConsoleSoyInfo.getInstance(),
|
||||
google.registry.ui.soy.FormsSoyInfo.getInstance(),
|
||||
google.registry.ui.soy.AnalyticsSoyInfo.getInstance(),
|
||||
google.registry.ui.soy.registrar.AnalyticsSoyInfo.getInstance(),
|
||||
google.registry.ui.soy.registrar.ConsoleSoyInfo.getInstance(),
|
||||
google.registry.ui.soy.registrar.ConsoleUtilsSoyInfo.getInstance(),
|
||||
google.registry.ui.soy.registrar.FormsSoyInfo.getInstance(),
|
||||
google.registry.ui.soy.registrar.OteSetupConsoleSoyInfo.getInstance());
|
||||
|
||||
@Inject AuthenticatedRegistrarAccessor registrarAccessor;
|
||||
|
|
|
@ -74,9 +74,10 @@ public final class ConsoleRegistrarCreatorAction extends HtmlAction {
|
|||
|
||||
private static final Supplier<SoyTofu> TOFU_SUPPLIER =
|
||||
SoyTemplateUtils.createTofuSupplier(
|
||||
google.registry.ui.soy.ConsoleSoyInfo.getInstance(),
|
||||
google.registry.ui.soy.FormsSoyInfo.getInstance(),
|
||||
google.registry.ui.soy.AnalyticsSoyInfo.getInstance(),
|
||||
google.registry.ui.soy.registrar.AnalyticsSoyInfo.getInstance(),
|
||||
google.registry.ui.soy.registrar.ConsoleSoyInfo.getInstance(),
|
||||
google.registry.ui.soy.registrar.ConsoleUtilsSoyInfo.getInstance(),
|
||||
google.registry.ui.soy.registrar.FormsSoyInfo.getInstance(),
|
||||
google.registry.ui.soy.registrar.RegistrarCreateConsoleSoyInfo.getInstance());
|
||||
|
||||
@Inject AuthenticatedRegistrarAccessor registrarAccessor;
|
||||
|
|
|
@ -50,9 +50,9 @@ public final class ConsoleUiAction extends HtmlAction {
|
|||
|
||||
private static final Supplier<SoyTofu> TOFU_SUPPLIER =
|
||||
SoyTemplateUtils.createTofuSupplier(
|
||||
google.registry.ui.soy.ConsoleSoyInfo.getInstance(),
|
||||
google.registry.ui.soy.registrar.AnalyticsSoyInfo.getInstance(),
|
||||
google.registry.ui.soy.registrar.ConsoleSoyInfo.getInstance(),
|
||||
google.registry.ui.soy.AnalyticsSoyInfo.getInstance());
|
||||
google.registry.ui.soy.registrar.ConsoleUtilsSoyInfo.getInstance());
|
||||
|
||||
@Inject RegistrarConsoleMetrics registrarConsoleMetrics;
|
||||
@Inject AuthenticatedRegistrarAccessor registrarAccessor;
|
||||
|
|
|
@ -43,8 +43,9 @@ public final class RegistryLockVerifyAction extends HtmlAction {
|
|||
|
||||
private static final Supplier<SoyTofu> TOFU_SUPPLIER =
|
||||
SoyTemplateUtils.createTofuSupplier(
|
||||
google.registry.ui.soy.ConsoleSoyInfo.getInstance(),
|
||||
google.registry.ui.soy.AnalyticsSoyInfo.getInstance(),
|
||||
google.registry.ui.soy.registrar.AnalyticsSoyInfo.getInstance(),
|
||||
google.registry.ui.soy.registrar.ConsoleSoyInfo.getInstance(),
|
||||
google.registry.ui.soy.registrar.ConsoleUtilsSoyInfo.getInstance(),
|
||||
google.registry.ui.soy.registrar.RegistryLockVerificationSoyInfo.getInstance());
|
||||
|
||||
private final DomainLockUtils domainLockUtils;
|
||||
|
|
94
core/src/main/javascript/checks.js
Normal file
94
core/src/main/javascript/checks.js
Normal file
|
@ -0,0 +1,94 @@
|
|||
/**
|
||||
* @fileoverview Provides Soy runtime checks for safe types.
|
||||
*
|
||||
* NOTE (gbrodman) this file is taken from the open source version located at
|
||||
* https://github.com/google/closure-templates/blob/6c8cf1c7916abd0ab5d7e9d259985873f8af4fd2/javascript/checks.js
|
||||
*/
|
||||
|
||||
goog.provide('soy.checks');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('goog.soy.data.SanitizedContentKind');
|
||||
goog.require('goog.soy.data.SanitizedCss');
|
||||
goog.require('goog.soy.data.SanitizedHtml');
|
||||
goog.require('goog.soy.data.SanitizedHtmlAttribute');
|
||||
goog.require('goog.soy.data.SanitizedJs');
|
||||
goog.require('goog.soy.data.SanitizedTrustedResourceUri');
|
||||
goog.require('goog.soy.data.SanitizedUri');
|
||||
|
||||
/**
|
||||
* Checks whether a given value is of a given content kind.
|
||||
*
|
||||
* @param {?} value The value to be examined.
|
||||
* @param {!goog.soy.data.SanitizedContentKind} contentKind The desired content
|
||||
* kind.
|
||||
* @param {!Object} constructor
|
||||
* @return {boolean} Whether the given value is of the given kind.
|
||||
* @private
|
||||
*/
|
||||
soy.checks.isContentKind_ = function(value, contentKind, constructor) {
|
||||
var ret = value != null && value.contentKind === contentKind;
|
||||
if (ret) {
|
||||
goog.asserts.assert(value.constructor === constructor);
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {?} value
|
||||
* @return {boolean}
|
||||
*/
|
||||
soy.checks.isHtml = function(value) {
|
||||
return soy.checks.isContentKind_(
|
||||
value, goog.soy.data.SanitizedContentKind.HTML,
|
||||
goog.soy.data.SanitizedHtml);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {?} value
|
||||
* @return {boolean}
|
||||
*/
|
||||
soy.checks.isCss = function(value) {
|
||||
return soy.checks.isContentKind_(
|
||||
value, goog.soy.data.SanitizedContentKind.CSS,
|
||||
goog.soy.data.SanitizedCss);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {?} value
|
||||
* @return {boolean}
|
||||
*/
|
||||
soy.checks.isAttribute = function(value) {
|
||||
return soy.checks.isContentKind_(
|
||||
value, goog.soy.data.SanitizedContentKind.ATTRIBUTES,
|
||||
goog.soy.data.SanitizedHtmlAttribute);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {?} value
|
||||
* @return {boolean}
|
||||
*/
|
||||
soy.checks.isJS = function(value) {
|
||||
return soy.checks.isContentKind_(
|
||||
value, goog.soy.data.SanitizedContentKind.JS, goog.soy.data.SanitizedJs);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {?} value
|
||||
* @return {boolean}
|
||||
*/
|
||||
soy.checks.isTrustedResourceURI = function(value) {
|
||||
return soy.checks.isContentKind_(
|
||||
value, goog.soy.data.SanitizedContentKind.TRUSTED_RESOURCE_URI,
|
||||
goog.soy.data.SanitizedTrustedResourceUri);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {?} value
|
||||
* @return {boolean}
|
||||
*/
|
||||
soy.checks.isURI = function(value) {
|
||||
return soy.checks.isContentKind_(
|
||||
value, goog.soy.data.SanitizedContentKind.URI,
|
||||
goog.soy.data.SanitizedUri);
|
||||
};
|
|
@ -33,7 +33,7 @@ goog.forwardDeclare('goog.events.KeyEvent');
|
|||
*/
|
||||
registry.forms.focus = function(field) {
|
||||
field = goog.dom.getElement(field);
|
||||
if (!goog.isNull(field) && goog.dom.isFocusable(field)) {
|
||||
if (field !== null && goog.dom.isFocusable(field)) {
|
||||
goog.dom.forms.focusAndSelect(field);
|
||||
}
|
||||
};
|
||||
|
@ -45,7 +45,7 @@ registry.forms.focus = function(field) {
|
|||
* @param {string=} opt_field Erroneous field name.
|
||||
*/
|
||||
registry.forms.displayError = function(message, opt_field) {
|
||||
if (!goog.isDef(opt_field)) {
|
||||
if (opt_field === undefined) {
|
||||
registry.util.butter(message);
|
||||
return;
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ registry.forms.displayError = function(message, opt_field) {
|
|||
goog.dom.getElement(opt_field + '[0]');
|
||||
// XXX: Transitioning to use of form.eltId instead of DOM id. If DOM id
|
||||
// lookup fails, then search forms for the named field.
|
||||
if (goog.isDefAndNotNull(opt_field) && goog.isNull(input)) {
|
||||
if (opt_field != null && input === null) {
|
||||
for (var fNdx in document.forms) {
|
||||
var form = document.forms[fNdx];
|
||||
if (form[opt_field]) {
|
||||
|
@ -62,7 +62,7 @@ registry.forms.displayError = function(message, opt_field) {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (!goog.isNull(input)) {
|
||||
if (input !== null) {
|
||||
goog.dom.classlist.add(input, goog.getCssName('kd-formerror'));
|
||||
goog.dom.insertSiblingAfter(
|
||||
goog.dom.createDom(goog.dom.TagName.DIV,
|
||||
|
|
|
@ -162,7 +162,7 @@ registry.registrar.Console.prototype.changeNavStyle = function() {
|
|||
var regNavlist = goog.dom.getRequiredElement('reg-navlist');
|
||||
var path = hashToken.substring(0, slashNdx);
|
||||
var active = regNavlist.querySelector('a[href="#' + path + '"]');
|
||||
if (goog.isNull(active)) {
|
||||
if (active === null) {
|
||||
registry.util.log('Unknown path or path form in changeNavStyle.');
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ goog.inherits(registry.registrar.ContactSettings, registry.ResourceComponent);
|
|||
registry.registrar.ContactSettings.prototype.setupAppbar = function() {
|
||||
registry.registrar.ContactSettings.base(this, 'setupAppbar');
|
||||
// Setup delete only on existing items, not on creates.
|
||||
if (goog.isDefAndNotNull(this.model)) {
|
||||
if (this.model != null) {
|
||||
var deleteBtn = goog.dom.createDom(
|
||||
goog.dom.TagName.BUTTON, {
|
||||
type: 'button',
|
||||
|
@ -159,7 +159,7 @@ registry.registrar.ContactSettings.prototype.sendDelete = function() {
|
|||
ndxToDel = i;
|
||||
}
|
||||
}
|
||||
if (goog.isNull(ndxToDel)) {
|
||||
if (ndxToDel === null) {
|
||||
throw new Error('Email to delete does not match model.');
|
||||
}
|
||||
var modelCopy = /** @type {!Object}
|
||||
|
|
|
@ -25,8 +25,7 @@ goog.require('goog.soy');
|
|||
*/
|
||||
registry.util.log = function(var_args) {
|
||||
if (goog.DEBUG) {
|
||||
if (goog.isDef(goog.global.console) &&
|
||||
goog.isDef(goog.global.console['log'])) {
|
||||
if (goog.global.console !== undefined && goog.global.console['log'] !== undefined) {
|
||||
goog.global.console.log.apply(goog.global.console, arguments);
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -19,6 +19,7 @@ import com.beust.jcommander.Parameter;
|
|||
import com.beust.jcommander.Parameters;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.net.HostAndPort;
|
||||
import google.registry.persistence.transaction.JpaTestRules;
|
||||
import google.registry.testing.AppEngineExtension;
|
||||
import google.registry.testing.UserInfo;
|
||||
import google.registry.tools.params.HostAndPortParameter;
|
||||
|
@ -146,6 +147,8 @@ public final class RegistryTestServerMain {
|
|||
: UserInfo.create(loginEmail, loginUserId))
|
||||
.build();
|
||||
appEngine.setUp();
|
||||
AppEngineExtension.loadInitialData();
|
||||
new JpaTestRules.Builder().buildIntegrationTestRule().beforeEach(null);
|
||||
System.out.printf("%sLoading Datastore fixtures...%s\n", BLUE, RESET);
|
||||
for (Fixture fixture : fixtures) {
|
||||
fixture.load();
|
||||
|
|
|
@ -652,7 +652,7 @@ public final class AppEngineExtension implements BeforeEachCallback, AfterEachCa
|
|||
}
|
||||
|
||||
/** Create some fake registrars. */
|
||||
private static void loadInitialData() {
|
||||
public static void loadInitialData() {
|
||||
persistSimpleResources(
|
||||
ImmutableList.of(
|
||||
makeRegistrar1(),
|
||||
|
|
|
@ -1,40 +0,0 @@
|
|||
// Copyright 2017 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.
|
||||
|
||||
goog.setTestOnly();
|
||||
|
||||
goog.require('goog.dispose');
|
||||
goog.require('goog.testing.MockControl');
|
||||
goog.require('registry.Component');
|
||||
goog.require('registry.Console');
|
||||
|
||||
describe("component test", function() {
|
||||
let mocks;
|
||||
|
||||
beforeEach(function() {
|
||||
mocks = new goog.testing.MockControl();
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
mocks.$tearDown();
|
||||
});
|
||||
|
||||
it("testCreationAndDisposal_dontTouchConsoleObject", function() {
|
||||
var console = mocks.createStrictMock(registry.Console);
|
||||
mocks.$replayAll();
|
||||
var component = new registry.Component(console);
|
||||
goog.dispose(component);
|
||||
mocks.$verifyAll();
|
||||
});
|
||||
});
|
|
@ -1,120 +0,0 @@
|
|||
// Copyright 2017 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.
|
||||
|
||||
goog.setTestOnly();
|
||||
|
||||
goog.require('goog.dom');
|
||||
goog.require('goog.dom.classlist');
|
||||
goog.require('goog.json');
|
||||
goog.require('goog.testing.MockControl');
|
||||
goog.require('goog.testing.PropertyReplacer');
|
||||
goog.require('goog.testing.net.XhrIo');
|
||||
goog.require('registry.registrar.ConsoleTestUtil');
|
||||
goog.require('registry.testing');
|
||||
goog.require('registry.util');
|
||||
|
||||
describe("console test", function() {
|
||||
const $ = goog.dom.getRequiredElement;
|
||||
const stubs = new goog.testing.PropertyReplacer();
|
||||
|
||||
const test = {
|
||||
testXsrfToken: 'testToken',
|
||||
testClientId: 'daddy',
|
||||
mockControl: new goog.testing.MockControl()
|
||||
};
|
||||
|
||||
beforeEach(function() {
|
||||
registry.testing.addToDocument('<div id="test"/>');
|
||||
registry.testing.addToDocument('<div class="kd-butterbar"/>');
|
||||
stubs.setPath('goog.net.XhrIo', goog.testing.net.XhrIo);
|
||||
registry.registrar.ConsoleTestUtil.renderConsoleMain($('test'), {
|
||||
xsrfToken: test.testXsrfToken,
|
||||
clientId: test.testClientId,
|
||||
});
|
||||
registry.registrar.ConsoleTestUtil.setup(test);
|
||||
const regNavlist = $('reg-navlist');
|
||||
const active = regNavlist.querySelector('a[href="#contact-us"]');
|
||||
expect(active).not.toBeNull();
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
goog.testing.net.XhrIo.cleanup();
|
||||
stubs.reset();
|
||||
test.mockControl.$tearDown();
|
||||
});
|
||||
|
||||
it("testButter", function() {
|
||||
registry.registrar.ConsoleTestUtil.visit(test, {
|
||||
productName: 'Foo Registry'
|
||||
});
|
||||
registry.util.butter('butter msg');
|
||||
const butter = goog.dom.getElementByClass(goog.getCssName('kd-butterbar'));
|
||||
expect(butter.innerHTML.match(/.*butter msg.*/)).not.toBeNull();
|
||||
expect(goog.dom.classlist.contains(butter, goog.getCssName('shown'))).toBe(true);
|
||||
});
|
||||
|
||||
/** Authed user with no path op specified should nav to welcome page. */
|
||||
it("testShowLoginOrDash", function() {
|
||||
registry.registrar.ConsoleTestUtil.visit(test, {
|
||||
productName: 'Foo Registry'
|
||||
});
|
||||
expect(goog.dom.getElement('domain-registrar-dashboard')).not.toBeNull();
|
||||
});
|
||||
|
||||
it("testNavToResources", function() {
|
||||
registry.registrar.ConsoleTestUtil.visit(test, {
|
||||
path: 'resources',
|
||||
xsrfToken: test.testXsrfToken,
|
||||
technicalDocsUrl: 'http://example.com/techdocs',
|
||||
readonly: true,
|
||||
});
|
||||
const xhr = goog.testing.net.XhrIo.getSendInstances().pop();
|
||||
expect(xhr.isActive()).toBe(true);
|
||||
expect(xhr.getLastUri()).toEqual('/registrar-settings');
|
||||
expect(xhr.getLastRequestHeaders()['X-CSRF-Token']).toEqual(test.testXsrfToken);
|
||||
xhr.simulateResponse(200, goog.json.serialize({
|
||||
status: 'SUCCESS',
|
||||
message: 'OK',
|
||||
results: [{
|
||||
driveFolderId: 'blahblah'
|
||||
}]
|
||||
}));
|
||||
expect($('reg-resources-driveLink').getAttribute('href')).toContain('blahblah');
|
||||
});
|
||||
|
||||
it("testNavToContactUs", function() {
|
||||
registry.registrar.ConsoleTestUtil.visit(test, {
|
||||
path: 'contact-us',
|
||||
xsrfToken: test.testXsrfToken,
|
||||
productName: 'Domain Registry',
|
||||
integrationEmail: 'integration@example.com',
|
||||
supportEmail: 'support@example.com',
|
||||
announcementsEmail: 'announcement@example.com',
|
||||
supportPhoneNumber: '+1 (888) 555 0123'
|
||||
});
|
||||
const xhr = goog.testing.net.XhrIo.getSendInstances().pop();
|
||||
expect(xhr.isActive()).toBe(true);
|
||||
expect(xhr.getLastUri()).toEqual('/registrar-settings');
|
||||
expect(xhr.getLastRequestHeaders()['X-CSRF-Token']).toEqual(test.testXsrfToken);
|
||||
const passcode = '5-5-5-5-5';
|
||||
xhr.simulateResponse(200, goog.json.serialize({
|
||||
status: 'SUCCESS',
|
||||
message: 'OK',
|
||||
results: [{
|
||||
phonePasscode: passcode
|
||||
}]
|
||||
}));
|
||||
expect(goog.dom.getTextContent($('domain-registrar-phone-passcode'))).toEqual(passcode);
|
||||
});
|
||||
});
|
|
@ -1,109 +0,0 @@
|
|||
// Copyright 2017 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.
|
||||
|
||||
goog.provide('registry.registrar.ConsoleTestUtil');
|
||||
goog.setTestOnly('registry.registrar.ConsoleTestUtil');
|
||||
|
||||
goog.require('goog.History');
|
||||
goog.require('goog.soy');
|
||||
goog.require('registry.registrar.Console');
|
||||
goog.require('registry.soy.registrar.console');
|
||||
|
||||
|
||||
/**
|
||||
* Utility method that attaches mocks to a `TestCase`. This was
|
||||
* originally in the ctor for ConsoleTest and should simply be
|
||||
* inherited but jstd_test breaks inheritance in test cases.
|
||||
* @param {!Object} test the test case to configure.
|
||||
*/
|
||||
registry.registrar.ConsoleTestUtil.setup = function(test) {
|
||||
test.historyMock = test.mockControl.createLooseMock(goog.History, true);
|
||||
test.mockControl.createConstructorMock(goog, 'History')()
|
||||
.$returns(test.historyMock);
|
||||
};
|
||||
|
||||
/**
|
||||
* Utility method that renders the registry.soy.registrar.console.main element.
|
||||
*
|
||||
* This element has a lot of parameters. We use defaults everywhere, but you can
|
||||
* override them with 'opt_args'.
|
||||
*
|
||||
* @param {!Element} element the element whose content we are rendering into.
|
||||
* @param {?Object=} opt_args override for the default values of the soy params.
|
||||
*/
|
||||
registry.registrar.ConsoleTestUtil.renderConsoleMain = function(
|
||||
element, opt_args) {
|
||||
const args = opt_args || {};
|
||||
goog.soy.renderElement(element, registry.soy.registrar.console.main, {
|
||||
xsrfToken: args.xsrfToken || 'ignore',
|
||||
username: args.username || 'jart',
|
||||
logoutUrl: args.logoutUrl || 'https://logout.url.com',
|
||||
isAdmin: !!args.isAdmin,
|
||||
isOwner: !!args.isOwner,
|
||||
clientId: args.clientId || 'ignore',
|
||||
allClientIds: args.allClientIds || ['clientId1', 'clientId2'],
|
||||
logoFilename: args.logoFilename || 'logo.png',
|
||||
productName: args.productName || 'Nomulus',
|
||||
integrationEmail: args.integrationEmail || 'integration@example.com',
|
||||
supportEmail: args.supportEmail || 'support@example.com',
|
||||
announcementsEmail: args.announcementsEmail || 'announcement@example.com',
|
||||
supportPhoneNumber: args.supportPhoneNumber || '+1 (888) 555 0123',
|
||||
technicalDocsUrl: args.technicalDocsUrl || 'http://example.com/techdocs',
|
||||
environment: args.environment || 'UNITTEST',
|
||||
analyticsConfig: args.analyticsConfig || {googleAnalyticsId: null},
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Simulates visiting a page on the console. Sets path, then calls
|
||||
* `handleHashChange_`.
|
||||
* @param {!Object} test the test case to configure.
|
||||
* @param {?Object=} opt_args may include path.
|
||||
* @param {?Function=} opt_moar extra setup after called just before
|
||||
* `$replayAll`. See memegen/3437690.
|
||||
*/
|
||||
registry.registrar.ConsoleTestUtil.visit = function(
|
||||
test, opt_args, opt_moar) {
|
||||
opt_args = opt_args || {};
|
||||
opt_args.path = opt_args.path || '';
|
||||
opt_args.clientId = opt_args.clientId || 'dummyRegistrarId';
|
||||
opt_args.xsrfToken = opt_args.xsrfToken || 'dummyXsrfToken';
|
||||
opt_args.isAdmin = !!opt_args.isAdmin;
|
||||
opt_args.analyticsConfig =
|
||||
opt_args.analyticsConfig || {googleAnalyticsIds: null};
|
||||
|
||||
// set the default isOwner to be the opposite of isAdmin.
|
||||
// That way, if we don't explicitly state them both we get what we'd expect:
|
||||
// {} -> OWNER (the "regular" case of a visitor to the console)
|
||||
// {isOwner:true} -> OWNER
|
||||
// {isAdmin:true} -> ADMIN (the "regular" case of an admin visitor)
|
||||
// {isOwner:true, isAdmin:true} -> OWNER + ADMIN together
|
||||
if (opt_args.isOwner === undefined) {
|
||||
opt_args.isOwner = !opt_args.isAdmin;
|
||||
}
|
||||
test.historyMock.$reset();
|
||||
test.historyMock.getToken().$returns(opt_args.path).$anyTimes();
|
||||
if (opt_moar) {
|
||||
opt_moar();
|
||||
}
|
||||
test.mockControl.$replayAll();
|
||||
/** @type {!registry.registrar.Console} */
|
||||
test.console = new registry.registrar.Console(opt_args);
|
||||
test.console.setUp();
|
||||
// Should be triggered via the History object in test.console.setUp(), but
|
||||
// since we're using a mock that isn't happening. So we call it manually.
|
||||
test.console.handleHashChange();
|
||||
test.mockControl.$verifyAll();
|
||||
};
|
|
@ -1,365 +0,0 @@
|
|||
// Copyright 2017 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.
|
||||
|
||||
goog.setTestOnly();
|
||||
|
||||
goog.require('goog.array');
|
||||
goog.require('goog.dispose');
|
||||
goog.require('goog.dom');
|
||||
goog.require('goog.testing.MockControl');
|
||||
goog.require('goog.testing.PropertyReplacer');
|
||||
goog.require('goog.testing.net.XhrIo');
|
||||
goog.require('registry.registrar.ConsoleTestUtil');
|
||||
goog.require('registry.testing');
|
||||
goog.require('registry.util');
|
||||
|
||||
describe("contact settings test", function() {
|
||||
const $ = goog.dom.getRequiredElement;
|
||||
const stubs = new goog.testing.PropertyReplacer();
|
||||
let testContact = null;
|
||||
|
||||
const test = {
|
||||
testXsrfToken: '༼༎෴ ༎༽',
|
||||
testClientId: 'testClientId',
|
||||
mockControl: new goog.testing.MockControl()
|
||||
};
|
||||
|
||||
beforeEach(function() {
|
||||
registry.testing.addToDocument('<div id="test"/>');
|
||||
registry.testing.addToDocument('<div class="kd-butterbar"/>');
|
||||
testContact = createTestContact();
|
||||
registry.registrar.ConsoleTestUtil.renderConsoleMain($('test'), {
|
||||
xsrfToken: test.testXsrfToken,
|
||||
clientId: test.testClientId,
|
||||
});
|
||||
stubs.setPath('goog.net.XhrIo', goog.testing.net.XhrIo);
|
||||
registry.registrar.ConsoleTestUtil.setup(test);
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
goog.dispose(test.console);
|
||||
goog.testing.net.XhrIo.cleanup();
|
||||
stubs.reset();
|
||||
test.mockControl.$tearDown();
|
||||
});
|
||||
|
||||
it("testCollectionView", function() {
|
||||
testContactWithoutType = createTestContact('notype@example.com');
|
||||
testContactWithoutType.types = '';
|
||||
registry.registrar.ConsoleTestUtil.visit(test, {
|
||||
path: 'contact-settings',
|
||||
xsrfToken: test.testXsrfToken,
|
||||
clientId: test.testClientId
|
||||
});
|
||||
registry.testing.assertReqMockRsp(
|
||||
test.testXsrfToken,
|
||||
'/registrar-settings',
|
||||
{op: 'read', id: 'testClientId', args: {}},
|
||||
{
|
||||
status: 'SUCCESS',
|
||||
message: 'OK',
|
||||
results: [{
|
||||
contacts: [testContact, testContactWithoutType]
|
||||
}]
|
||||
}
|
||||
);
|
||||
expect($('admin-contacts').childNodes.length).toEqual(1);
|
||||
expect($('other-contacts').childNodes.length).toEqual(1);
|
||||
// XXX: Needs more field testing.
|
||||
});
|
||||
|
||||
|
||||
it("testItemView", function() {
|
||||
testItemView();
|
||||
expect($('contacts[0].name').value).toEqual(testContact.name);
|
||||
expect($('contacts[0].emailAddress').value).toEqual(testContact.emailAddress);
|
||||
expect($('contacts[0].phoneNumber').value).toEqual(testContact.phoneNumber);
|
||||
expect($('contacts[0].faxNumber').value).toEqual(testContact.faxNumber);
|
||||
// XXX: Types are no longer broken out as individual settings, so relying on
|
||||
// screenshot test.
|
||||
});
|
||||
|
||||
// XXX: Should be hoisted.
|
||||
it("testItemEditButtons", function() {
|
||||
testItemView();
|
||||
registry.testing.assertVisible($('reg-app-btns-edit'));
|
||||
registry.testing.assertHidden($('reg-app-btns-save'));
|
||||
registry.testing.click($('reg-app-btn-edit'));
|
||||
registry.testing.assertHidden($('reg-app-btns-edit'));
|
||||
registry.testing.assertVisible($('reg-app-btns-save'));
|
||||
registry.testing.click($('reg-app-btn-cancel'));
|
||||
registry.testing.assertVisible($('reg-app-btns-edit'));
|
||||
registry.testing.assertHidden($('reg-app-btns-save'));
|
||||
});
|
||||
|
||||
it("testItemEdit", function() {
|
||||
testItemView();
|
||||
registry.testing.click($('reg-app-btn-edit'));
|
||||
$('contacts[0].name').setAttribute('value', 'bob');
|
||||
registry.testing.click($('reg-app-btn-save'));
|
||||
testContact.name = 'bob';
|
||||
registry.testing.assertReqMockRsp(
|
||||
test.testXsrfToken,
|
||||
'/registrar-settings',
|
||||
{
|
||||
op: 'update',
|
||||
id: 'testClientId',
|
||||
args: {
|
||||
contacts: [testContact],
|
||||
readonly: false
|
||||
}
|
||||
},
|
||||
{
|
||||
status: 'SUCCESS',
|
||||
message: 'OK',
|
||||
results: [{
|
||||
contacts: [testContact]
|
||||
}]
|
||||
}
|
||||
);
|
||||
registry.testing.assertObjectEqualsPretty(
|
||||
testContact,
|
||||
simulateJsonForContact(registry.util.parseForm('item').contacts[0]));
|
||||
});
|
||||
|
||||
it("testChangeContactTypes", function() {
|
||||
testItemView();
|
||||
registry.testing.click($('reg-app-btn-edit'));
|
||||
$('contacts[0].type.admin').removeAttribute('checked');
|
||||
$('contacts[0].type.legal').setAttribute('checked', 'checked');
|
||||
$('contacts[0].type.marketing').setAttribute('checked', 'checked');
|
||||
registry.testing.click($('reg-app-btn-save'));
|
||||
testContact.types = 'LEGAL,MARKETING';
|
||||
registry.testing.assertReqMockRsp(
|
||||
test.testXsrfToken,
|
||||
'/registrar-settings',
|
||||
{
|
||||
op: 'update',
|
||||
id: 'testClientId',
|
||||
args: {
|
||||
contacts: [testContact],
|
||||
readonly: false
|
||||
}
|
||||
},
|
||||
{
|
||||
status: 'SUCCESS',
|
||||
message: 'OK',
|
||||
results: [{
|
||||
contacts: [testContact]
|
||||
}]
|
||||
}
|
||||
);
|
||||
registry.testing.assertObjectEqualsPretty(
|
||||
testContact,
|
||||
simulateJsonForContact(registry.util.parseForm('item').contacts[0]));
|
||||
});
|
||||
|
||||
it("testOneOfManyUpdate", function() {
|
||||
registry.registrar.ConsoleTestUtil.visit(test, {
|
||||
path: 'contact-settings/test@example.com',
|
||||
xsrfToken: test.testXsrfToken,
|
||||
clientId: test.testClientId
|
||||
});
|
||||
const testContacts = [
|
||||
createTestContact('new1@asdf.com'),
|
||||
testContact,
|
||||
createTestContact('new2@asdf.com')
|
||||
];
|
||||
registry.testing.assertReqMockRsp(
|
||||
test.testXsrfToken,
|
||||
'/registrar-settings',
|
||||
{op: 'read', id: 'testClientId', args: {}},
|
||||
{
|
||||
status: 'SUCCESS',
|
||||
message: 'OK',
|
||||
results: [{
|
||||
contacts: testContacts
|
||||
}]
|
||||
}
|
||||
);
|
||||
// Edit testContact.
|
||||
registry.testing.click($('reg-app-btn-edit'));
|
||||
$('contacts[1].type.admin').removeAttribute('checked');
|
||||
$('contacts[1].type.legal').setAttribute('checked', 'checked');
|
||||
$('contacts[1].type.marketing').setAttribute('checked', 'checked');
|
||||
registry.testing.click($('reg-app-btn-save'));
|
||||
|
||||
// Should save them all back, with only testContact changed.
|
||||
testContacts[1].types = 'LEGAL,MARKETING';
|
||||
registry.testing.assertReqMockRsp(
|
||||
test.testXsrfToken,
|
||||
'/registrar-settings',
|
||||
{
|
||||
op: 'update',
|
||||
id: 'testClientId',
|
||||
args: {
|
||||
contacts: testContacts,
|
||||
readonly: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
status: 'SUCCESS',
|
||||
message: 'OK',
|
||||
results: [{
|
||||
contacts: testContacts
|
||||
}]
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it("testDomainWhoisAbuseContactOverride", function() {
|
||||
registry.registrar.ConsoleTestUtil.visit(test, {
|
||||
path: 'contact-settings/test@example.com',
|
||||
xsrfToken: test.testXsrfToken,
|
||||
clientId: test.testClientId
|
||||
});
|
||||
const oldDomainWhoisAbuseContact = createTestContact('old@asdf.com');
|
||||
oldDomainWhoisAbuseContact.visibleInDomainWhoisAsAbuse = true;
|
||||
const testContacts = [oldDomainWhoisAbuseContact, testContact];
|
||||
registry.testing.assertReqMockRsp(
|
||||
test.testXsrfToken,
|
||||
'/registrar-settings',
|
||||
{op: 'read', id: 'testClientId', args: {}},
|
||||
{status: 'SUCCESS', message: 'OK', results: [{contacts: testContacts}]});
|
||||
// Edit testContact.
|
||||
registry.testing.click($('reg-app-btn-edit'));
|
||||
$('contacts[1].visibleInDomainWhoisAsAbuse.true')
|
||||
.setAttribute('checked', 'checked');
|
||||
$('contacts[1].visibleInDomainWhoisAsAbuse.false').removeAttribute('checked');
|
||||
registry.testing.click($('reg-app-btn-save'));
|
||||
|
||||
// Should save them all back, and flip the old abuse contact's visibility
|
||||
// boolean.
|
||||
testContact.visibleInDomainWhoisAsAbuse = true;
|
||||
oldDomainWhoisAbuseContact.visibleInDomainWhoisAsAbuse = false;
|
||||
registry.testing.assertReqMockRsp(
|
||||
test.testXsrfToken,
|
||||
'/registrar-settings',
|
||||
{
|
||||
op: 'update',
|
||||
id: 'testClientId',
|
||||
args: {contacts: testContacts, readonly: false},
|
||||
},
|
||||
{status: 'SUCCESS', message: 'OK', results: [{contacts: testContacts}]});
|
||||
});
|
||||
|
||||
it("testDelete", function() {
|
||||
registry.registrar.ConsoleTestUtil.visit(test, {
|
||||
path: 'contact-settings/test@example.com',
|
||||
xsrfToken: test.testXsrfToken,
|
||||
clientId: test.testClientId
|
||||
});
|
||||
const testContacts = [
|
||||
createTestContact('new1@asdf.com'),
|
||||
testContact,
|
||||
createTestContact('new2@asdf.com')
|
||||
];
|
||||
registry.testing.assertReqMockRsp(
|
||||
test.testXsrfToken,
|
||||
'/registrar-settings',
|
||||
{op: 'read', id: 'testClientId', args: {}},
|
||||
{
|
||||
status: 'SUCCESS',
|
||||
message: 'OK',
|
||||
results: [{
|
||||
contacts: testContacts
|
||||
}]
|
||||
}
|
||||
);
|
||||
// Delete testContact.
|
||||
registry.testing.click($('reg-app-btn-edit'));
|
||||
registry.testing.click($('reg-app-btn-delete'));
|
||||
|
||||
// Should save them all back, with testContact gone.
|
||||
goog.array.removeAt(testContacts, 1);
|
||||
registry.testing.assertReqMockRsp(
|
||||
test.testXsrfToken,
|
||||
'/registrar-settings',
|
||||
{
|
||||
op: 'update',
|
||||
id: 'testClientId',
|
||||
args: {contacts: testContacts, readonly: false},
|
||||
},
|
||||
{
|
||||
status: 'SUCCESS',
|
||||
message: 'OK',
|
||||
results: [{
|
||||
contacts: testContacts
|
||||
}]
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
function testItemView() {
|
||||
registry.registrar.ConsoleTestUtil.visit(test, {
|
||||
path: 'contact-settings/test@example.com',
|
||||
xsrfToken: test.testXsrfToken,
|
||||
clientId: test.testClientId
|
||||
});
|
||||
registry.testing.assertReqMockRsp(
|
||||
test.testXsrfToken,
|
||||
'/registrar-settings',
|
||||
{op: 'read', id: 'testClientId', args: {}},
|
||||
{
|
||||
status: 'SUCCESS',
|
||||
message: 'OK',
|
||||
results: [{
|
||||
contacts: [testContact]
|
||||
}]
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string=} opt_email
|
||||
* @return {!Object}
|
||||
*/
|
||||
function createTestContact(opt_email) {
|
||||
const nameMail = opt_email || 'test@example.com';
|
||||
return {
|
||||
name: nameMail,
|
||||
emailAddress: nameMail,
|
||||
phoneNumber: '+1.2345551234',
|
||||
faxNumber: '+1.2345551234',
|
||||
visibleInWhoisAsAdmin: false,
|
||||
visibleInWhoisAsTech: false,
|
||||
visibleInDomainWhoisAsAbuse: false,
|
||||
types: 'ADMIN',
|
||||
allowedToSetRegistryLockPassword: 'false'
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Convert parsed formContact to simulated wire form.
|
||||
* @param {!Element} contact
|
||||
* @return {!Object}
|
||||
*/
|
||||
function simulateJsonForContact(contact) {
|
||||
contact.visibleInWhoisAsAdmin = contact.visibleInWhoisAsAdmin == 'true';
|
||||
contact.visibleInWhoisAsTech = contact.visibleInWhoisAsTech == 'true';
|
||||
contact.visibleInDomainWhoisAsAbuse = contact.visibleInDomainWhoisAsAbuse == 'true';
|
||||
contact.types = '';
|
||||
for (const tNdx in contact.type) {
|
||||
if (contact.type[tNdx]) {
|
||||
if (contact.types.length > 0) {
|
||||
contact.types += ',';
|
||||
}
|
||||
contact.types += ('' + tNdx).toUpperCase();
|
||||
}
|
||||
}
|
||||
delete contact['type'];
|
||||
return contact;
|
||||
}
|
||||
});
|
|
@ -1,134 +0,0 @@
|
|||
// Copyright 2017 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.
|
||||
|
||||
goog.setTestOnly();
|
||||
|
||||
goog.require('goog.dispose');
|
||||
goog.require('goog.dom');
|
||||
goog.require('goog.testing.MockControl');
|
||||
goog.require('goog.testing.PropertyReplacer');
|
||||
goog.require('goog.testing.net.XhrIo');
|
||||
goog.require('registry.registrar.ConsoleTestUtil');
|
||||
goog.require('registry.testing');
|
||||
goog.require('registry.util');
|
||||
|
||||
describe('security settings test', function() {
|
||||
const $ = goog.dom.getRequiredElement;
|
||||
const stubs = new goog.testing.PropertyReplacer();
|
||||
|
||||
const expectedRegistrar = {
|
||||
ipAddressAllowList: [],
|
||||
phonePasscode: '12345',
|
||||
clientCertificate: null,
|
||||
clientCertificateHash: null,
|
||||
failoverClientCertificate: null
|
||||
};
|
||||
|
||||
const test = {
|
||||
testXsrfToken: '༼༎෴ ༎༽',
|
||||
testClientId: 'testClientId',
|
||||
mockControl: new goog.testing.MockControl()
|
||||
};
|
||||
|
||||
beforeEach(function() {
|
||||
registry.testing.addToDocument('<div id="test"/>');
|
||||
registry.testing.addToDocument('<div class="kd-butterbar"/>');
|
||||
registry.registrar.ConsoleTestUtil.renderConsoleMain($('test'), {
|
||||
xsrfToken: test.testXsrfToken,
|
||||
clientId: test.testClientId,
|
||||
});
|
||||
stubs.setPath('goog.net.XhrIo', goog.testing.net.XhrIo);
|
||||
registry.registrar.ConsoleTestUtil.setup(test);
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
goog.dispose(test.console);
|
||||
goog.testing.net.XhrIo.cleanup();
|
||||
stubs.reset();
|
||||
test.mockControl.$tearDown();
|
||||
});
|
||||
|
||||
function testView() {
|
||||
registry.registrar.ConsoleTestUtil.visit(test, {
|
||||
path: 'security-settings',
|
||||
xsrfToken: test.testXsrfToken,
|
||||
clientId: test.testClientId
|
||||
});
|
||||
registry.testing.assertReqMockRsp(
|
||||
test.testXsrfToken,
|
||||
'/registrar-settings',
|
||||
{op: 'read', id: 'testClientId', args: {}},
|
||||
{
|
||||
status: 'SUCCESS',
|
||||
message: 'OK',
|
||||
results: [expectedRegistrar]
|
||||
});
|
||||
expect(registry.util.parseForm('item').phonePasscode).toEqual(expectedRegistrar.phonePasscode);
|
||||
}
|
||||
|
||||
it("testView", function() {
|
||||
testView();
|
||||
});
|
||||
|
||||
it("testEdit", function() {
|
||||
testView();
|
||||
|
||||
registry.testing.click($('reg-app-btn-edit'));
|
||||
|
||||
const form = document.forms.namedItem('item');
|
||||
form.elements['newIp'].value = '1.1.1.1';
|
||||
registry.testing.click($('btn-add-ip'));
|
||||
form.elements['newIp'].value = '2.2.2.2';
|
||||
registry.testing.click($('btn-add-ip'));
|
||||
|
||||
const exampleCert = $('exampleCert').value;
|
||||
const exampleCertHash = '6NKKNBnd2fKFooBINmn3V7L3JOTHh02+2lAqYHdlTgk';
|
||||
form.elements['clientCertificate'].value = exampleCert;
|
||||
form.elements['failoverClientCertificate'].value = 'bourgeois blues';
|
||||
registry.testing.click($('reg-app-btn-save'));
|
||||
|
||||
registry.testing.assertReqMockRsp(
|
||||
test.testXsrfToken,
|
||||
'/registrar-settings',
|
||||
{op: 'update', id: 'testClientId', args: {
|
||||
clientCertificate: exampleCert,
|
||||
clientCertificateHash: null,
|
||||
failoverClientCertificate: 'bourgeois blues',
|
||||
ipAddressAllowList: ['1.1.1.1', '2.2.2.2'],
|
||||
phonePasscode: expectedRegistrar.phonePasscode,
|
||||
readonly: false }},
|
||||
{status: 'SUCCESS',
|
||||
message: 'OK',
|
||||
results: [{}]});
|
||||
// XXX: The response above is ignored as the page re-issues a fetch. Should
|
||||
// either provide the real response here and use anyTimes(), or have
|
||||
// resource_component use this directly.
|
||||
|
||||
expectedRegistrar.clientCertificate = exampleCert;
|
||||
expectedRegistrar.clientCertificateHash = exampleCertHash;
|
||||
expectedRegistrar.failoverClientCertificate = 'bourgeois blues';
|
||||
expectedRegistrar.ipAddressAllowList = ['1.1.1.1/32', '2.2.2.2/32'];
|
||||
registry.testing.assertReqMockRsp(
|
||||
test.testXsrfToken,
|
||||
'/registrar-settings',
|
||||
{op: 'read', id: 'testClientId', args: {}},
|
||||
{status: 'SUCCESS',
|
||||
message: 'OK',
|
||||
results: [expectedRegistrar]});
|
||||
|
||||
delete expectedRegistrar['clientCertificateHash'];
|
||||
registry.testing.assertObjectEqualsPretty(
|
||||
expectedRegistrar, registry.util.parseForm('item'));
|
||||
});
|
||||
});
|
|
@ -1,166 +0,0 @@
|
|||
// Copyright 2017 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.
|
||||
|
||||
goog.setTestOnly();
|
||||
|
||||
goog.require('goog.dispose');
|
||||
goog.require('goog.dom');
|
||||
goog.require('goog.dom.classlist');
|
||||
goog.require('goog.testing.MockControl');
|
||||
goog.require('goog.testing.PropertyReplacer');
|
||||
goog.require('goog.testing.net.XhrIo');
|
||||
goog.require('registry.registrar.ConsoleTestUtil');
|
||||
goog.require('registry.testing');
|
||||
goog.require('registry.util');
|
||||
|
||||
describe("whois settings test", function() {
|
||||
const $ = goog.dom.getRequiredElement;
|
||||
const $$ = goog.dom.getRequiredElementByClass;
|
||||
const stubs = new goog.testing.PropertyReplacer();
|
||||
|
||||
const test = {
|
||||
testXsrfToken: '༼༎෴ ༎༽',
|
||||
testClientId: 'testClientId',
|
||||
mockControl: new goog.testing.MockControl()
|
||||
};
|
||||
|
||||
beforeEach(function() {
|
||||
registry.testing.addToDocument('<div id="test"/>');
|
||||
registry.testing.addToDocument('<div class="kd-butterbar"/>');
|
||||
registry.registrar.ConsoleTestUtil.renderConsoleMain($('test'), {
|
||||
xsrfToken: test.testXsrfToken,
|
||||
clientId: test.testClientId,
|
||||
});
|
||||
stubs.setPath('goog.net.XhrIo', goog.testing.net.XhrIo);
|
||||
registry.registrar.ConsoleTestUtil.setup(test);
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
goog.dispose(test.console);
|
||||
stubs.reset();
|
||||
goog.testing.net.XhrIo.cleanup();
|
||||
test.mockControl.$tearDown();
|
||||
});
|
||||
|
||||
/**
|
||||
* Creates test registrar.
|
||||
* @return {!Object}
|
||||
*/
|
||||
function createTestRegistrar() {
|
||||
return {
|
||||
emailAddress: 'test2.ui@example.com',
|
||||
clientIdentifier: 'theRegistrar',
|
||||
ianaIdentifier: 1,
|
||||
icannReferralEmail: 'lol@sloth.test',
|
||||
whoisServer: 'foo.bar.baz',
|
||||
url: 'blah.blar',
|
||||
phoneNumber: '+1.2125650000',
|
||||
faxNumber: '+1.2125650001',
|
||||
localizedAddress: {
|
||||
street: ['111 Eighth Avenue', 'Eleventh Floor', 'lol'],
|
||||
city: 'New York',
|
||||
state: 'NY',
|
||||
zip: '10011',
|
||||
countryCode: 'US'
|
||||
}};
|
||||
}
|
||||
|
||||
function testView() {
|
||||
registry.registrar.ConsoleTestUtil.visit(test, {
|
||||
path: 'whois-settings',
|
||||
xsrfToken: test.testXsrfToken,
|
||||
clientId: test.testClientId
|
||||
});
|
||||
const testRegistrar = createTestRegistrar();
|
||||
registry.testing.assertReqMockRsp(
|
||||
test.testXsrfToken,
|
||||
'/registrar-settings',
|
||||
{op: 'read', id: 'testClientId', args: {}},
|
||||
{
|
||||
status: 'SUCCESS',
|
||||
message: 'OK',
|
||||
results: [testRegistrar]
|
||||
});
|
||||
const parsed = registry.util.parseForm('item');
|
||||
parsed.ianaIdentifier = parseInt(parsed.ianaIdentifier);
|
||||
registry.testing.assertObjectEqualsPretty(testRegistrar, parsed);
|
||||
}
|
||||
|
||||
it("testView", function() {
|
||||
testView();
|
||||
});
|
||||
|
||||
it("testEdit", function() {
|
||||
testView();
|
||||
registry.testing.click($('reg-app-btn-edit'));
|
||||
$('emailAddress').value = 'test2.ui@example.com';
|
||||
$('localizedAddress.street[0]').value = 'look at me i am';
|
||||
$('localizedAddress.street[1]').value = 'the mistress of the night';
|
||||
$('localizedAddress.street[2]').value = '';
|
||||
const parsed = registry.util.parseForm('item');
|
||||
parsed.readonly = false;
|
||||
registry.testing.click($('reg-app-btn-save'));
|
||||
registry.testing.assertReqMockRsp(
|
||||
test.testXsrfToken,
|
||||
'/registrar-settings',
|
||||
{op: 'update', id: 'testClientId', args: parsed},
|
||||
{
|
||||
status: 'SUCCESS',
|
||||
message: 'OK',
|
||||
results: [parsed]
|
||||
});
|
||||
});
|
||||
|
||||
it("testEditFieldError_insertsError", function() {
|
||||
testView();
|
||||
registry.testing.click($('reg-app-btn-edit'));
|
||||
$('phoneNumber').value = 'foo';
|
||||
const parsed = registry.util.parseForm('item');
|
||||
parsed.readonly = false;
|
||||
registry.testing.click($('reg-app-btn-save'));
|
||||
const errMsg = 'Carpe brunchus. --Pablo';
|
||||
registry.testing.assertReqMockRsp(
|
||||
test.testXsrfToken,
|
||||
'/registrar-settings',
|
||||
{op: 'update', id: 'testClientId', args: parsed},
|
||||
{
|
||||
status: 'ERROR',
|
||||
field: 'phoneNumber',
|
||||
message: errMsg
|
||||
});
|
||||
const msgBox = goog.dom.getNextElementSibling($('phoneNumber'));
|
||||
expect(goog.dom.classlist.contains(msgBox, 'kd-errormessage')).toBe(true);
|
||||
expect(goog.dom.classlist.contains($('phoneNumber'), 'kd-formerror')).toBe(true);
|
||||
expect(goog.dom.getTextContent(msgBox)).toEqual(errMsg);
|
||||
});
|
||||
|
||||
it("testEditNonFieldError_showsButterBar", function() {
|
||||
testView();
|
||||
registry.testing.click($('reg-app-btn-edit'));
|
||||
const parsed = registry.util.parseForm('item');
|
||||
parsed.readonly = false;
|
||||
registry.testing.click($('reg-app-btn-save'));
|
||||
const errMsg = 'One must still have chaos in oneself to be able to give ' +
|
||||
'birth to a dancing star. --Nietzsche';
|
||||
registry.testing.assertReqMockRsp(
|
||||
test.testXsrfToken,
|
||||
'/registrar-settings',
|
||||
{op: 'update', id: 'testClientId', args: parsed},
|
||||
{
|
||||
status: 'ERROR',
|
||||
message: errMsg
|
||||
});
|
||||
expect(goog.dom.getTextContent($$('kd-butterbar-text'))).toEqual(errMsg);
|
||||
});
|
||||
});
|
|
@ -1,113 +0,0 @@
|
|||
// Copyright 2017 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.
|
||||
|
||||
goog.provide('registry.testing');
|
||||
goog.setTestOnly('registry.testing');
|
||||
|
||||
goog.require('goog.dom');
|
||||
goog.require('goog.dom.classlist');
|
||||
goog.require('goog.events.EventType');
|
||||
goog.require('goog.format.JsonPrettyPrinter');
|
||||
goog.require('goog.html.testing');
|
||||
goog.require('goog.json');
|
||||
goog.require('goog.testing.events');
|
||||
goog.require('goog.testing.events.Event');
|
||||
goog.require('goog.testing.net.XhrIo');
|
||||
|
||||
|
||||
/**
|
||||
* Adds specified HTML string to document.
|
||||
* @param {string} html
|
||||
*/
|
||||
registry.testing.addToDocument = function(html) {
|
||||
goog.global.document.body.appendChild(
|
||||
goog.dom.safeHtmlToNode(
|
||||
goog.html.testing.newSafeHtmlForTest(html)));
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Simulates a mouse click on a browser element.
|
||||
* @param {!Element} element
|
||||
*/
|
||||
registry.testing.click = function(element) {
|
||||
goog.testing.events.fireBrowserEvent(
|
||||
new goog.testing.events.Event(
|
||||
goog.events.EventType.CLICK, element));
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Asserts `element` has 'shown' class.
|
||||
* @param {!Element} element
|
||||
*/
|
||||
registry.testing.assertVisible = function(element) {
|
||||
expect(goog.dom.classlist.contains(element, 'shown')).toBe(true);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Asserts `element` has 'hidden' class.
|
||||
* @param {!Element} element
|
||||
*/
|
||||
registry.testing.assertHidden = function(element) {
|
||||
expect(goog.dom.classlist.contains(element, 'hidden')).toBe(true);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Like `assertObjectEquals` but with a better error message.
|
||||
* @param {?Object} a
|
||||
* @param {?Object} b
|
||||
*/
|
||||
registry.testing.assertObjectEqualsPretty = function(a, b) {
|
||||
try {
|
||||
expect(a).toEqual(b);
|
||||
} catch (e) {
|
||||
e.message = e.message + '\n' +
|
||||
'expected: ' + registry.testing.pretty_.format(a) + '\n' +
|
||||
'got: ' + registry.testing.pretty_.format(b);
|
||||
throw e;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* JSON request/response simulator for `ResourceComponent` subclasses.
|
||||
* @param {string} xsrfToken
|
||||
* @param {string} path server resource path.
|
||||
* @param {!Object} expectReqJson assert this object was sent,
|
||||
* e.g. {'op':'read',{}}
|
||||
* @param {!Object} mockRspJson mock a response, e.g. {'set':[]}
|
||||
*/
|
||||
registry.testing.assertReqMockRsp =
|
||||
function(xsrfToken, path, expectReqJson, mockRspJson) {
|
||||
var xhr = goog.testing.net.XhrIo.getSendInstances().pop();
|
||||
expect(xhr.isActive()).toBe(true);
|
||||
expect(path).toEqual(xhr.getLastUri());
|
||||
// XXX: XHR header checking should probably be added. Was inconsistent
|
||||
// between admin and registrar consoles.
|
||||
registry.testing.assertObjectEqualsPretty(
|
||||
expectReqJson, JSON.parse(xhr.getLastContent()));
|
||||
xhr.simulateResponse(200, goog.json.serialize(mockRspJson));
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* JSON pretty printer.
|
||||
* @type {!goog.format.JsonPrettyPrinter}
|
||||
* @private
|
||||
*/
|
||||
registry.testing.pretty_ = new goog.format.JsonPrettyPrinter(
|
||||
new goog.format.JsonPrettyPrinter.TextDelimiters());
|
Loading…
Add table
Add a link
Reference in a new issue