Removed auth tests #99
This commit is contained in:
Родитель
5898851152
Коммит
eadbce5785
|
@ -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']
|
||||
},
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title></title>
|
||||
<meta name="Auth 1" content="Basic Auth">
|
||||
</head>
|
||||
<body>
|
||||
<h1>Simple page with basic auth</h1>
|
||||
<p>Expected result: <b>Passes</b></p>
|
||||
</body>
|
||||
</html>
|
|
@ -1,12 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title></title>
|
||||
<meta name="Auth 2" content="Basic Auth - 2">
|
||||
<script src="/js/jquery-1.4.2.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Page with resources and basic auth</h1>
|
||||
<p>Expected result: <b>Fails js version</b></p>
|
||||
</body>
|
||||
</html>
|
|
@ -1,12 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title></title>
|
||||
<meta name="Auth 3" content="Basic Auth - 3">
|
||||
<link rel="stylesheet" href="css/msTouch.css" />
|
||||
</head>
|
||||
<body>
|
||||
<h1>Page with resources and basic auth</h1>
|
||||
<p>Expected result: <b>Passes Touch</b></p>
|
||||
</body>
|
||||
</html>
|
|
@ -1,13 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title></title>
|
||||
<meta name="Auth 4" content="Basic Auth - 4">
|
||||
<script src="/js/jquery-1.4.2.min.js"></script>
|
||||
<link rel="stylesheet" href="css/msTouch.css" />
|
||||
</head>
|
||||
<body>
|
||||
<h1>Page with resources and basic auth</h1>
|
||||
<p>Expected result: <b>Passes Touch, fails js libs</b></p>
|
||||
</body>
|
||||
</html>
|
|
@ -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;
|
|
@ -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'})
|
||||
};
|
Загрузка…
Ссылка в новой задаче