-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #49 from hmrc/APIS-4455
APIS-4455 First stage of discontinuation of legacy sandbox tokens.
- Loading branch information
Showing
36 changed files
with
494 additions
and
336 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
app/uk/gov/hmrc/thirdpartyapplication/config/DropSandboxIndex.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 @@ | ||
/* | ||
* Copyright 2019 HM Revenue & Customs | ||
* | ||
* 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. | ||
*/ | ||
|
||
package uk.gov.hmrc.thirdpartyapplication.config | ||
|
||
import com.google.inject.AbstractModule | ||
import javax.inject.{Inject, Singleton} | ||
import uk.gov.hmrc.thirdpartyapplication.repository.ApplicationRepository | ||
|
||
import scala.concurrent.ExecutionContext | ||
|
||
class DropSandboxIndexModule extends AbstractModule { | ||
override def configure(): Unit = { | ||
bind(classOf[DropSandboxIndex]).asEagerSingleton() | ||
} | ||
} | ||
|
||
@Singleton | ||
class DropSandboxIndex @Inject()(applicationRepository: ApplicationRepository)(implicit ec: ExecutionContext) { | ||
|
||
val indexName = "sandboxTokenClientIdIndex" | ||
applicationRepository.collection.indexesManager.drop(indexName) | ||
|
||
} | ||
|
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
22 changes: 22 additions & 0 deletions
22
app/uk/gov/hmrc/thirdpartyapplication/models/AccessType.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,22 @@ | ||
/* | ||
* Copyright 2019 HM Revenue & Customs | ||
* | ||
* 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. | ||
*/ | ||
|
||
package uk.gov.hmrc.thirdpartyapplication.models | ||
|
||
object AccessType extends Enumeration { | ||
type AccessType = Value | ||
val STANDARD, PRIVILEGED, ROPC = Value | ||
} |
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
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
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
78 changes: 78 additions & 0 deletions
78
app/uk/gov/hmrc/thirdpartyapplication/models/db/ApplicationData.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,78 @@ | ||
/* | ||
* Copyright 2019 HM Revenue & Customs | ||
* | ||
* 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. | ||
*/ | ||
|
||
package uk.gov.hmrc.thirdpartyapplication.models.db | ||
|
||
import java.util.UUID | ||
|
||
import org.joda.time.DateTime | ||
import uk.gov.hmrc.thirdpartyapplication.models.AccessType._ | ||
import uk.gov.hmrc.thirdpartyapplication.models.RateLimitTier.{BRONZE, RateLimitTier} | ||
import uk.gov.hmrc.thirdpartyapplication.models.State.{PRODUCTION, TESTING} | ||
import uk.gov.hmrc.thirdpartyapplication.models._ | ||
import uk.gov.hmrc.time.DateTimeUtils | ||
|
||
case class ApplicationData(id: UUID, | ||
name: String, | ||
normalisedName: String, | ||
collaborators: Set[Collaborator], | ||
description: Option[String] = None, | ||
wso2Username: String, | ||
wso2Password: String, | ||
wso2ApplicationName: String, | ||
tokens: ApplicationTokens, | ||
state: ApplicationState, | ||
access: Access = Standard(Seq.empty, None, None), | ||
createdOn: DateTime = DateTimeUtils.now, | ||
lastAccess: Option[DateTime] = Some(DateTimeUtils.now), | ||
rateLimitTier: Option[RateLimitTier] = Some(BRONZE), | ||
environment: String = Environment.PRODUCTION.toString, | ||
checkInformation: Option[CheckInformation] = None, | ||
blocked: Boolean = false) { | ||
lazy val admins = collaborators.filter(_.role == Role.ADMINISTRATOR) | ||
} | ||
|
||
object ApplicationData { | ||
|
||
def create(application: CreateApplicationRequest, | ||
wso2Username: String, | ||
wso2Password: String, | ||
wso2ApplicationName: String, | ||
tokens: ApplicationTokens): ApplicationData = { | ||
|
||
val applicationState = (application.environment, application.access.accessType) match { | ||
case (Environment.SANDBOX, _) => ApplicationState(PRODUCTION) | ||
case (_, PRIVILEGED | ROPC) => ApplicationState(PRODUCTION, application.collaborators.headOption.map(_.emailAddress)) | ||
case _ => ApplicationState(TESTING) | ||
} | ||
|
||
ApplicationData( | ||
UUID.randomUUID, | ||
application.name, | ||
application.name.toLowerCase, | ||
application.collaborators, | ||
application.description, | ||
wso2Username, | ||
wso2Password, | ||
wso2ApplicationName, | ||
tokens, | ||
applicationState, | ||
application.access, | ||
environment = application.environment.toString) | ||
} | ||
} | ||
|
||
case class ApplicationTokens(production: EnvironmentToken) |
Oops, something went wrong.