Which class to Mock for to bypass Springboot security in integration tests -
@springboottest(webenvironment = random_port) @activeprofiles("test") class contextloadingspec extends specification { @autowired testresttemplate testresttemplate def '/ should load context'() { when: responseentity<object> entity = testresttemplate.getforentity('/', object.class) then: entity.statuscode == httpstatus.ok } @testconfiguration static class config { @bean resttemplatebuilder resttemplatebuilder() { return new resttemplatebuilder() .basicauthorization('user', 'xxxxxxxx') } } }
creating testconfiguration doesn't seem correct me here. credentials should in 'application.yml' , authentication call should have been mocked. please suggest better way of writing test.
Comments
Post a Comment