Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of http://github.com/marcesher/cfmongodb
- Loading branch information
Showing
10 changed files
with
696 additions
and
507 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,7 +1,7 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | <?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | <classpath> | ||
<classpathentry kind="src" path="java/src"/> | <classpathentry kind="src" path="java/src"/> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> | <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> | ||
<classpathentry kind="lib" path="lib/mongo-2.3.jar"/> | <classpathentry kind="lib" path="lib/mongo-2.4.jar"/> | ||
<classpathentry kind="output" path="java/bin"/> | <classpathentry kind="output" path="java/bin"/> | ||
</classpath> | </classpath> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,88 @@ | |||
<!--- | |||
Original Author: Ciarán Archer | |||
Desc: Set of MXUnit tests to verify Mongo.cfc authentication functionality | |||
works. | |||
Note: presumes that mongod was started with --auth, BUT we don't run tests against an authenticated mongod. Consequently, | |||
we have to mock these behaviors and test that *our* code responds against what we currently know to be MongoDB's behavior | |||
when running a DB in auth mode | |||
If you run these tests with --auth, they will no doubt fail | |||
More info here: http://www.mongodb.org/display/DOCS/Security+and+Authentication | |||
---> | |||
|
|||
<!--- | |||
WHERE I AM with these tests | |||
1) need to add a user to admin.system.users or do whatever it takes to see what actually happens when an authenticated attempt fails due to not being authed | |||
2) spoof the query() function to throw a similar error | |||
3) have mongo.init() check for authentication required and work that into authenticate() | |||
4) get these tests testing that behavior. | |||
NOTE: to get this working: | |||
use admin | |||
db.addUser("one","one") | |||
then attempted to query against it | |||
---> | |||
|
|||
<cfcomponent output="false" extends="mxunit.framework.TestCase"> | |||
<cfscript> | |||
import cfmongodb.core.*; | |||
|
|||
variables.testDatabase = "cfmongodb_auth_tests"; | |||
variables.testCollection = "authtests"; | |||
variables.javaloaderFactory = createObject('component','cfmongodb.core.JavaloaderFactory').init(); | |||
variables.mongoConfig = createObject('component','cfmongodb.core.MongoConfig').init(dbName=variables.testDatabase, mongoFactory=javaloaderFactory); | |||
variables.mongoConfig.setAuthDetails("username", "verysecurepassword!"); | |||
|
|||
function init_should_error_when_authentication_fails() { | |||
expectException("AuthenticationFailedException"); | |||
|
|||
var mongo = createObject('component','cfmongodb.core.Mongo'); | |||
//we entirely spoof the authentication internals | |||
injectMethod(mongo, this, "isAuthenticationRequiredOverride", "isAuthenticationRequired"); | |||
injectMethod(mongo, this, "authenticateOverride", "authenticate"); | |||
|
|||
mongo.init(mongoConfig); | |||
} | |||
|
|||
function init_should_succeed_when_authentication_passes() { | |||
var mongo = createObject('component','cfmongodb.core.Mongo'); | |||
//we entirely spoof the authentication internals | |||
injectMethod(mongo, this, "isAuthenticationRequiredOverride", "isAuthenticationRequired"); | |||
injectMethod(mongo, this, "authenticateSuccessOverride", "authenticate"); | |||
|
|||
mongo.init(mongoConfig); | |||
} | |||
|
|||
function tearDown(){ | |||
|
|||
var mongo = createObject('component','cfmongodb.core.Mongo').init(mongoConfig); | |||
try{ | |||
mongo.dropDatabase(); | |||
}catch(any e){ | |||
debug("error dropping database"); | |||
debug(e); | |||
} | |||
|
|||
//close connection | |||
mongo.close(); | |||
|
|||
} | |||
|
|||
private function isAuthenticationRequiredOverride(){ return true; } | |||
private function authenticateOverride(){ return {authenticated=false, error={}}; } | |||
private function authenticateSuccessOverride(){ return {authenticated=true, error={}}; } | |||
|
|||
|
|||
</cfscript> | |||
</cfcomponent> | |||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,29 @@ | |||
<cfcomponent extends="mxunit.framework.TestCase"> | |||
|
|||
<cffunction name="setUp" returntype="void" access="public" hint="put things here that you want to run before each test"> | |||
<cfset variables.rootURL = "http://" & cgi.SERVER_NAME & ":" & cgi.SERVER_PORT & "/cfmongodb/examples/"> | |||
<cfset debug(cgi)> | |||
|
|||
<cfset paths = ["gettingstarted.cfm", "aggregation/group.cfm", "aggregation/mapReduce.cfm", "geospatial/geo.cfm", "PeopleList/index.cfm"]> | |||
|
|||
</cffunction> | |||
|
|||
|
|||
<cffunction name="all_examples_should_work" returntype="void" access="public"> | |||
<cfset var httpResult = ""> | |||
<cfset var path = ""> | |||
<cfset var currentURL = ""> | |||
<cfloop array="#paths#" index="path"> | |||
<cfset currentURL = variables.rootURL & path> | |||
<cfhttp method="get" url="#currentURL#" result="httpResult"> | |||
<cfif httpResult.statusCode neq "200 OK"> | |||
|
|||
<cfset debug(httpResult.fileContent)> | |||
<cfset fail("For #currentURL#, path Expected 200 OK but received #httpResult.statusCode#.")> | |||
|
|||
</cfif> | |||
</cfloop> | |||
|
|||
</cffunction> | |||
|
|||
</cfcomponent> |
Oops, something went wrong.