Skip to content

Commit

Permalink
1.31.0 (#42)
Browse files Browse the repository at this point in the history
* Fix test package names
* Update jars
  • Loading branch information
pambrose authored Sep 24, 2022
1 parent f57837d commit 5b1d5d7
Show file tree
Hide file tree
Showing 28 changed files with 89 additions and 53 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ depends:
./gradlew dependencies

upgrade-wrapper:
./gradlew wrapper --gradle-version=7.5 --distribution-type=bin
./gradlew wrapper --gradle-version=7.5.1 --distribution-type=bin
11 changes: 5 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ buildscript {
plugins {
id 'java'
id 'application'
id 'org.jetbrains.kotlin.jvm' version '1.7.10' apply false
id 'org.jetbrains.kotlin.plugin.serialization' version '1.7.10' apply false
id 'org.jmailen.kotlinter' version "3.11.1" apply false
id 'org.jetbrains.kotlin.jvm' version '1.7.20-RC' apply false
id 'org.jetbrains.kotlin.plugin.serialization' version '1.7.20-RC' apply false
id 'org.jmailen.kotlinter' version "3.12.0" apply false
id 'com.github.gmazzo.buildconfig' version '3.1.0' apply false
id "com.github.ben-manes.versions" version '0.42.0' apply false
id "org.flywaydb.flyway" version "9.0.1"
id "org.flywaydb.flyway" version "9.3.1"
}

ext {
Expand Down Expand Up @@ -85,7 +85,7 @@ ext {
allprojects {
description = 'ReadingBat Core'
group 'com.github.readingbat'
version '1.30.0'
version '1.31.0'

apply plugin: 'application'
apply plugin: 'java-library' // gradle 7
Expand Down Expand Up @@ -125,7 +125,6 @@ allprojects {
}

subprojects {

dependencies {
// These are required for the annotation args below
//implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version"
Expand Down
30 changes: 15 additions & 15 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,27 @@ org.gradle.configureondemand=true
org.gradle.parallel=true
org.gradle.caching=true
org.gradle.jvmargs=-Xmx8g -Dkotlin.daemon.jvm.options=-Xmx6g -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
cloud_version=1.6.2
cloud_version=1.7.0
commons_version=1.9
css_version=1.0.0-pre.357
exposed_version=0.38.2
css_version=1.0.0-pre.390
exposed_version=0.39.2
flexmark_version=0.64.0
github_api_version=1.307
gson_version=2.9.0
github_api_version=1.308
gson_version=2.9.1
hikari_version=5.0.1
java_script_version=2.0.0
khealth_version=2.1.0
kotest_version=5.3.2
khealth_version=2.1.1
kotest_version=5.4.2
kotest_ktor_version=4.4.3
kotlin_version=1.7.10
ktor_version=2.0.3
logback_version=1.2.10
logging_version=2.1.23
kotlin_version=1.7.20-RC
ktor_version=2.1.1
logback_version=1.4.1
logging_version=3.0.0
pgjdbc_version=0.8.9
postgres_version=42.4.0
postgres_version=42.5.0
prometheus_version=0.16.0
proxy_version=1.13.0
redis_version=4.2.3
serialization_version=1.3.3
proxy_version=1.14.0
redis_version=4.3.0-m2
serialization_version=1.4.0
sendgrid_version=4.9.3
utils_version=1.28.0
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion readingbat-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ buildConfig {

buildConfigField('String', 'CORE_NAME', "\"${project.name}\"")
buildConfigField('String', 'CORE_VERSION', "\"${project.version}\"")
buildConfigField('String', 'CORE_RELEASE_DATE', "\"07/16/2022\"")
buildConfigField('String', 'CORE_RELEASE_DATE', "\"09/23/2022\"")
}

// Include build uberjars in heroku deploy
Expand Down
26 changes: 13 additions & 13 deletions readingbat-core/src/main/kotlin/Content.kt
Original file line number Diff line number Diff line change
Expand Up @@ -76,18 +76,18 @@ val dslContent =
include(GitHubContent(Organization, "readingbat", "readingbat-python-content", srcPath = "src").eval(this).python)
include(GitHubContent(Organization, "readingbat", "readingbat-java-content").eval(this).kotlin)
*/
/*
kotlin {
group("Infinite Loop") {
packageName = "com.github.readingbat.test_content"
/*
kotlin {
group("Infinite Loop") {
packageName = "com.github.readingbat.testcontent"
challenge("InfiniteLoop") {
returnType = ReturnType.BooleanType
}
challenge("InfiniteLoop") {
returnType = ReturnType.BooleanType
}
}
}
*/
}
}
*/

//include(GitHubContent(Organization, "readingbat", "readingbat-java-content", fileName = "Content.kt").eval(this, variableName = "content").java)

Expand All @@ -113,7 +113,7 @@ val dslContent =
srcPath = "python"

group("Test Cases") {
packageName = "test_content"
packageName = "testcontent"
description = "Tests"

challenge("divide1") { returnType = FloatType /* This should be a float*/ }
Expand All @@ -132,7 +132,7 @@ val dslContent =
branchName = "1.12.0"

group("Java Tests") {
packageName = "com.github.readingbat.test_content"
packageName = "com.github.readingbat.testcontent"
description = "Tests"

challenge("StringArrayTest1")
Expand All @@ -148,7 +148,7 @@ val dslContent =
branchName = "1.12.0"

group("Kotlin Tests") {
packageName = "com.github.readingbat.test_content"
packageName = "com.github.readingbat.testcontent"
description = "Tests"

challenge("StringArrayKtTest1") { returnType = StringArrayType }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,7 @@ internal object ChallengePage : KLogging() {
?.let { Json.decodeFromString<Map<String, String>>(it) }
?: emptyMap
}

browserSession.isNotNull() ->
transaction {
SessionChallengeInfoTable
Expand All @@ -700,6 +701,7 @@ internal object ChallengePage : KLogging() {
?.let { Json.decodeFromString<Map<String, String>>(it) }
?: emptyMap
}

else -> emptyMap
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ internal object ClassSummaryPage : KLogging() {
val teacherId = classCode.fetchClassTeacherId()
throw InvalidRequestException("User id ${user.userId} does not match class code's teacher id $teacherId")
}

else -> {
// Do nothing
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ internal object StudentSummaryPage : KLogging() {
val teacherId = classCode.fetchClassTeacherId()
throw InvalidRequestException("User id ${user.userId} does not match class code's teacher Id $teacherId")
}

else -> {
// Do nothing
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ internal object UserInfoPage {
user.isNotValidUser() -> {
br { +"Must be logged in for this function" }
}

else -> {
val name = user.fullName
val email = user.email
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ internal object ChallengePost : KLogging() {
UserChallengeInfoTable
.deleteWhere { (UserChallengeInfoTable.userRef eq fetchUserDbmsIdFromCache(id)) and (UserChallengeInfoTable.md5 eq md5) }
}

NO_AUTH_KEY ->
transaction {
SessionChallengeInfoTable
Expand All @@ -217,6 +218,7 @@ internal object ChallengePost : KLogging() {
)) and (SessionChallengeInfoTable.md5 eq md5)
}
}

else -> error("Invalid type: $type")
}

Expand All @@ -227,6 +229,7 @@ internal object ChallengePost : KLogging() {
UserAnswerHistoryTable
.deleteWhere { (UserAnswerHistoryTable.userRef eq fetchUserDbmsIdFromCache(id)) and (UserAnswerHistoryTable.md5 eq md5) }
}

NO_AUTH_KEY ->
transaction {
SessionAnswerHistoryTable
Expand All @@ -237,6 +240,7 @@ internal object ChallengePost : KLogging() {
)) and (SessionAnswerHistoryTable.md5 eq md5)
}
}

else -> error("Invalid type: $type")
}

Expand Down Expand Up @@ -336,6 +340,7 @@ internal object ChallengePost : KLogging() {
LIKE_CLEAR -> 1
LIKE_COLOR,
DISLIKE_COLOR -> 0

DISLIKE_CLEAR -> 2
else -> error("Invalid like/dislike argument: $likeArg")
}
Expand Down Expand Up @@ -385,6 +390,7 @@ internal object ChallengePost : KLogging() {
row[allCorrect] = complete
row[answersJson] = invokeStr
}

browserSession.isNotNull() ->
SessionChallengeInfoTable
.upsert(conflictIndex = sessionChallengeInfoIndex) { row ->
Expand All @@ -394,6 +400,7 @@ internal object ChallengePost : KLogging() {
row[allCorrect] = complete
row[answersJson] = invokeStr
}

else ->
logger.warn { "ChallengeInfo not updated" }
}
Expand Down Expand Up @@ -433,6 +440,7 @@ internal object ChallengePost : KLogging() {
row[UserAnswerHistoryTable.incorrectAttempts] = incorrectAttempts
row[historyJson] = json
}

browserSession.isNotNull() ->
SessionAnswerHistoryTable
.upsert(conflictIndex = sessionAnswerHistoryIndex) { row ->
Expand All @@ -444,6 +452,7 @@ internal object ChallengePost : KLogging() {
row[SessionAnswerHistoryTable.incorrectAttempts] = incorrectAttempts
row[historyJson] = json
}

else ->
logger.warn { "Answer history not updated" }
}
Expand Down Expand Up @@ -480,6 +489,7 @@ internal object ChallengePost : KLogging() {
if (shouldPublish)
user.publishLikeDislike(challengeMd5, likeDislikeVal)
}

browserSession.isNotNull() ->
transaction {
SessionChallengeInfoTable
Expand All @@ -490,6 +500,7 @@ internal object ChallengePost : KLogging() {
row[likeDislike] = likeDislikeVal.toShort()
}
}

else -> {
// Do nothing
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ internal object CreateAccountPost : KLogging() {
email.isBlank() -> createAccountPage(defaultFullName = fullName, msg = EMPTY_EMAIL_MSG)
email.isNotValidEmail() ->
createAccountPage(defaultFullName = fullName, defaultEmail = email, msg = INVALID_EMAIL_MSG)

else -> {
val passwordError = checkPassword(password, confirmPassword)
if (passwordError.isNotBlank)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,17 @@ internal object PasswordResetPost : KLogging() {
unknownUserLimiter.acquire()
passwordResetPage(EMPTY_RESET_ID, Message("Invalid user: $email", true))
}

email.isBlank() -> passwordResetPage(EMPTY_RESET_ID, unableToSend)
email.isNotValidEmail() -> {
passwordResetPage(EMPTY_RESET_ID, Message("Invalid email address: $email", true))
}

isNotRegisteredEmail(email) -> {
unknownUserLimiter.acquire()
passwordResetPage(EMPTY_RESET_ID, Message("Unknown user: $email", true))
}

else -> {
try {
val newResetId = newResetId()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ internal object TeacherPrefsPost : KLogging() {
else -> error("Invalid source: $source")
}
}

REMOVE_FROM_CLASS -> {
val studentId = params[USER_ID_PARAM] ?: error("Missing: $USER_ID_PARAM")
val student = studentId.toUser()
Expand All @@ -84,7 +85,9 @@ internal object TeacherPrefsPost : KLogging() {
logger.info { msg }
classSummaryPage(content, user, classCode, msg = Message(msg))
}

DELETE_CLASS -> deleteClass(content, user, params.getClassCode(CLASS_CODE_NAME_PARAM))

else -> error("Invalid action: $action")
}
} else {
Expand Down Expand Up @@ -122,13 +125,16 @@ internal object TeacherPrefsPost : KLogging() {
classDesc.isBlank() -> {
teacherPrefsPage(content, user, Message("Unable to create class [Empty class description]", true))
}

!user.isUniqueClassDesc(classDesc) -> {
teacherPrefsPage(content, user, Message("Class description is not unique [$classDesc]", true), classDesc)
}

user.classCount() == content.maxClassCount -> {
val msg = Message("Maximum number of classes is: [${content.maxClassCount}]", true)
teacherPrefsPage(content, user, msg, classDesc)
}

else -> {
// Add classcode to list of classes created by user
val classCode = newClassCode()
Expand All @@ -143,6 +149,7 @@ internal object TeacherPrefsPost : KLogging() {
// student/teacher toggle mode
queryActiveTeachingClassCode(user) == classCode && classCode.isEnabled ->
Message("Same active class selected [$classCode]", true)

else -> {
user.assignActiveClassCode(classCode, true)
Message(
Expand All @@ -162,6 +169,7 @@ internal object TeacherPrefsPost : KLogging() {
user,
Message("Invalid class code: $classCode", true)
)

else -> {
val activeTeachingClassCode = queryActiveTeachingClassCode(user)
val enrollees = classCode.fetchEnrollees()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ internal object ConfigureFormAuth : KLogging() {
private val failedLoginLimiter = RateLimiter.create(1.0) // rate 2.0 is "2 permits per second"

/**
* Form-based authentication is a interceptor that reads attributes off a POST request in order to validate the user.
* Form-based authentication is an interceptor that reads attributes off a POST request in order to validate the user.
* Only needed by whatever your login form is POSTing to.
*
* If validation fails, the user will be challenged, e.g. sent to a login page to authenticate.
Expand All @@ -51,7 +51,7 @@ internal object ConfigureFormAuth : KLogging() {

challenge {
// I don't think form auth supports multiple errors, but we're conservatively assuming there will be at
// most one error, which we handle here. Worst case, we just send the user to login with no context.
// most one error, which we handle here. Worst case, we just send the user to log in with no context.

// val errors: List<AuthenticationFailedCause> = call.authentication.allFailures
// logger.info { "Inside challenge: $errors" }
Expand Down
Loading

0 comments on commit 5b1d5d7

Please sign in to comment.