From eadbce5785ba52248a3e53a4a5d30617b401ac22 Mon Sep 17 00:00:00 2001 From: Marc Gagne Date: Thu, 27 Aug 2015 06:58:38 -0400 Subject: [PATCH] Removed auth tests #99 --- Gruntfile.js | 1 - static/auth-1.html | 11 ------- static/auth-2.html | 12 ------- static/auth-3.html | 12 ------- static/auth-4.html | 13 -------- static/auth-server.js | 34 ------------------- test/auth_test.js | 76 ------------------------------------------- 7 files changed, 159 deletions(-) delete mode 100644 static/auth-1.html delete mode 100644 static/auth-2.html delete mode 100644 static/auth-3.html delete mode 100644 static/auth-4.html delete mode 100644 static/auth-server.js delete mode 100644 test/auth_test.js diff --git a/Gruntfile.js b/Gruntfile.js index 7d15d98..4be2e13 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -29,7 +29,6 @@ module.exports = function (grunt) { input: ['test/**/input*.js'], browserdetection: ['test/**/browserdetection*.js'], preload: ['test/**/pre*.js'], - //auth: ['test/**/auth*.js'], altImg: ['test/**/alt*.js'], aria: ['test/**/aria*.js'] }, diff --git a/static/auth-1.html b/static/auth-1.html deleted file mode 100644 index eed66e9..0000000 --- a/static/auth-1.html +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - -

Simple page with basic auth

-

Expected result: Passes

- - \ No newline at end of file diff --git a/static/auth-2.html b/static/auth-2.html deleted file mode 100644 index 92fd7b2..0000000 --- a/static/auth-2.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - -

Page with resources and basic auth

-

Expected result: Fails js version

- - \ No newline at end of file diff --git a/static/auth-3.html b/static/auth-3.html deleted file mode 100644 index 8a836fe..0000000 --- a/static/auth-3.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - -

Page with resources and basic auth

-

Expected result: Passes Touch

- - \ No newline at end of file diff --git a/static/auth-4.html b/static/auth-4.html deleted file mode 100644 index 1db15c5..0000000 --- a/static/auth-4.html +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - -

Page with resources and basic auth

-

Expected result: Passes Touch, fails js libs

- - \ No newline at end of file diff --git a/static/auth-server.js b/static/auth-server.js deleted file mode 100644 index f105acc..0000000 --- a/static/auth-server.js +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Description: Test that local scans can use authenticated (user/password) pages. - * At the moment, only supports Basic and Digest auth courtesy of node.js request. - * - * Copyright (c) Microsoft Corporation; All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this - * file except in compliance with the License. You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * THIS CODE IS PROVIDED AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS - * OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT. - * - * See the Apache Version 2.0 License for specific language governing permissions - * and limitations under the License. - */ - -"use strict"; - -var express = require('express'), - app = express(), - port = process.env.PORT || 1000; - -// Authenticator -app.use(express.basicAuth(function (user, pass) { - return user === "user" && pass === "password"; -})); - -app.use("/", express.static(__dirname + "/")); - -app.listen(port); - -module.exports.port = port; \ No newline at end of file diff --git a/test/auth_test.js b/test/auth_test.js deleted file mode 100644 index 369a700..0000000 --- a/test/auth_test.js +++ /dev/null @@ -1,76 +0,0 @@ -/** - * Description: Test that local scans can use authenticated (user/password) pages. - * At the moment, only supports Basic and Digest auth courtesy of node.js request. - * - * Copyright (c) Microsoft Corporation; All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this - * file except in compliance with the License. You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * THIS CODE IS PROVIDED AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS - * OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT. - * - * See the Apache Version 2.0 License for specific language governing permissions - * and limitations under the License. - */ - -"use strict"; - -var service = require('../app.js'), - serviceUrl = 'http://localhost:' + service.port + '/?url=%0', - authString = '&user=%1&password=%2', - authServer = require('../static/auth-server.js'), - serverUrl = 'http%3A%2F%2Flocalhost%3A' + authServer.port + '%2Fauth-', - request = require('request'); - - -function checkObject(object, expected, test) { - for (var key in expected) { - if (typeof expected[key] === "object") { - checkObject(object[key], expected[key], test); - } else { - test.equal(object[key], expected[key], object[key] + " !== " + expected[key]); - } - } -} - -function deepCount(object){ - var count = 0; - if(typeof object === "object"){ - for(var key in object){ - count += deepCount(object[key]); - } - }else{ - count++; - } - return count; -} - -function checkPage(page, expected, auth) { - return function (test) { - var uri = page.indexOf('http') === 0 ? page : serviceUrl.replace('%0', serverUrl + page), - tests = deepCount(expected); - - if (auth) { - uri += authString.replace('%1', auth.user).replace('%2', auth.password); - } - - test.expect(tests); - - request(uri, function (error, response, content) { - var result = JSON.parse(content); - checkObject(result, expected, test); - test.done(); - }); - }; -} - -module.exports['Auth Tests'] = { - 'No auth': checkPage('1.html', {statusCode: 401}), - 'Basic auth': checkPage('1.html', {results: {cvlist: {passed: true}}}, {user: 'user', password: 'password'}), - 'Basic auth - failing JS': checkPage('2.html', {results: {jslibs: {passed: false}}}, {user: 'user', password: 'password'}), - 'Basic auth - touch': checkPage('3.html', {results: {touch: {passed: true}}}, {user: 'user', password: 'password'}), - 'Basic auth - failing JS, touch': checkPage('4.html', {results: {jslibs: {passed: false}, touch: {passed: true}}}, {user: 'user', password: 'password'}) -}; \ No newline at end of file