diff options
author | Johan Thomsen <jth@dbc.dk> | 2019-03-10 23:03:15 +0100 |
---|---|---|
committer | Robin Gloster <mail@glob.in> | 2019-03-12 15:04:45 +0000 |
commit | 968d3c9c052ea07608e23da9a16ccc39263687f6 (patch) | |
tree | 29ca5685f8e107e75d3b42d398f2d0772c69c1d9 /nixos/tests | |
parent | 9f0ef9fb9f78f9e61e7cc7a62e3a2b935c1440aa (diff) | |
download | nixlib-968d3c9c052ea07608e23da9a16ccc39263687f6.tar nixlib-968d3c9c052ea07608e23da9a16ccc39263687f6.tar.gz nixlib-968d3c9c052ea07608e23da9a16ccc39263687f6.tar.bz2 nixlib-968d3c9c052ea07608e23da9a16ccc39263687f6.tar.lz nixlib-968d3c9c052ea07608e23da9a16ccc39263687f6.tar.xz nixlib-968d3c9c052ea07608e23da9a16ccc39263687f6.tar.zst nixlib-968d3c9c052ea07608e23da9a16ccc39263687f6.zip |
nixos/gitlab: improved test to check download of repository archives
Diffstat (limited to 'nixos/tests')
-rw-r--r-- | nixos/tests/gitlab.nix | 36 |
1 files changed, 33 insertions, 3 deletions
diff --git a/nixos/tests/gitlab.nix b/nixos/tests/gitlab.nix index 16e0dd723ecf..ac733461932d 100644 --- a/nixos/tests/gitlab.nix +++ b/nixos/tests/gitlab.nix @@ -1,5 +1,8 @@ # This test runs gitlab and checks if it works +let + initialRootPassword = "notproduction"; +in import ./make-test.nix ({ pkgs, lib, ...} : with lib; { name = "gitlab"; meta = with pkgs.stdenv.lib.maintainers; { @@ -27,7 +30,7 @@ import ./make-test.nix ({ pkgs, lib, ...} : with lib; { services.gitlab = { enable = true; databasePassword = "dbPassword"; - initialRootPassword = "notproduction"; + inherit initialRootPassword; smtp.enable = true; secrets = { secret = "secret"; @@ -69,7 +72,27 @@ import ./make-test.nix ({ pkgs, lib, ...} : with lib; { }; }; - testScript = '' + testScript = + let + auth = pkgs.writeText "auth.json" (builtins.toJSON { + grant_type = "password"; + username = "root"; + password = initialRootPassword; + }); + + createProject = pkgs.writeText "create-project.json" (builtins.toJSON { + name = "test"; + }); + + putFile = pkgs.writeText "put-file.json" (builtins.toJSON { + branch = "master"; + author_email = "author@example.com"; + author_name = "Firstname Lastname"; + content = "some content"; + commit_message = "create a new file"; + }); + in + '' $gitlab->start(); $gitlab->waitForUnit("gitaly.service"); $gitlab->waitForUnit("gitlab-workhorse.service"); @@ -78,6 +101,13 @@ import ./make-test.nix ({ pkgs, lib, ...} : with lib; { $gitlab->waitForFile("/var/gitlab/state/tmp/sockets/gitlab.socket"); $gitlab->waitUntilSucceeds("curl -sSf http://gitlab/users/sign_in"); $gitlab->succeed("curl -isSf http://gitlab | grep -i location | grep -q http://gitlab/users/sign_in"); - $gitlab->succeed("${pkgs.sudo}/bin/sudo -u gitlab -H gitlab-rake gitlab:check 1>&2") + $gitlab->succeed("${pkgs.sudo}/bin/sudo -u gitlab -H gitlab-rake gitlab:check 1>&2"); + $gitlab->succeed("echo \"Authorization: Bearer \$(curl -X POST -H 'Content-Type: application/json' -d @${auth} http://gitlab/oauth/token | ${pkgs.jq}/bin/jq -r '.access_token')\" >/tmp/headers"); + $gitlab->succeed("curl -X POST -H 'Content-Type: application/json' -H @/tmp/headers -d @${createProject} http://gitlab/api/v4/projects"); + $gitlab->succeed("curl -X POST -H 'Content-Type: application/json' -H @/tmp/headers -d @${putFile} http://gitlab/api/v4/projects/1/repository/files/some-file.txt"); + $gitlab->succeed("curl -H @/tmp/headers http://gitlab/api/v4/projects/1/repository/archive.tar.gz > /tmp/archive.tar.gz"); + $gitlab->succeed("curl -H @/tmp/headers http://gitlab/api/v4/projects/1/repository/archive.tar.bz2 > /tmp/archive.tar.bz2"); + $gitlab->succeed("test -s /tmp/archive.tar.gz"); + $gitlab->succeed("test -s /tmp/archive.tar.bz2"); ''; }) |