-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathPasskeyDBTest.scala
More file actions
77 lines (70 loc) · 2.15 KB
/
PasskeyDBTest.scala
File metadata and controls
77 lines (70 loc) · 2.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package aws
import org.scalatest.freespec.AnyFreeSpec
import org.scalatest.matchers.should.Matchers
import software.amazon.awssdk.services.dynamodb.DynamoDbClient
import software.amazon.awssdk.services.dynamodb.model.KeyType.{HASH, RANGE}
import software.amazon.awssdk.services.dynamodb.model.ScalarAttributeType.S
import software.amazon.awssdk.services.dynamodb.model._
class PasskeyDBTest extends AnyFreeSpec with Matchers {
"test db stuff - use this to test DynamoDB stuff locally during development" - {
given dynamoDB: DynamoDbClient = Clients.localDb
"create table" ignore {
createTable()
}
"destroy table" ignore {
destroyTable()
}
}
/** NB: Only use these for local testing use the provided CloudFormation
* template to create table in AWS environments.
*
* If you update this then be sure to also update the CloudFormation
* template's definition.
*/
private[aws] def createTable()(implicit
dynamoDB: DynamoDbClient
): CreateTableResponse =
dynamoDB.createTable(
CreateTableRequest
.builder()
.tableName(PasskeyDB.tableName)
.keySchema(
KeySchemaElement
.builder()
.attributeName("username")
.keyType(HASH)
.build(),
KeySchemaElement
.builder()
.attributeName("credentialId")
.keyType(RANGE)
.build()
)
.attributeDefinitions(
AttributeDefinition
.builder()
.attributeName("username")
.attributeType(S)
.build(),
AttributeDefinition
.builder()
.attributeName("credentialId")
.attributeType(S)
.build()
)
.provisionedThroughput(
ProvisionedThroughput
.builder()
.readCapacityUnits(15L)
.writeCapacityUnits(15L)
.build()
)
.build()
)
private[aws] def destroyTable()(implicit
dynamoDb: DynamoDbClient
): DeleteTableResponse =
dynamoDb.deleteTable(
DeleteTableRequest.builder().tableName(PasskeyDB.tableName).build()
)
}