-
Notifications
You must be signed in to change notification settings - Fork 633
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
60 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
migration/src/test/scala/org/thp/thehive/migration/th3/UserNormalisationTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package org.thp.thehive.migration.th3 | ||
|
||
import akka.NotUsed | ||
import akka.stream.scaladsl.Source | ||
import akka.util.ByteString | ||
import play.api.test.PlaySpecification | ||
|
||
class UserNormalisationTest extends PlaySpecification with Conversion { | ||
override def readAttachment(id: String): Source[ByteString, NotUsed] = Source.empty | ||
override val mainOrganisation: String = "thehive.local" | ||
|
||
"User migration" should { | ||
"convert simple name" in { | ||
normaliseLogin("myLogin") must beEqualTo("mylogin") | ||
} | ||
"convert email address" in { | ||
normaliseLogin("Firstname.Lastname@Example.com") must beEqualTo("firstname.lastname@example.com") | ||
} | ||
"convert login with special characters" in { | ||
normaliseLogin("login`with\"special^chars%") must beEqualTo("login.with.special.chars") | ||
} | ||
"convert login with only special characters" in { | ||
normaliseLogin("^'\"éç") must beEqualTo("empty.name") | ||
} | ||
"convert login with several @" in { | ||
normaliseLogin("first@second@third") must beEqualTo("first@second.third") | ||
} | ||
"convert invalid email address" in { | ||
normaliseLogin(".first.@.domain.") must beEqualTo("first@domain") | ||
} | ||
"convert empty domain" in { | ||
normaliseLogin("first@") must beEqualTo("first") | ||
} | ||
"convert email with invalid domain" in { | ||
normaliseLogin("first@```") must beEqualTo("first") | ||
} | ||
} | ||
} |