polytrix 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (171) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +13 -0
  3. data/.groc.json +7 -0
  4. data/.rspec +11 -0
  5. data/.rspec_parallel +10 -0
  6. data/Gemfile +23 -0
  7. data/README.md +48 -0
  8. data/Rakefile +143 -0
  9. data/Vagrantfile +41 -0
  10. data/features/0_identity_spec.rb +40 -0
  11. data/features/1_cloud_files_spec.rb +48 -0
  12. data/features/2_servers_spec.rb +19 -0
  13. data/features/features_helper.rb +46 -0
  14. data/features/helpers/cloudfiles_helper.rb +31 -0
  15. data/features/helpers/pacto_helper.rb +33 -0
  16. data/features/helpers/teardown_helper.rb +49 -0
  17. data/features/pacto/extensions/loaders/api_blueprint_loader.rb +63 -0
  18. data/features/pacto/extensions/loaders/simple_loader.rb +55 -0
  19. data/features/pacto/extensions/loaders/yaml_or_json_loader.rb +17 -0
  20. data/features/pacto/extensions/matchers.rb +38 -0
  21. data/features/phase2/feature_coverage_report.rb +109 -0
  22. data/features/phase2/run_all_features.rb +14 -0
  23. data/features/static_site/fixtures/index.html +6 -0
  24. data/lib/polytrix/challenge.rb +27 -0
  25. data/lib/polytrix/challenge_builder.rb +16 -0
  26. data/lib/polytrix/challenge_runner.rb +87 -0
  27. data/lib/polytrix/configuration.rb +31 -0
  28. data/lib/polytrix/core/file_finder.rb +43 -0
  29. data/lib/polytrix/core/implementor.rb +17 -0
  30. data/lib/polytrix/core/result_tracker.rb +25 -0
  31. data/lib/polytrix/documentation_generator.rb +18 -0
  32. data/lib/polytrix/manifest.rb +46 -0
  33. data/lib/polytrix/result.rb +9 -0
  34. data/lib/polytrix/rspec/documentation_formatter.rb +41 -0
  35. data/lib/polytrix/rspec.rb +75 -0
  36. data/lib/polytrix/runners/linux_challenge_runner.rb +22 -0
  37. data/lib/polytrix/runners/middleware/change_directory.rb +20 -0
  38. data/lib/polytrix/runners/middleware/feature_executor.rb +23 -0
  39. data/lib/polytrix/runners/middleware/pacto.rb +59 -0
  40. data/lib/polytrix/runners/middleware/setup_env_vars.rb +38 -0
  41. data/lib/polytrix/runners/windows_challenge_runner.rb +25 -0
  42. data/lib/polytrix/version.rb +3 -0
  43. data/lib/polytrix.rb +56 -0
  44. data/packer/.gitignore +3 -0
  45. data/packer/Berksfile +15 -0
  46. data/packer/Gemfile +5 -0
  47. data/packer/Vagrantfile +128 -0
  48. data/packer/cookbooks/drg/metadata.rb +27 -0
  49. data/packer/cookbooks/drg/recipes/admins.rb +22 -0
  50. data/packer/cookbooks/drg/recipes/default.rb +9 -0
  51. data/packer/cookbooks/drg/recipes/dotnet.rb +4 -0
  52. data/packer/cookbooks/drg/recipes/golang.rb +4 -0
  53. data/packer/cookbooks/drg/recipes/java.rb +5 -0
  54. data/packer/cookbooks/drg/recipes/php.rb +10 -0
  55. data/packer/cookbooks/drg/recipes/ruby.rb +29 -0
  56. data/packer/cookbooks/drg/recipes/system.rb +13 -0
  57. data/packer/create_box.sh +10 -0
  58. data/packer/http/preseed.cfg +87 -0
  59. data/packer/packer.json +91 -0
  60. data/packer/scripts/root_setup.sh +37 -0
  61. data/packer/scripts/setup.sh +32 -0
  62. data/pacto/config/pacto_server.rb +40 -0
  63. data/pacto/contracts/dfw.servers.api.rackspacecloud.com/v2/account_id/extensions.json +64 -0
  64. data/pacto/contracts/dfw.servers.api.rackspacecloud.com/v2/account_id/flavors/id.json +100 -0
  65. data/pacto/contracts/dfw.servers.api.rackspacecloud.com/v2/account_id/images/id.json +176 -0
  66. data/pacto/contracts/dfw.servers.api.rackspacecloud.com/v2/account_id/servers/id.json +189 -0
  67. data/pacto/contracts/dfw.servers.api.rackspacecloud.com/v2/account_id/servers.json +63 -0
  68. data/pacto/contracts/dns.api.rackspacecloud.com/v1.0/_tenant_id/domains.json +62 -0
  69. data/pacto/contracts/identity.api.rackspacecloud.com/v2.0/tokens.json +192 -0
  70. data/pacto/contracts/monitoring.api.rackspacecloud.com/v1.0/_tenant_id/account.json +39 -0
  71. data/pacto/contracts/ord.autoscale.api.rackspacecloud.com/v1.0/_tenant_id/groups.json +38 -0
  72. data/pacto/contracts/ord.blockstorage.api.rackspacecloud.com/v1/_tenant_id/volumes.json +30 -0
  73. data/pacto/contracts/ord.databases.api.rackspacecloud.com/v1.0/_tenant_id/instances.json +30 -0
  74. data/pacto/contracts/ord.loadbalancers.api.rackspacecloud.com/v1.0/_tenant_id/loadbalancers.json +114 -0
  75. data/pacto/contracts/ord.queues.api.rackspacecloud.com/v1/_tenant_id/queues.json +13 -0
  76. data/pacto/contracts/ord.servers.api.rackspacecloud.com/v2/_tenant_id/os-networksv2.json +46 -0
  77. data/pacto/contracts/ord.servers.api.rackspacecloud.com/v2/_tenant_id/servers/detail.json +230 -0
  78. data/pacto/contracts/storage101.dfw1.clouddrive.com/v1/mosso_account/container/object.json +15 -0
  79. data/pacto/contracts/storage101.dfw1.clouddrive.com/v1/mosso_account.json +43 -0
  80. data/pacto/contracts/storage101.ord1.clouddrive.com/v1/_mosso_id.json +44 -0
  81. data/pacto/pacto_server.rb +100 -0
  82. data/pacto/rackspace_uri_map.yaml +229 -0
  83. data/polytrix.gemspec +27 -0
  84. data/scripts/bootstrap +10 -0
  85. data/scripts/cibuild +4 -0
  86. data/sdks/fog/.gitignore +1 -0
  87. data/sdks/fog/Gemfile +5 -0
  88. data/sdks/fog/challenges/all_connections.rb +45 -0
  89. data/sdks/fog/challenges/authenticate_token.rb +15 -0
  90. data/sdks/fog/challenges/cdn_enable_container.rb +20 -0
  91. data/sdks/fog/challenges/create_a_container.rb +17 -0
  92. data/sdks/fog/challenges/create_server.rb +36 -0
  93. data/sdks/fog/challenges/get_object_metadata.rb +13 -0
  94. data/sdks/fog/challenges/list_containers.rb +10 -0
  95. data/sdks/fog/challenges/provision_scalable_webapp.rb +30 -0
  96. data/sdks/fog/challenges/upload_folder.rb +25 -0
  97. data/sdks/fog/scripts/bootstrap +4 -0
  98. data/sdks/fog/scripts/bootstrap.ps1 +1 -0
  99. data/sdks/fog/scripts/wrapper +2 -0
  100. data/sdks/fog/scripts/wrapper.ps1 +1 -0
  101. data/sdks/gophercloud/.gitignore +2 -0
  102. data/sdks/gophercloud/challenges/authenticate_token.go +23 -0
  103. data/sdks/gophercloud/scripts/bootstrap +6 -0
  104. data/sdks/gophercloud/scripts/wrapper +10 -0
  105. data/sdks/jclouds/.gitignore +1 -0
  106. data/sdks/jclouds/challenges/AuthenticateToken.java +115 -0
  107. data/sdks/jclouds/pom.xml +34 -0
  108. data/sdks/jclouds/scripts/bootstrap +3 -0
  109. data/sdks/jclouds/scripts/wrapper +7 -0
  110. data/sdks/openstack.net/.gitignore +4 -0
  111. data/sdks/openstack.net/.nuget/Microsoft.Build.dll +0 -0
  112. data/sdks/openstack.net/.nuget/NuGet.Config +6 -0
  113. data/sdks/openstack.net/.nuget/NuGet.exe +0 -0
  114. data/sdks/openstack.net/.nuget/NuGet.targets +136 -0
  115. data/sdks/openstack.net/Challenge.cs +10 -0
  116. data/sdks/openstack.net/RunChallenge.cs +19 -0
  117. data/sdks/openstack.net/challenges/AuthenticateToken.cs +24 -0
  118. data/sdks/openstack.net/challenges/Weird.cs +133 -0
  119. data/sdks/openstack.net/openstack.net.csproj +58 -0
  120. data/sdks/openstack.net/openstack.net.sln +27 -0
  121. data/sdks/openstack.net/openstack.net.userprefs +8 -0
  122. data/sdks/openstack.net/packages.config +6 -0
  123. data/sdks/openstack.net/scripts/bootstrap +2 -0
  124. data/sdks/openstack.net/scripts/bootstrap.ps1 +2 -0
  125. data/sdks/openstack.net/scripts/wrapper +7 -0
  126. data/sdks/openstack.net/scripts/wrapper.ps1 +1 -0
  127. data/sdks/php-opencloud/.gitignore +4 -0
  128. data/sdks/php-opencloud/challenges/all_connections.php +64 -0
  129. data/sdks/php-opencloud/challenges/authenticate_token.php +14 -0
  130. data/sdks/php-opencloud/challenges/create_server.php +39 -0
  131. data/sdks/php-opencloud/challenges/get_object_metadata.php +19 -0
  132. data/sdks/php-opencloud/composer.json +5 -0
  133. data/sdks/php-opencloud/scripts/bootstrap +4 -0
  134. data/sdks/php-opencloud/scripts/bootstrap.ps1 +2 -0
  135. data/sdks/php-opencloud/scripts/wrapper +2 -0
  136. data/sdks/php-opencloud/scripts/wrapper.ps1 +1 -0
  137. data/sdks/pkgcloud/.gitignore +1 -0
  138. data/sdks/pkgcloud/challenges/authenticate_token.js +17 -0
  139. data/sdks/pkgcloud/challenges/get_object_metadata.js +18 -0
  140. data/sdks/pkgcloud/scripts/bootstrap +2 -0
  141. data/sdks/pkgcloud/scripts/bootstrap.ps1 +1 -0
  142. data/sdks/pkgcloud/scripts/wrapper +2 -0
  143. data/sdks/pkgcloud/scripts/wrapper.ps1 +1 -0
  144. data/sdks/pyrax/.gitignore +2 -0
  145. data/sdks/pyrax/challenges/all_connections.py +61 -0
  146. data/sdks/pyrax/challenges/authenticate_token.py +17 -0
  147. data/sdks/pyrax/challenges/cdn_enable_container.py +22 -0
  148. data/sdks/pyrax/challenges/create_a_container.py +21 -0
  149. data/sdks/pyrax/challenges/create_server.py +35 -0
  150. data/sdks/pyrax/challenges/get_object_metadata.py +17 -0
  151. data/sdks/pyrax/challenges/upload_folder.py +32 -0
  152. data/sdks/pyrax/requirements.txt +21 -0
  153. data/sdks/pyrax/scripts/bootstrap +9 -0
  154. data/sdks/pyrax/scripts/bootstrap.ps1 +7 -0
  155. data/sdks/pyrax/scripts/wrapper +3 -0
  156. data/sdks/pyrax/scripts/wrapper.ps1 +2 -0
  157. data/spec/fixtures/factorial.py +18 -0
  158. data/spec/fixtures/polytrix.yml +16 -0
  159. data/spec/fixtures/src-doc/quine.md.erb +20 -0
  160. data/spec/polytrix/challenge_builder_spec.rb +16 -0
  161. data/spec/polytrix/challenge_runner_spec.rb +14 -0
  162. data/spec/polytrix/challenge_spec.rb +20 -0
  163. data/spec/polytrix/configuration_spec.rb +10 -0
  164. data/spec/polytrix/documentation_generator_spec.rb +36 -0
  165. data/spec/polytrix/file_finder_spec.rb +24 -0
  166. data/spec/polytrix/manifest_spec.rb +26 -0
  167. data/spec/polytrix/middleware/feature_executor_spec.rb +48 -0
  168. data/spec/polytrix_spec.rb +13 -0
  169. data/spec/rspec_spec.rb +17 -0
  170. data/spec/spec_helper.rb +7 -0
  171. metadata +325 -0
