Last active
December 28, 2015 04:49
-
-
Save distributedlife/7445603 to your computer and use it in GitHub Desktop.
distributedlife.com blog posts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <services> | |
| <service name="My.Service.Name"> | |
| <endpoint name="Endpoint One"> | |
| <operation name="GetAwesomePeople"> | |
| <aspect name="Input Validation" start="22/03/2010 - 2:02:17" finish="22/03/2010 - 2:02:23"> | |
| <case name="Name not supplied" start="22/03/2010 - 2:02:18" finish="22/03/2010 - 2:02:20" result="failed" /> | |
| <case name="Name is larger than db value" start="22/03/2010 - 2:02:20" finish="22/03/2010 - 2:02:20" result="passed" /> | |
| <case name="Name is one char" start="22/03/2010 - 2:02:20" finish="22/03/2010 - 2:02:21" result="passed" /> | |
| <case name="Awesome person does not exist" start="22/03/2010 - 2:02:21" finish="22/03/2010 - 2:02:22" result="failed" /> | |
| </aspect> | |
| </operation> | |
| </endpoint> | |
| </service> | |
| </services> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| enum EnabledOptions FileIsEmpty (const char* const Filename) | |
| { | |
| const unsigned int SEEK_END = 2 ; | |
| long FileHandle = 0 ; | |
| enum EnabledOptions ReturnValue = Yes; | |
| FileHandle = fopen (Filename, "rb" ); | |
| if (!FileHandle) | |
| { | |
| lr_error_message ("Failed to open the file \"%s\"", Filename) ; | |
| return Yes; | |
| } | |
| fseek (FileHandle , 0 , SEEK_END); | |
| if (ftell (FileHandle) != 0) | |
| { | |
| ReturnValue = No ; | |
| } | |
| fclose (FileHandle) ; | |
| return ReturnValue ; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void ReadFileUTF8 (const char* const Filename, const char* TargetParameter) | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const unsigned int SEEK_END = 2 ; | |
| long FileHandle = 0 ; | |
| long FileSizeInBytes = 0 ; | |
| char * DataBuffer = 0; | |
| int shifted = 0 ; | |
| size_t result = 0; | |
| long index = 0 ; | |
| //Set our TargetParameter to Failed incase we don't make it | |
| lr_set("FAILED", TargetParameter); | |
| FileHandle = fopen (Filename, "rb" ); | |
| if (!FileHandle) | |
| { | |
| lr_error_message ("Failed to open the file \"%s\"", Filename) ; | |
| return ; | |
| } | |
| //Get the file size. We use this to allocate our data buffer. | |
| fseek (FileHandle , 0 , SEEK_END); | |
| FileSizeInBytes = ftell (FileHandle); | |
| rewind (FileHandle); | |
| // allocate memory to contain the whole file | |
| DataBuffer = (char*) malloc ((sizeof(char) * FileSizeInBytes) + 1) ; | |
| if (!DataBuffer) | |
| { | |
| lr_error_message ("Could not allocate memory for buffer") ; | |
| return ; | |
| } | |
| // copy the file into the DataBuffer: | |
| result = fread (DataBuffer, sizeof(char), FileSizeInBytes, FileHandle) ; | |
| if (result != FileSizeInBytes) | |
| { | |
| lr_error_message ("Could not copy file data into buffer") ; | |
| if (DataBuffer) | |
| { | |
| free (DataBuffer) ; | |
| } | |
| } | |
| //add null-terminating char | |
| DataBuffer[FileSizeInBytes] = '\0' ; | |
| //Skip BOM (if there is one) | |
| if (DataBuffer[0] == '\xff' && DataBuffer[1] == '\xfe') | |
| { | |
| DataBuffer++ ; | |
| DataBuffer++ ; | |
| shifted = 1 ; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| lr_set (DataBuffer, TargetParameter); | |
| //Move back to start of string before freeing memory | |
| if (shifted == 1) | |
| { | |
| DataBuffer-- ; | |
| DataBuffer-- ; | |
| } | |
| fclose (FileHandle) ; | |
| free (DataBuffer) ; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ExecuteTestAsUser (MyServiceUser) ; | |
| SetDefaultParameters () ; | |
| CallService () ; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| GrantSuperUserToUser (MyServiceUser); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| enum UserScenarios | |
| { | |
| DoNotSetSecurity, | |
| MyService1, | |
| MyService2 | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| char* usernames[] = | |
| { | |
| "User001", | |
| "User002" | |
| } | |
| char* passwords[] = | |
| { | |
| "PASSWORD", | |
| "PASSWORD" | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if (OutstandingDefectExists (411, Functionality)) | |
| { | |
| return 0 ; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| enum EnabledOptions Defects[] = | |
| { | |
| /* 1*/ No, | |
| /* 2*/ Yes, | |
| /* 3*/ Yes, | |
| /* 4*/ Yes, | |
| ... | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| EnableCheckForExceptions (No) ; | |
| EnableCheckForAuditEvents (No) ; | |
| EnableCheckForDataPersistence (No) ; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void EnableCheckForAuditEvents (enum EnabledOptions AuditValidationEnabled) | |
| { | |
| lr_save_int (AuditValidationEnabled, "__AuditValidationEnabled") ; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| enum EnabledOptions AuditingEnabled (void) | |
| { | |
| if (StringsAreEqual (lr_get ("{__AuditValidationEnabled}"), "1")) | |
| { | |
| return Yes; | |
| } | |
| else | |
| { | |
| return No ; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void CheckAuditRecord (void) | |
| { | |
| if (!AuditingEnabled ()) | |
| { | |
| return ; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| //Non-repudiation (auditing) | |
| { | |
| ExpectAuditRecord () ; | |
| } | |
| } | |
| //Execute the test | |
| { | |
| ExecuteTestAsUser (DemoServiceUser) ; | |
| SetDefaultParameters () ; | |
| CallService () ; | |
| } | |
| //Non-repudiation (auditing) | |
| { | |
| CheckAuditRecord () ; | |
| ValidateAuditRecord (Success, "DemoServiceUser called operation Create User") ; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| enum EnabledOptions FileExists (const char* const Filename) | |
| { | |
| long FileHandle = 0 ; | |
| if (FileHandle = fopen (Filename, "r")) | |
| { | |
| fclose (FileHandle) ; | |
| return Yes ; | |
| } | |
| return No ; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment