Esempio n. 1
0
    def test_responses(self):
        tm = TM("my test tm", description="aa", isOrdered=True)

        user = Actor("User")
        web = Server("Web Server")
        db = Datastore("SQL Database")

        http_req = Dataflow(user, web, "http req")
        insert = Dataflow(web, db, "insert data")
        query = Dataflow(web, db, "query")
        query_resp = Dataflow(db, web, "query results", responseTo=query)
        http_resp = Dataflow(web, user, "http resp")
        http_resp.responseTo = http_req

        self.assertTrue(tm.check())

        self.assertEqual(http_req.response, http_resp)
        self.assertIs(http_resp.isResponse, True)

        self.assertIs(query_resp.isResponse, True)
        self.assertEqual(query_resp.responseTo, query)
        self.assertEqual(query.response, query_resp)

        self.assertIsNone(insert.response)
        self.assertIs(insert.isResponse, False)
Esempio n. 2
0
user_to_web.protocol = "HTTP"
user_to_web.dstPort = 80
user_to_web.data = 'Comments in HTML or Markdown'
user_to_web.note = "This is a simple web app\nthat stores and retrieves user comments."

web_to_db = Dataflow(web, db, "Insert query with comments")
web_to_db.protocol = "MySQL"
web_to_db.dstPort = 3306
web_to_db.data = 'MySQL insert statement, all literals'
web_to_db.note = "Web server inserts user comments\ninto it's SQL query and stores them in the DB."

db_to_web = Dataflow(db, web, "Retrieve comments")
db_to_web.protocol = "MySQL"
db_to_web.dstPort = 80
db_to_web.data = 'Web server retrieves comments from DB'
db_to_web.responseTo = web_to_db

web_to_user = Dataflow(web, user, "Show comments (*)")
web_to_user.protocol = "HTTP"
web_to_user.data = 'Web server shows comments to the end user'
web_to_user.responseTo = user_to_web

my_lambda_to_db = Dataflow(my_lambda, db, "Lambda periodically cleans DB")
my_lambda_to_db.protocol = "MySQL"
my_lambda_to_db.dstPort = 3306
my_lambda_to_db.data = "Lamda clears DB every 6 hours"



if __name__ == "__main__":
    tm.process(dfd=True)
Esempio n. 3
0
aws_services = [s3_bucket]
for service in aws_services:
    service.inBoundary = aws

mongo_services = [identity_db, token_blacklist_db, resources_db]
for service in mongo_services:
    service.inBoundary = mongo_atlas
sendgrid.inBoundary = external_services
#TODO
# aws.inBoundary = external_services
# mongo_atlas.inBoundary = external_services

# Dataflows
user_browser = Dataflow(web_user, browser, "User Accesing Webapp")
browser_user = Dataflow(browser, web_user, "Responses to user")
browser_user.responseTo = user_browser

browser_webserver = Dataflow(browser, react_webapp, "User Accesing Webapp")
webserver_browser = Dataflow(react_webapp, browser, "Responses to user")
webserver_browser.responseTo = browser_webserver

for entity in [browser, mobile_client, direct_api]:
    to_webserver = Dataflow(entity, nginx_backend_server,
                            "{} acessing api".format(entity.name))
    from_webserver = Dataflow(nginx_backend_server, entity,
                              "Responses to {}".format(entity.name))
    from_webserver.responseTo = to_webserver

# web_user
# administrator
# mobile_client