@@ -0,0 +1,115 @@
1
+ /*
2
+ * Licensed to the Apache Software Foundation (ASF) under one
3
+ * or more contributor license agreements. See the NOTICE file
4
+ * distributed with this work for additional information
5
+ * regarding copyright ownership. The ASF licenses this file
6
+ * to you under the Apache License, Version 2.0 (the
7
+ * "License"); you may not use this file except in compliance
8
+ * with the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing,
13
+ * software distributed under the License is distributed on an
14
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ * KIND, either express or implied. See the License for the
16
+ * specific language governing permissions and limitations
17
+ * under the License.
18
+ */
19
+ package org.jclouds.examples.rackspace;
20
+
21
+ import java.io.Closeable;
22
+ import java.util.Properties;
23
+
24
+ import org.jclouds.ContextBuilder;
25
+ import org.jclouds.compute.ComputeService;
26
+ import org.jclouds.compute.ComputeServiceContext;
27
+ import org.jclouds.openstack.keystone.v2_0.config.CredentialTypes;
28
+ import org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties;
29
+ import org.jclouds.openstack.nova.v2_0.NovaApi;
30
+ import org.jclouds.openstack.nova.v2_0.NovaAsyncApi;
31
+ import org.jclouds.rest.RestContext;
32
+
33
+ /**
34
+ * To authenticate using jclouds you need to provide your credentials to a Context as in the init() method below.
35
+ * Authentication occurs on your first actual interaction with the Rackspace Cloud (i.e. the very first time
36
+ * you call a method that needs to talk to the cloud). Once you are authenticated you receive a token that is
37
+ * cached and you won't reauthenticate for subsequent calls. If your token expires before the JVM quits, jclouds
38
+ * will automatically handle reauthentication and get a new token for you.
39
+ *
40
+ * If authentication doesn't work, the call will result in an org.jclouds.rest.AuthorizationException
41
+ *
42
+ * This example demostrates how you would authenticate via username and password or API key. The default is
43
+ * authentication via API key, which is used in the rest of the examples in this package.
44
+ *
45
+ * @author Everett Toews
46
+ */
47
+ public class AuthenticateToken implements Closeable {
48
+ private ComputeService compute;
49
+ private RestContext<NovaApi, NovaAsyncApi> nova;
50
+
51
+ /**
52
+ * To get a username and API key see http://www.jclouds.org/documentation/quickstart/rackspace/
53
+ *
54
+ * The first argument (args[0]) must be your username
55
+ * The second argument (args[1]) must be your API key or password
56
+ * [Optional] The third argument (args[2]) must be "password" if password authentication is used,
57
+ * otherwise default to using API key.
58
+ */
59
+ public static void main(String[] args) {
60
+ AuthenticateToken authenticate = new AuthenticateToken();
61
+
62
+ try {
63
+ authenticate.init(args);
64
+ authenticate.authenticateOnCall();
65
+ }
66
+ catch (Exception e) {
67
+ e.printStackTrace();
68
+ }
69
+ finally {
70
+ authenticate.close();
71
+ }
72
+ }
73
+
74
+ private void init(String[] args) {
75
+ // The provider configures jclouds To use the Rackspace Cloud (US)
76
+ // To use the Rackspace Cloud (UK) set the provider to "rackspace-cloudservers-uk"
77
+ String provider = "rackspace-cloudservers-us";
78
+
79
+ String username = System.getenv("RAX_USERNAME");
80
+ String credential = System.getenv("RAX_API_KEY");
81
+
82
+ Properties overrides = new Properties();
83
+
84
+ if (args.length == 3 && "password".equals(args[2])) {
85
+ overrides.put(KeystoneProperties.CREDENTIAL_TYPE, CredentialTypes.PASSWORD_CREDENTIALS);
86
+ }
87
+
88
+ String endpoint = System.getenv("RAX_AUTH_URL") + "/v2.0/";
89
+ ComputeServiceContext context = ContextBuilder.newBuilder(provider)
90
+ .credentials(username, credential)
91
+ .overrides(overrides)
92
+ .endpoint(endpoint)
93
+ .buildView(ComputeServiceContext.class);
94
+ compute = context.getComputeService();
95
+ nova = context.unwrap();
96
+ }
97
+
98
+ /**
99
+ * Calling getConfiguredZones() causes jclouds to authenticate. If authentication doesn't work, the call to
100
+ * getConfiguredZones() will result in an org.jclouds.rest.AuthorizationException
101
+ */
102
+ private void authenticateOnCall() {
103
+ nova.getApi().getConfiguredZones();
104
+ System.out.println("Authenticated");
105
+ }
106
+
107
+ /**
108
+ * Always close your service when you're done with it.
109
+ */
110
+ public void close() {
111
+ if (compute != null) {
112
+ compute.getContext();
113
+ }
114
+ }
115
+ }
@@ -0,0 +1,34 @@
1
+ <project xmlns="http://maven.apache.org/POM/4.0.0"
2
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
4
+ http://maven.apache.org/xsd/maven-4.0.0.xsd">
5
+ <modelVersion>4.0.0</modelVersion>
6
+ <groupId>com.mycompany.app</groupId>
7
+ <artifactId>my-app</artifactId>
8
+ <packaging>jar</packaging>
9
+ <version>1.0-SNAPSHOT</version>
10
+ <name>Maven Quick Start Archetype</name>
11
+ <url>http://maven.apache.org</url>
12
+ <build>
13
+ <sourceDirectory>challenges</sourceDirectory>
14
+ <plugins>
15
+ <plugin>
16
+ <groupId>org.codehaus.mojo</groupId>
17
+ <artifactId>versions-maven-plugin</artifactId>
18
+ <version>2.1</version>
19
+ </plugin>
20
+ <plugin>
21
+ <groupId>org.codehaus.mojo</groupId>
22
+ <artifactId>exec-maven-plugin</artifactId>
23
+ <version>1.2.1</version>
24
+ </plugin>
25
+ </plugins>
26
+ </build>
27
+ <dependencies>
28
+ <dependency>
29
+ <groupId>org.apache.jclouds</groupId>
30
+ <artifactId>jclouds-all</artifactId>
31
+ <version>1.7.2</version>
32
+ </dependency>
33
+ </dependencies>
34
+ </project>
@@ -0,0 +1,3 @@
1
+ #!/bin/bash
2
+ mvn versions:use-latest-releases -DgenerateBackupPoms=false
3
+ mvn clean install
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ CHALLENGE_FILE=$1
3
+ CHALLENGE=`basename $CHALLENGE_FILE .java`
4
+ CLASS="org.jclouds.examples.rackspace.${CHALLENGE}"
5
+
6
+ mvn -q compile
7
+ mvn -q exec:java -Dexec.mainClass=$CLASS -e
@@ -0,0 +1,4 @@
1
+ bin/
2
+ obj/
3
+ packages/
4
+
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <configuration>
3
+ <solution>
4
+ <add key="disableSourceControlIntegration" value="true" />
5
+ </solution>
6
+ </configuration>
Binary file
@@ -0,0 +1,136 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3
+ <PropertyGroup>
4
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">$(MSBuildProjectDirectory)\..\</SolutionDir>
5
+
6
+ <!-- Enable the restore command to run before builds -->
7
+ <RestorePackages Condition=" '$(RestorePackages)' == '' ">true</RestorePackages>
8
+
9
+ <!-- Property that enables building a package from a project -->
10
+ <BuildPackage Condition=" '$(BuildPackage)' == '' ">false</BuildPackage>
11
+
12
+ <!-- Determines if package restore consent is required to restore packages -->
13
+ <RequireRestoreConsent Condition=" '$(RequireRestoreConsent)' != 'false' ">true</RequireRestoreConsent>
14
+
15
+ <!-- Download NuGet.exe if it does not already exist -->
16
+ <DownloadNuGetExe Condition=" '$(DownloadNuGetExe)' == '' ">false</DownloadNuGetExe>
17
+ </PropertyGroup>
18
+
19
+ <ItemGroup Condition=" '$(PackageSources)' == '' ">
20
+ <!-- Package sources used to restore packages. By default, registered sources under %APPDATA%\NuGet\NuGet.Config will be used -->
21
+ <!-- The official NuGet package source (https://www.nuget.org/api/v2/) will be excluded if package sources are specified and it does not appear in the list -->
22
+ <!--
23
+ <PackageSource Include="https://www.nuget.org/api/v2/" />
24
+ <PackageSource Include="https://my-nuget-source/nuget/" />
25
+ -->
26
+ </ItemGroup>
27
+
28
+ <PropertyGroup Condition=" '$(OS)' == 'Windows_NT'">
29
+ <!-- Windows specific commands -->
30
+ <NuGetToolsPath>$([System.IO.Path]::Combine($(SolutionDir), ".nuget"))</NuGetToolsPath>
31
+ <PackagesConfig>$([System.IO.Path]::Combine($(ProjectDir), "packages.config"))</PackagesConfig>
32
+ </PropertyGroup>
33
+
34
+ <PropertyGroup Condition=" '$(OS)' != 'Windows_NT'">
35
+ <!-- We need to launch nuget.exe with the mono command if we're not on windows -->
36
+ <NuGetToolsPath>$(SolutionDir).nuget</NuGetToolsPath>
37
+ <PackagesConfig>packages.config</PackagesConfig>
38
+ </PropertyGroup>
39
+
40
+ <PropertyGroup>
41
+ <!-- NuGet command -->
42
+ <NuGetExePath Condition=" '$(NuGetExePath)' == '' ">$(NuGetToolsPath)\NuGet.exe</NuGetExePath>
43
+ <PackageSources Condition=" $(PackageSources) == '' ">@(PackageSource)</PackageSources>
44
+
45
+ <NuGetCommand Condition=" '$(OS)' == 'Windows_NT'">"$(NuGetExePath)"</NuGetCommand>
46
+ <NuGetCommand Condition=" '$(OS)' != 'Windows_NT' ">mono --runtime=v4.0.30319 $(NuGetExePath)</NuGetCommand>
47
+
48
+ <PackageOutputDir Condition="$(PackageOutputDir) == ''">$(TargetDir.Trim('\\'))</PackageOutputDir>
49
+
50
+ <RequireConsentSwitch Condition=" $(RequireRestoreConsent) == 'true' ">-RequireConsent</RequireConsentSwitch>
51
+ <NonInteractiveSwitch Condition=" '$(VisualStudioVersion)' != '' AND '$(OS)' == 'Windows_NT' ">-NonInteractive</NonInteractiveSwitch>
52
+
53
+ <PaddedSolutionDir Condition=" '$(OS)' == 'Windows_NT'">"$(SolutionDir) "</PaddedSolutionDir>
54
+ <PaddedSolutionDir Condition=" '$(OS)' != 'Windows_NT' ">"$(SolutionDir)"</PaddedSolutionDir>
55
+
56
+ <!-- Commands -->
57
+ <RestoreCommand>$(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" $(NonInteractiveSwitch) $(RequireConsentSwitch) -solutionDir $(PaddedSolutionDir)</RestoreCommand>
58
+ <BuildCommand>$(NuGetCommand) pack "$(ProjectPath)" -Properties "Configuration=$(Configuration);Platform=$(Platform)" $(NonInteractiveSwitch) -OutputDirectory "$(PackageOutputDir)" -symbols</BuildCommand>
59
+
60
+ <!-- We need to ensure packages are restored prior to assembly resolve -->
61
+ <BuildDependsOn Condition="$(RestorePackages) == 'true'">
62
+ RestorePackages;
63
+ $(BuildDependsOn);
64
+ </BuildDependsOn>
65
+
66
+ <!-- Make the build depend on restore packages -->
67
+ <BuildDependsOn Condition="$(BuildPackage) == 'true'">
68
+ $(BuildDependsOn);
69
+ BuildPackage;
70
+ </BuildDependsOn>
71
+ </PropertyGroup>
72
+
73
+ <Target Name="CheckPrerequisites">
74
+ <!-- Raise an error if we're unable to locate nuget.exe -->
75
+ <Error Condition="'$(DownloadNuGetExe)' != 'true' AND !Exists('$(NuGetExePath)')" Text="Unable to locate '$(NuGetExePath)'" />
76
+ <!--
77
+ Take advantage of MsBuild's build dependency tracking to make sure that we only ever download nuget.exe once.
78
+ This effectively acts as a lock that makes sure that the download operation will only happen once and all
79
+ parallel builds will have to wait for it to complete.
80
+ -->
81
+ <MsBuild Targets="_DownloadNuGet" Projects="$(MSBuildThisFileFullPath)" Properties="Configuration=NOT_IMPORTANT;DownloadNuGetExe=$(DownloadNuGetExe)" />
82
+ </Target>
83
+
84
+ <Target Name="_DownloadNuGet">
85
+ <DownloadNuGet OutputFilename="$(NuGetExePath)" Condition=" '$(DownloadNuGetExe)' == 'true' AND !Exists('$(NuGetExePath)')" />
86
+ </Target>
87
+
88
+ <Target Name="RestorePackages" DependsOnTargets="CheckPrerequisites">
89
+ <Exec Command="$(RestoreCommand)"
90
+ Condition="'$(OS)' != 'Windows_NT' And Exists('$(PackagesConfig)')" />
91
+
92
+ <Exec Command="$(RestoreCommand)"
93
+ LogStandardErrorAsError="true"
94
+ Condition="'$(OS)' == 'Windows_NT' And Exists('$(PackagesConfig)')" />
95
+ </Target>
96
+
97
+ <Target Name="BuildPackage" DependsOnTargets="CheckPrerequisites">
98
+ <Exec Command="$(BuildCommand)"
99
+ Condition=" '$(OS)' != 'Windows_NT' " />
100
+
101
+ <Exec Command="$(BuildCommand)"
102
+ LogStandardErrorAsError="true"
103
+ Condition=" '$(OS)' == 'Windows_NT' " />
104
+ </Target>
105
+
106
+ <UsingTask TaskName="DownloadNuGet" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
107
+ <ParameterGroup>
108
+ <OutputFilename ParameterType="System.String" Required="true" />
109
+ </ParameterGroup>
110
+ <Task>
111
+ <Reference Include="System.Core" />
112
+ <Using Namespace="System" />
113
+ <Using Namespace="System.IO" />
114
+ <Using Namespace="System.Net" />
115
+ <Using Namespace="Microsoft.Build.Framework" />
116
+ <Using Namespace="Microsoft.Build.Utilities" />
117
+ <Code Type="Fragment" Language="cs">
118
+ <![CDATA[
119
+ try {
120
+ OutputFilename = Path.GetFullPath(OutputFilename);
121
+
122
+ Log.LogMessage("Downloading latest version of NuGet.exe...");
123
+ WebClient webClient = new WebClient();
124
+ webClient.DownloadFile("https://www.nuget.org/nuget.exe", OutputFilename);
125
+
126
+ return true;
127
+ }
128
+ catch (Exception ex) {
129
+ Log.LogErrorFromException(ex);
130
+ return false;
131
+ }
132
+ ]]>
133
+ </Code>
134
+ </Task>
135
+ </UsingTask>
136
+ </Project>
@@ -0,0 +1,10 @@
1
+ using System;
2
+
3
+ namespace openstack.net
4
+ {
5
+ public interface Challenge
6
+ {
7
+ int Run (string[] args);
8
+ }
9
+ }
10
+
@@ -0,0 +1,19 @@
1
+ using System;
2
+ using System.IO;
3
+
4
+ namespace openstack.net
5
+ {
6
+ public class RunChallenge
7
+ {
8
+ public static void Main (string[] args)
9
+ {
10
+ // Pacto cannot currently validate 100-Continue responses. See https://github.com/thoughtworks/pacto/issues/87
11
+ System.Net.ServicePointManager.Expect100Continue = false;
12
+ var challenge = Path.GetFileNameWithoutExtension(args[0]);
13
+ var challenge_class = Type.GetType("openstack.net." + challenge);
14
+ var challenge_object = Activator.CreateInstance(challenge_class) as Challenge;
15
+ challenge_object.Run(args);
16
+ }
17
+ }
18
+ }
19
+
@@ -0,0 +1,24 @@
1
+ using System;
2
+ using net.openstack.Providers.Rackspace;
3
+ using net.openstack.Core.Providers;
4
+ using net.openstack.Core.Exceptions.Response;
5
+ using net.openstack.Providers.Rackspace.Objects;
6
+
7
+ namespace openstack.net
8
+ {
9
+ class AuthenticateToken : Challenge
10
+ {
11
+ public int Run (string[] args)
12
+ {
13
+ var auth_url = new Uri(Environment.GetEnvironmentVariable ("RAX_AUTH_URL"));
14
+ Console.WriteLine ("Connecting to " + auth_url);
15
+ IIdentityProvider identityProvider = new CloudIdentityProvider (null, null, null, auth_url);
16
+ identityProvider.Authenticate (new RackspaceCloudIdentity {
17
+ Username = Environment.GetEnvironmentVariable("RAX_USERNAME"),
18
+ APIKey = Environment.GetEnvironmentVariable("RAX_API_KEY")
19
+ });
20
+ Console.WriteLine ("Authenticated!");
21
+ return 0;
22
+ }
23
+ }
24
+ }
@@ -0,0 +1,133 @@
1
+ using System;
2
+ using System.IO;
3
+ using System.Text;
4
+ using System.Net;
5
+ using System.Collections;
6
+ using System.Collections.Generic;
7
+ using System.Reflection;
8
+ using net.openstack.Core.Domain;
9
+ using net.openstack.Core.Providers;
10
+ using net.openstack.Providers.Rackspace;
11
+ using net.openstack.Providers.Rackspace.Objects;
12
+ using HttpMethod = JSIStudios.SimpleRESTServices.Client.HttpMethod;
13
+
14
+ namespace openstack.net
15
+ {
16
+ class Weird : Challenge
17
+ {
18
+ public int Run (string[] args)
19
+ {
20
+ var auth_url = new Uri(Environment.GetEnvironmentVariable ("RAX_AUTH_URL"));
21
+ Console.WriteLine ("Connecting to " + auth_url);
22
+ CloudIdentity identity = new RackspaceCloudIdentity {
23
+ Username = Environment.GetEnvironmentVariable("RAX_USERNAME"),
24
+ APIKey = Environment.GetEnvironmentVariable("RAX_API_KEY")
25
+ };
26
+ // IIdentityProvider identityProvider = new CloudIdentityProvider (identity, auth_url);
27
+ IIdentityProvider identityProvider = new CloudIdentityProvider (identity);
28
+ // IObjectStorageProvider provider = new CloudBlockStorageProvider(testIdentity, "dfw", identityProvider, null);
29
+ IObjectStorageProvider provider = new CloudFilesProvider(identityProvider);
30
+ TestProtocolViolation(provider);
31
+ Console.WriteLine ("Testing!");
32
+ return 0;
33
+ }
34
+
35
+ public void TestProtocolViolation(IObjectStorageProvider provider)
36
+ {
37
+ try
38
+ {
39
+ TestTempUrlWithSpecialCharactersInObjectName(provider);
40
+ }
41
+ catch (WebException ex)
42
+ {
43
+ /* ServicePoint servicePoint = ServicePointManager.FindServicePoint(ex.Response.ResponseUri);
44
+ FieldInfo table = typeof(ServicePointManager).GetField("s_ServicePointTable", BindingFlags.Static | BindingFlags.NonPublic);
45
+ WeakReference weakReference = (WeakReference)((Hashtable)table.GetValue(null))[servicePoint.Address.GetLeftPart(UriPartial.Authority)];
46
+ if (weakReference != null)
47
+ weakReference.Target = null; */
48
+ }
49
+
50
+ TestTempUrlExpired(provider);
51
+ }
52
+
53
+ public void TestTempUrlExpired(IObjectStorageProvider provider)
54
+ {
55
+ string TestContainerPrefix = "sambug";
56
+
57
+ string containerName = TestContainerPrefix + Path.GetRandomFileName();
58
+ string objectName = Path.GetRandomFileName();
59
+ string fileContents = "File contents!";
60
+
61
+ Dictionary<string, string> accountMetadata = provider.GetAccountMetaData();
62
+ string tempUrlKey;
63
+ if (!accountMetadata.TryGetValue("Temp-Url-Key", out tempUrlKey))
64
+ {
65
+ tempUrlKey = Guid.NewGuid().ToString("N");
66
+ accountMetadata = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
67
+ accountMetadata["Temp-Url-Key"] = tempUrlKey;
68
+ provider.UpdateAccountMetadata(accountMetadata);
69
+ }
70
+
71
+ ObjectStore result = provider.CreateContainer(containerName);
72
+
73
+ Stream stream = new MemoryStream(Encoding.UTF8.GetBytes(fileContents));
74
+ provider.CreateObject(containerName, stream, objectName);
75
+
76
+ // verify a past time does not work
77
+ try
78
+ {
79
+ DateTimeOffset expirationTime = DateTimeOffset.Now - TimeSpan.FromSeconds(3);
80
+ Uri uri = ((CloudFilesProvider)provider).CreateTemporaryPublicUri(HttpMethod.GET, containerName, objectName, tempUrlKey, expirationTime);
81
+ WebRequest request = HttpWebRequest.Create(uri);
82
+ using (WebResponse response = request.GetResponse())
83
+ {
84
+ Stream cdnStream = response.GetResponseStream();
85
+ StreamReader reader = new StreamReader(cdnStream, Encoding.UTF8);
86
+ string text = reader.ReadToEnd();
87
+ }
88
+ }
89
+ catch (WebException ex)
90
+ {
91
+ // Assert.AreEqual(HttpStatusCode.Unauthorized, ((HttpWebResponse)ex.Response).StatusCode);
92
+ }
93
+
94
+ provider.DeleteContainer(containerName, deleteObjects: true);
95
+ }
96
+
97
+ public void TestTempUrlWithSpecialCharactersInObjectName(IObjectStorageProvider provider)
98
+ {
99
+ string TestContainerPrefix = "sambug";
100
+ string containerName = TestContainerPrefix + Path.GetRandomFileName();
101
+ string objectName = "§ /\n\r 你好";
102
+ string fileContents = "File contents!";
103
+
104
+ Dictionary<string, string> accountMetadata = provider.GetAccountMetaData();
105
+ string tempUrlKey;
106
+ if (!accountMetadata.TryGetValue("Temp-Url-Key", out tempUrlKey))
107
+ {
108
+ tempUrlKey = Guid.NewGuid().ToString("N");
109
+ accountMetadata = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
110
+ accountMetadata["Temp-Url-Key"] = tempUrlKey;
111
+ provider.UpdateAccountMetadata(accountMetadata);
112
+ }
113
+
114
+ ObjectStore result = provider.CreateContainer(containerName);
115
+
116
+ Stream stream = new MemoryStream(Encoding.UTF8.GetBytes(fileContents));
117
+ provider.CreateObject(containerName, stream, objectName);
118
+
119
+ // verify a future time works
120
+ DateTimeOffset expirationTime = DateTimeOffset.Now + TimeSpan.FromSeconds(10);
121
+ Uri uri = ((CloudFilesProvider)provider).CreateTemporaryPublicUri(HttpMethod.GET, containerName, objectName, tempUrlKey, expirationTime);
122
+ WebRequest request = HttpWebRequest.Create(uri);
123
+ using (WebResponse response = request.GetResponse())
124
+ {
125
+ Stream cdnStream = response.GetResponseStream();
126
+ StreamReader reader = new StreamReader(cdnStream, Encoding.UTF8);
127
+ string text = reader.ReadToEnd();
128
+ }
129
+
130
+ provider.DeleteContainer(containerName, deleteObjects: true);
131
+ }
132
+ }
133
+ }
@@ -0,0 +1,58 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3
+ <PropertyGroup>
4
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5
+ <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
6
+ <ProductVersion>10.0.0</ProductVersion>
7
+ <SchemaVersion>2.0</SchemaVersion>
8
+ <ProjectGuid>{391B73DA-3906-4A09-9F92-A4196BB00ECF}</ProjectGuid>
9
+ <OutputType>Exe</OutputType>
10
+ <RootNamespace>openstack.net</RootNamespace>
11
+ <AssemblyName>openstack.net</AssemblyName>
12
+ </PropertyGroup>
13
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
14
+ <DebugSymbols>true</DebugSymbols>
15
+ <DebugType>full</DebugType>
16
+ <Optimize>false</Optimize>
17
+ <OutputPath>bin\Debug</OutputPath>
18
+ <DefineConstants>DEBUG;</DefineConstants>
19
+ <ErrorReport>prompt</ErrorReport>
20
+ <WarningLevel>4</WarningLevel>
21
+ <Externalconsole>true</Externalconsole>
22
+ <PlatformTarget>x86</PlatformTarget>
23
+ </PropertyGroup>
24
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
25
+ <DebugType>full</DebugType>
26
+ <Optimize>true</Optimize>
27
+ <OutputPath>bin\Release</OutputPath>
28
+ <ErrorReport>prompt</ErrorReport>
29
+ <WarningLevel>4</WarningLevel>
30
+ <Externalconsole>true</Externalconsole>
31
+ <PlatformTarget>x86</PlatformTarget>
32
+ </PropertyGroup>
33
+ <ItemGroup>
34
+ <Reference Include="System" />
35
+ <Reference Include="Newtonsoft.Json">
36
+ <HintPath>packages\Newtonsoft.Json.5.0.8\lib\net40\Newtonsoft.Json.dll</HintPath>
37
+ </Reference>
38
+ <Reference Include="SimpleRESTServices">
39
+ <HintPath>packages\SimpleRESTServices.1.3.0.1\lib\net40\SimpleRESTServices.dll</HintPath>
40
+ </Reference>
41
+ <Reference Include="openstacknet">
42
+ <HintPath>packages\openstack.net.1.3.2.1\lib\net40\openstacknet.dll</HintPath>
43
+ </Reference>
44
+ </ItemGroup>
45
+ <ItemGroup>
46
+ <Compile Include="challenges\*.cs" />
47
+ <Compile Include="Challenge.cs" />
48
+ <Compile Include="RunChallenge.cs" />
49
+ </ItemGroup>
50
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
51
+ <Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
52
+ <ItemGroup>
53
+ <None Include="packages.config" />
54
+ </ItemGroup>
55
+ <ItemGroup>
56
+ <Folder Include="challenges\" />
57
+ </ItemGroup>
58
+ </Project>
@@ -0,0 +1,27 @@
1
+ 
2
+ Microsoft Visual Studio Solution File, Format Version 11.00
3
+ # Visual Studio 2010
4
+ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "openstack.net", "openstack.net.csproj", "{391B73DA-3906-4A09-9F92-A4196BB00ECF}"
5
+ EndProject
6
+ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{E9E4006E-EA17-47D4-AC7F-B092E8994661}"
7
+ ProjectSection(SolutionItems) = preProject
8
+ .nuget\NuGet.Config = .nuget\NuGet.Config
9
+ .nuget\NuGet.exe = .nuget\NuGet.exe
10
+ .nuget\NuGet.targets = .nuget\NuGet.targets
11
+ EndProjectSection
12
+ EndProject
13
+ Global
14
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
15
+ Debug|x86 = Debug|x86
16
+ Release|x86 = Release|x86
17
+ EndGlobalSection
18
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
19
+ {391B73DA-3906-4A09-9F92-A4196BB00ECF}.Debug|x86.ActiveCfg = Debug|x86
20
+ {391B73DA-3906-4A09-9F92-A4196BB00ECF}.Debug|x86.Build.0 = Debug|x86
21
+ {391B73DA-3906-4A09-9F92-A4196BB00ECF}.Release|x86.ActiveCfg = Release|x86
22
+ {391B73DA-3906-4A09-9F92-A4196BB00ECF}.Release|x86.Build.0 = Release|x86
23
+ EndGlobalSection
24
+ GlobalSection(MonoDevelopProperties) = preSolution
25
+ StartupItem = openstack.net.csproj
26
+ EndGlobalSection
27
+ EndGlobal
@@ -0,0 +1,8 @@
1
+ <Properties>
2
+ <MonoDevelop.Ide.Workspace ActiveConfiguration="Debug|x86" />
3
+ <MonoDevelop.Ide.Workbench />
4
+ <MonoDevelop.Ide.DebuggingService.Breakpoints>
5
+ <BreakpointStore />
6
+ </MonoDevelop.Ide.DebuggingService.Breakpoints>
7
+ <MonoDevelop.Ide.DebuggingService.PinnedWatches />
8
+ </Properties>
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <packages>
3
+ <package id="Newtonsoft.Json" version="5.0.8" targetFramework="net40" />
4
+ <package id="openstack.net" version="1.3.2.1" targetFramework="net40" />
5
+ <package id="SimpleRESTServices" version="1.3.0.1" targetFramework="net40" />
6
+ </packages>
@@ -0,0 +1,2 @@
1
+ #!/bin/bash
2
+ xbuild
@@ -0,0 +1,2 @@
1
+ # Need a better way to install so it's on the path
2
+ C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe openstack.net.sln
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+
3
+ # Might need to build again...
4
+ # xbuild
5
+ #
6
+
7
+ mono --debug bin/Debug/openstack.net.exe "$@"
@@ -0,0 +1 @@
1
+ .\bin\Debug\openstack.net.exe "$args"
@@ -0,0 +1,4 @@
1
+ composer.phar
2
+ composer.lock
3
+ vendor/
4
+ installer