Skip to content
Snippets Groups Projects
HTTP.tdltx 3.86 KiB
Newer Older
Package HTTP { 
	Package MessageBasedConfiguration {
        Import all from MessageBased
        Message Gate HTTPGate accepts Request,Response
        Component API {
            //Add variables and timers here or define new component types and configurations 
            gate HTTPGate http
        }
        Configuration BasicClientServer {
            API client as Tester,
            API server as SUT,
            connect client::http to server::http
        }
    
	} Note : "Message based types and instances"
	
	Package MessageBased {
        Import all from Standard
        
        //Generic Method type -> required for generation!!!
        Enumerated Method {
	        Method GET,
	        Method POST,
	        Method PUT,
	        Method PATCH,
	        Method DELETE
        }

        //Generic Request type    
        Structure Request (
            String uri,
            optional Method method,
            optional Headers headers,
            optional Parameters parameters,
            optional Body body
        )
        
        //Generic Request instances
        Request rGET (method = GET)
        Request rPOST (method = POST)
        Request PUT (method = PUT)
        Request PATCH (method = PATCH)
        Request DELETE (method = DELETE)
        
        //Generic Response type    
        Structure Response (
            optional Integer status,
            optional String statusMessage,
            optional Headers headers,
            optional Body body
        )
        
        //Generic Response instances, name = status code
        
        Response r200 (statusMessage = "OK")
        Response r201 (statusMessage = "Created")
        Response r204 (statusMessage = "No Content")
        Response r400 (statusMessage = "Bad Request")
        Response r401 (statusMessage = "Not Found")
        Response r403 (statusMessage = "Not Authorized")
        Response r404 (statusMessage = "Forbidden")

        //Generic Response instances, name = status message        
        Response OK (status = "200")
        Response Created (status = "201")
        Response NoContent (status = "204")
        Response BadRequest (status = "400")
        Response NotFound (status = "404")
        Response NotAuthorized (status = "401")
        Response Forbidden (status = "403")
        
        //supporting types
        Collection Parameters of Parameter
        Structure Parameter (
            Location location,
            String ^name,
            String ^value
        )
        Type Location
        Location path
        Location query

        //may need a structure, not necessarily relevant in standardized testing
        Location cookie
        
        //separate headers -> not necessary
        //Location header;
        Collection Headers of Header
        Structure Header (
            String ^name,
            String ^value
            //not relevant in TDL? 
            //optional contentLength of type Integer,
            //optional contentType of type String 
        )
        
        //Base body for extension
        Structure Body ( )
        
        //Basic string body
        Structure StringBody extends Body (
            String text
        )
        
        //Basic wrapper for collection responses
        Structure CollectionBody extends Body (
            Bodies items
        )
        
        //Any body can be included
        //If consistent type is needed, a custom subtype shall be defined and used 
        Collection Bodies of Body
        
        //Custom collection data instances can be defined
        //  - inline in the responses 
        //  - predefined as a separate data element
        //Custom collection data instances can be defined 
        //to enforce type consistency specific for API 
    
        //Basic form body    
        Structure FormBody extends Body (
            String field,
            String content
        )
    } 
}