Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Helper files for performing a rough validation of the functionality of the Duplicati CloudFiles backend without depending on having an actual Rackspace account. Import the AutoResponder Rules and add the Fiddlerscript rules to your Fiddler Rules file in the Handler class.
<?xml version="1.0" encoding="utf-8"?>
<AutoResponder LastSave="2020-01-06T22:02:18.2787399-08:00" FiddlerVersion="5.0.20194.41348">
<State Enabled="true" Fallthrough="true" UseLatency="false">
<ResponseGroup Id="06245c5d-eff4-474e-a452-62d3f99a6bd3" Header="CloudFilesTest" />
<ResponseRule GroupId="06245c5d-eff4-474e-a452-62d3f99a6bd3" Match="https://identity.api.rackspacecloud.com/auth" Action="NEW_RESPONSE_16_49_04" Enabled="true" Headers="SFRUUC8xLjEgMjAwIEdlbmVyYXRlZA0KQ29udGVudC1MZW5ndGg6IDANCkNvbnRlbnQtVHlwZTogdGV4dC9wbGFpbjsgY2hhcnNldD11dGYtOA0KWC1TdG9yYWdlLVVybDogaHR0cHM6Ly9pZGVudGl0eS5hcGkucmFja3NwYWNlY2xvdWQuY29tL2ZpbGVzLw0KWC1BdXRoLVRva2VuOiBUb2tlbkFCQzEyMw0KDQo=" />
<ResponseRule GroupId="06245c5d-eff4-474e-a452-62d3f99a6bd3" Match="method:GET https://identity.api.rackspacecloud.com/files/folder/?format=xml" Action="NEW_RESPONSE_16_54_53" Enabled="true" Headers="SFRUUC8xLjEgMjAwIEdlbmVyYXRlZA0KQ29udGVudC1MZW5ndGg6IDQzOA0KQ29udGVudC1UeXBlOiB0ZXh0L3BsYWluOyBjaGFyc2V0PXV0Zi04DQoNCg==" Body="PGNvbnRhaW5lcj4KICA8b2JqZWN0PgogICAgPG5hbWU+aXRlbTE8L25hbWU+CiAgICA8Ynl0ZXM+MTAwPC9ieXRlcz4KICAgIDxsYXN0X21vZGlmaWVkPjIwMjAtMDEtMDFUMjM6MjI6MjIuMDQzNjg2NS0wODowMDwvbGFzdF9tb2RpZmllZD4KICA8L29iamVjdD4KICA8b2JqZWN0PgogICAgPG5hbWU+aXRlbTI8L25hbWU+CiAgICA8Ynl0ZXM+MjAwPC9ieXRlcz4KICAgIDxsYXN0X21vZGlmaWVkPjIwMjAtMDEtMDJUMjM6MjI6MjIuMDQzNjg2NS0wODowMDwvbGFzdF9tb2RpZmllZD4KICA8L29iamVjdD4KICA8b2JqZWN0PgogICAgPG5hbWU+aXRlbTM8L25hbWU+CiAgICA8Ynl0ZXM+MzAwPC9ieXRlcz4KICAgIDxsYXN0X21vZGlmaWVkPjIwMjAtMDEtMDNUMjM6MjI6MjIuMDQzNjg2NS0wODowMDwvbGFzdF9tb2RpZmllZD4KICA8L29iamVjdD4KPC9jb250YWluZXI+" />
<ResponseRule GroupId="06245c5d-eff4-474e-a452-62d3f99a6bd3" Match="method:DELETE https://identity.api.rackspacecloud.com/files/folder/" Action="204_NoContent.dat" Enabled="true" />
<ResponseRule GroupId="06245c5d-eff4-474e-a452-62d3f99a6bd3" Match="method:PUT https://identity.api.rackspacecloud.com/files/folder/" Action="*script:RackspacePutFile" Enabled="true" />
<ResponseRule GroupId="06245c5d-eff4-474e-a452-62d3f99a6bd3" Match="method:GET https://identity.api.rackspacecloud.com/files/folder/" Action="NEW_RESPONSE_16_54_53" Enabled="true" Headers="SFRUUC8xLjEgMjAwIEdlbmVyYXRlZA0KQ29udGVudC1MZW5ndGg6IDE4MDUNCkNvbnRlbnQtVHlwZTogdGV4dC9wbGFpbjsgY2hhcnNldD11dGYtOA0KDQo=" Body="NzAxDQpJr+npF+agV6QncQRVrq6ItCRs3AwezG6mGHeuPnzmqRLS5M6uDMxYzaDZLqPxXoS0NT8pmy6oKuN7Q/9u8hkoQMjygsrf2adYFA5rRZ3LtLry+Qk8vA7jKrnrM8nM6duHse7a/tu61VuX0YcgPeVFsI5Ee/gQ64S5D1gR9Kbeiyoy45Sv8LbfOCStpOuHwu3TpoM6iG3id8VpIO+DqeG1uUVc7llRlr/YZUPUYkeYMkxrPU4ipAO8T2zORc/HW45C9+ulKtSTgQ/D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xBm2vt0Q+ZY32SLW33WvbMbJvFZT3KR6HkNXAzz7YtZGzGAcREfXJYLOR8LFdFjL3PD+igVxz+dlTJCJyeZZTHZMgBMFkyh+4obThZThpJnqiyY7/NjA1Px4tvenTWucZPtMeOQ1tknIj5eOrjpSc6gGrz7ALV+di7smnNww16UrNyCplSulpNTcc31BQjayJjNfoK4szEebrv05Hyl9h6fyU2cZuO58UPpp86niXDl0ZGaY4Sb2/mrZDeYufJWrXuvFTu7PmH1U01+jwtiduVKztKqy1KaA+2UMMKsITeRkvpTOLR1KtNv5RA3XQzuSS0STarfq+Io1NFOJw2fCXIV7TxQz35w1eQ/eyYCouagpafVmZNMsebYaiOjJwOFkJvd4bAQnXmu4XfG4HD75nIqrUFlia+eiTsVeKUaje6geapKZIE2kAhuJrhbhdG2HIPxeHmCIAcsf1h0+2TUVBNJJmaGsUGw9B15N2L3QwNpXxvhaVW1HlmjHiVowZTjmZKk0l9rL6sCAEQcSSikdPwUy1wI8yr9lAgNI1NcSDKIVZ2QEnDj/m+w3yjRWNVw/qkpFDY42uan5z5XXcwX5fhRk/NK1CKLcM0sl9PB7HsynCTqczP8T7r3KGsyTGBjWTlwf8Uh5epGneMpDALSpfrDJIGnbXKEVQR4k+v3WORsiT7akWy2EPZ6Y9VQ00N35EJwb2feu+uGq+qA6RI+jwT+vIMEOBROTRPLbQmdc4HAwO9pRym8jc0TFCWB9Wfke5SQUhaAc+xt4eIT007h6Thov+gilQgbQe718OPuzFfr5zF1DSFrAIzDO6UHaLp+cWrtWXV/gaaMtNBnykMIfxVKaCwdrNwW/X8bX1mi1Bk0d795AbMibGVKqJgRA3ZJ+rxPvMCOIIROllv2JGJNKaD3M5KDjz1iaDuG0sQEBfoI0WSdE1cYphb66msXbAfDPb83Wg/jhmu+7VTEx03ASpChrVM9r9YJnk17iKTSSvvzg5UFDOuqZQr5HiYCU56JOp/atb70xY2ow0KMA0KDQo=" />
</State>
</AutoResponder>
public static function RackspacePutFile(oS: Session)
{
var ms : System.IO.MemoryStream = new System.IO.MemoryStream(System.Text.Encoding.UTF8.GetBytes(""));
oS.LoadResponseFromStream(ms, null);
oS.responseCode = 202;
oS.oResponse.headers.Add("ETag", "\"" + ComputeHash(oS.requestBodyBytes) + "\"");
}
public static function ComputeHash(bytes: Byte[])
{
var sizeStart: int = 0;
var index : int = 0;
var hash: System.Security.Cryptography.MD5 = System.Security.Cryptography.MD5.Create();
while(true)
{
if(index >= bytes.Length) break;
if(bytes[index] == 0x0D && bytes[index+1] == 0x0A)
{
var sizeString = System.Text.Encoding.ASCII.GetString(bytes, sizeStart, index - sizeStart);
var size = Int32.Parse(sizeString, System.Globalization.NumberStyles.HexNumber);
if(size == 0)
{
break;
}
hash.TransformBlock(bytes, index + 2, size, bytes, index + 2);
sizeStart = index = index + 2 + size + 2;
}
index++;
}
hash.TransformFinalBlock(bytes, 0, 0);
return BitConverter.ToString(hash.Hash).Replace("-", "");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment