OWASP / Maturity-Models

Node application to help managing Maturity Models like the ones created by BSIMM and OpenSAMM
Apache License 2.0
187 stars 51 forks source link

View team is loading schema 3 times #140

Closed DinisCruz closed 8 years ago

DinisCruz commented 8 years ago

This is caused by the use of the activity-table directive 3 times

Test that proves it

  it 'Issues 140 - View team is loading schema 3 times', ->
    project       = 'bsimm'
    team          = 'aaaaaa-bbb'
    options =
      url_Location    : "/view/#{project}/#{team}/table"
      url_Template_Key: 'pages/.page.html'

    inject ($injector)->
      $injector.get('Render_View')(options)
               .set_Expect_Get "/api/v1/data/#{project}/#{team}/score", {}
               .set_Expect_Get "/api/v1/data/#{project}/#{team}/score", {}
               .set_Expect_Get "/api/v1/data/#{project}/#{team}/score", {}
               .set_Expect_Get "/api/v1/team/#{project}/get/#{team}"  , {}
               .set_Expect_Get "/api/v1/team/#{project}/get/#{team}"  , {}
               .set_Expect_Get "/api/v1/team/#{project}/get/#{team}"  , {}
               .run()
               .html.assert_Contains('<div id="teamMenu">')

image

image

DinisCruz commented 8 years ago

Here is a variation of the test that proves the problem (using the view's test)

describe 'views | table.page', ->

  project       = 'bsimm'
  team          = 'team-A'
  options =
    project         : project
    team            : team
    url_Location    : "/view/#{project}/#{team}/table"
    url_Template_Key: 'pages/table.page.html'

  view = null

  beforeEach ()->
    module('MM_Graph')
    inject ($injector, $httpBackend)->
      using ($httpBackend),->
        @.expectGET("/api/v1/project/schema/#{project}"    ).respond({});
        @.expectGET("/api/v1/project/schema/#{project}"    ).respond({});
        @.expectGET("/api/v1/project/schema/#{project}"    ).respond({});
        @.expectGET("/api/v1/data/#{project}/#{team}/score").respond({});
        @.expectGET("/api/v1/data/#{project}/#{team}/score").respond({});
        @.expectGET("/api/v1/data/#{project}/#{team}/score").respond({});
        @.expectGET("/api/v1/team/#{project}/get/#{team}"  ).respond({});
        @.expectGET("/api/v1/team/#{project}/get/#{team}"  ).respond({});
        @.expectGET("/api/v1/team/#{project}/get/#{team}"  ).respond({});
      view = $injector.get('Render_View')(options).run()

  it 'pages/table.page.html', ->
    using view, ->
      @.$('teamMenu').length.assert_Is 1
      @.$('teamTable').length.assert_Is 3
DinisCruz commented 8 years ago

Fixed, here is the regression test that proves the fix

describe 'views | table.page', ->

  project       = 'bsimm'
  team          = 'team-A'
  options =
    project         : project
    team            : team
    url_Location    : "/view/#{project}/#{team}/table"
    url_Template_Key: 'pages/table.page.html'

  view = null

  beforeEach ()->
    module('MM_Graph')
    inject ($injector, $httpBackend)->
      using ($httpBackend),->
        @.expectGET("/api/v1/project/schema/#{project}"    )
        #@.expectGET("/api/v1/project/schema/#{project}"    )     # throws error after fix
        #@.expectGET("/api/v1/project/schema/#{project}"    )
        @.expectGET("/api/v1/data/#{project}/#{team}/score")
        @.expectGET("/api/v1/team/#{project}/get/#{team}"  )

      view = $injector.get('Render_View')(options).run()

  it 'pages/table.page.html', ->
    using view, ->
      @.$('teamMenu' ).length.assert_Is 1
      @.$('teamTable').length.assert_Is 3
      @.$('.callout' ).length.assert_Is 3

      @.$('table'    ).length.assert_Is 3     # tables
      @.$('th'       ).length.assert_Is 33    # table headers
      @.$('tr'       ).length.assert_Is 115   # rows
      @.$('td'       ).length.assert_Is 1232  # cells

here is the proof that we don't get more than 3 requests send (with no duplication)

image

and

image