Skip to content
This repository has been archived by the owner on Oct 23, 2024. It is now read-only.

Commit

Permalink
Fixes #5024 by using the correct validator for validating app depende…
Browse files Browse the repository at this point in the history
…ncies. (#5027)
  • Loading branch information
aquamatthias authored Jan 27, 2017
1 parent 1dc09c4 commit 25dd12d
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/main/scala/mesosphere/marathon/state/AppDefinition.scala
Original file line number Diff line number Diff line change
Expand Up @@ -608,9 +608,8 @@ object AppDefinition extends GeneralPurposeCombinators {
*/
def validAppDefinition(implicit pluginManager: PluginManager): Validator[AppDefinition] =
validator[AppDefinition] { app =>
app.id is valid
app.id is PathId.absolutePathValidator
app.dependencies is every(PathId.validPathWithBase(app.id.parent))
app.id is valid and PathId.absolutePathValidator
app.dependencies is valid
} and validBasicAppDefinition and pluginValidators

/**
Expand Down Expand Up @@ -806,4 +805,4 @@ object AppDefinition extends GeneralPurposeCombinators {
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package mesosphere.marathon
package api.validation

import mesosphere.UnitTest
import mesosphere.marathon.core.plugin.PluginManager
import mesosphere.marathon.state.{ AppDefinition, PathId }

class AppDefinitionValidationTest extends UnitTest {

"AppDefinition" when {

"created with dependencies" should {

"be valid with dependencies pointing to a a subtree of this app" in new Fixture {
val app = AppDefinition(
id = PathId("/a/b/c/d"),
cmd = Some("sleep 1000"),
dependencies = Set(PathId("/a/b/c/e"))
)
validator(app).isSuccess shouldBe true
}

"be valid with dependencies pointing to a different subtree (Regression for #5024)" in new Fixture {
val app = AppDefinition(
id = PathId("/a/b/c/d"),
cmd = Some("sleep 1000"),
dependencies = Set(PathId("/x/y/z"))
)
validator(app).isSuccess shouldBe true
}

"be invalid with dependencies with invalid path chars" in new Fixture {
val app = AppDefinition(
id = PathId("/a/b/c/d"),
cmd = Some("sleep 1000"),
dependencies = Set(PathId("/a/.../"))
)
validator(app).isSuccess shouldBe false
}
}
}

class Fixture {
val validator = AppDefinition.validAppDefinition(PluginManager.None)
}
}

0 comments on commit 25dd12d

Please sign in to comment.