|
14 | 14 | tar -xvf ${pkgs.sources.dynamodb} |
15 | 15 | ''; |
16 | 16 |
|
17 | | - test = pkgs.runCommand "tests" { buildInputs = [ pkgs.jre pkgs.curl pkgs.netcat pkgs.awscli ]; } |
| 17 | + publicKey = builtins.readFile ./public.cer; |
| 18 | + |
| 19 | + swaggerUi = pkgs.runCommand "swagger-ui" {} |
| 20 | + '' |
| 21 | + mkdir -p $out |
| 22 | + ${handler}/bin/swagger $out |
| 23 | + ''; |
| 24 | + |
| 25 | + googleResp = { "key1" = publicKey ; }; |
| 26 | + |
| 27 | + apiDir = pkgs.writeTextFile |
| 28 | + { name = "google-resp"; |
| 29 | + destination = "/robot/v1/metadata/x509/[email protected]"; |
| 30 | + text = builtins.toJSON googleResp; |
| 31 | + }; |
| 32 | + |
| 33 | + # TODO: don't use latest dynamodb (but pin version) |
| 34 | + |
| 35 | + test = pkgs.runCommand "tests" |
| 36 | + { buildInputs = |
| 37 | + [ pkgs.jre |
| 38 | + pkgs.netcat |
| 39 | + pkgs.awscli |
| 40 | + pkgs.haskellPackages.wai-app-static |
| 41 | + ]; |
| 42 | + } |
18 | 43 | '' |
19 | 44 |
|
20 | | - java -Djava.library.path=${dynamoJar}/DynamoDBLocal_lib -jar ${dynamoJar}/DynamoDBLocal.jar -sharedDb -port 8000 & |
| 45 | + # Set up DynamoDB |
| 46 | + java \ |
| 47 | + -Djava.library.path=${dynamoJar}/DynamoDBLocal_lib \ |
| 48 | + -jar ${dynamoJar}/DynamoDBLocal.jar \ |
| 49 | + -sharedDb -port 8000 & |
21 | 50 |
|
22 | 51 | while ! nc -z 127.0.0.1 8000; do |
23 | 52 | echo waiting for DynamoDB |
24 | 53 | sleep 1 |
25 | 54 | done |
| 55 | +
|
26 | 56 | export AWS_DEFAULT_REGION=us-east-1 |
27 | 57 | export AWS_ACCESS_KEY_ID=dummy |
28 | 58 | export AWS_SECRET_ACCESS_KEY=dummy |
29 | 59 |
|
| 60 | + aws dynamodb create-table \ |
| 61 | + --table-name Users \ |
| 62 | + --attribute-definitions \ |
| 63 | + AttributeName=UserId,AttributeType=S \ |
| 64 | + --key-schema AttributeName=UserId,KeyType=HASH \ |
| 65 | + --endpoint-url http://127.0.0.1:8000 \ |
| 66 | + --provisioned-throughput ReadCapacityUnits=1,WriteCapacityUnits=1 \ |
| 67 | + > /dev/null |
| 68 | +
|
30 | 69 | aws dynamodb create-table \ |
31 | 70 | --table-name Decks \ |
32 | 71 | --attribute-definitions \ |
33 | 72 | AttributeName=DeckId,AttributeType=S \ |
34 | 73 | --key-schema AttributeName=DeckId,KeyType=HASH \ |
35 | 74 | --endpoint-url http://127.0.0.1:8000 \ |
36 | | - --provisioned-throughput ReadCapacityUnits=1,WriteCapacityUnits=1 |
| 75 | + --provisioned-throughput ReadCapacityUnits=1,WriteCapacityUnits=1 \ |
| 76 | + > /dev/null |
37 | 77 |
|
38 | 78 | aws dynamodb create-table \ |
39 | 79 | --table-name Slides \ |
40 | 80 | --attribute-definitions \ |
41 | 81 | AttributeName=SlideId,AttributeType=S \ |
42 | 82 | --key-schema AttributeName=SlideId,KeyType=HASH \ |
43 | 83 | --endpoint-url http://127.0.0.1:8000 \ |
44 | | - --provisioned-throughput ReadCapacityUnits=1,WriteCapacityUnits=1 |
| 84 | + --provisioned-throughput ReadCapacityUnits=1,WriteCapacityUnits=1 \ |
| 85 | + > /dev/null |
45 | 86 |
|
| 87 | + # Start server with fs redirect for getProtocolByName |
46 | 88 | NIX_REDIRECTS=/etc/protocols=${pkgs.iana-etc}/etc/protocols \ |
47 | 89 | LD_PRELOAD="${pkgs.libredirect}/lib/libredirect.so" \ |
48 | 90 | ${handler}/bin/server & |
49 | 91 |
|
50 | 92 | while ! nc -z 127.0.0.1 8080; do |
| 93 | + echo waiting for server |
| 94 | + sleep 1 |
| 95 | + done |
| 96 | +
|
| 97 | + # Set up mock server for Google public keys |
| 98 | + cp ${pkgs.writeText "google-x509" (builtins.toJSON googleResp)} cert |
| 99 | + warp -d ${apiDir} -p 8081 & |
| 100 | + while ! nc -z 127.0.0.1 8081; do |
51 | 101 | echo waiting for warp |
52 | 102 | sleep 1 |
53 | 103 | done |
54 | 104 |
|
55 | 105 | echo "Running tests" |
56 | | - ${handler}/bin/test |
| 106 | + ${handler}/bin/test ${./token} |
57 | 107 |
|
58 | 108 | touch $out |
59 | 109 | ''; |
|
0 commit comments