Bug 838671

Summary: Add testcase to cover default password
Product: [Retired] Beaker Reporter: Bill Peck <bpeck>
Component: schedulerAssignee: Steven Lawrance <stl>
Status: CLOSED CURRENTRELEASE QA Contact:
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 0.9CC: bpeck, dcallagh, rmancy, stl
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-08-09 08:06:33 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Bill Peck 2012-07-09 18:25:18 UTC
Description of problem:

We should ship a default password and verify that its set in the kickstarts

Version-Release number of selected component (if applicable):
0.9.0

Comment 1 Dan Callaghan 2012-08-06 03:51:20 UTC
When running beaker-init against an empty database with no options:

/usr/lib64/python2.6/site-packages/sqlalchemy/engine/default.py:506: SAWarning: Unicode type received non-unicode bind param value
  param.append(processors[key](compiled_params[key]))
Traceback (most recent call last):
  File "bkr/server/tools/init.py", line 221, in <module>
    main()
  File "bkr/server/tools/init.py", line 218, in main
    user_email_address=opts.email_address)
  File "bkr/server/tools/init.py", line 186, in init_db
    ConfigItem.by_name('root_password').set('beaker', user=admin.users[0])
IndexError: list index out of range

That's because the admin user wasn't created, since I didn't pass the relevant options to create it.

If we're going to assume there is always an admin account (which I think is reasonable) then we should do some slightly nicer error checking. Like, check that there is an admin user and if not bail out with a usage error telling the user they must pass --username, --password, and --email. Or else just silently skip setting the root password. But the behaviour we have now is not very friendly.

It would be nice to also fix that annoying SAWarning. It's probably coming from the same line (need to use unicode literals).

Comment 2 Steven Lawrance 2012-08-06 14:09:26 UTC
(In reply to comment #1)
> If we're going to assume there is always an admin account (which I think is
> reasonable) then we should do some slightly nicer error checking. Like,
> check that there is an admin user and if not bail out with a usage error
> telling the user they must pass --username, --password, and --email. Or else
> just silently skip setting the root password. But the behaviour we have now
> is not very friendly.

Agreed; current behaviour results in something pretty much unusable.

I have made it check an admin account exists, and bail if not.  That raised another thought though -- if you specify the same username on a second invocation of beaker-init, you get a lovely backtrace about a duplicate row.  Should we actually allow overriding the specified admin user's password (and other details)?

> It would be nice to also fix that annoying SAWarning. It's probably coming
> from the same line (need to use unicode literals).

Pretty sure that SAWarning was there long beforehand.  However, I've gone ahead and updated all the string literals I could find in init_db to be unicode anyway, and I still get that warning.

Comment 3 Dan Callaghan 2012-08-07 07:00:03 UTC
(In reply to comment #2)
> Pretty sure that SAWarning was there long beforehand.  However, I've gone
> ahead and updated all the string literals I could find in init_db to be
> unicode anyway, and I still get that warning.

Here is how to find the source of the warning:

# python -Werror:Unicode /usr/bin/beaker-init 
Traceback (most recent call last):
  File "/usr/bin/beaker-init", line 9, in <module>
    load_entry_point('bkr.server==0.9.2', 'console_scripts', 'beaker-init')()
  File "/usr/lib/python2.6/site-packages/bkr/server/tools/init.py", line 218, in main
    user_email_address=opts.email_address)
  File "/usr/lib/python2.6/site-packages/bkr/server/tools/init.py", line 174, in init_db
    ConfigItem.by_name('root_password')
  File "/usr/lib/python2.6/site-packages/bkr/server/model.py", line 5999, in by_name
    return cls.query.filter_by(name=name).one()
[...]
sqlalchemy.exc.SAWarning: Unicode type received non-unicode bind param value

Comment 4 Steven Lawrance 2012-08-07 09:57:02 UTC
(In reply to comment #3)
> (In reply to comment #2)
> > Pretty sure that SAWarning was there long beforehand.  However, I've gone
> > ahead and updated all the string literals I could find in init_db to be
> > unicode anyway, and I still get that warning.
> 
> Here is how to find the source of the warning:
<snip>

OK, so I added a new case with the first patch, which I thought was then fixed up in the second patch.  But the warning is still there, with a much less useful stack trace -- it happens during the call to flush().  So I'm guessing it's a default value somewhere in model.py.

Comment 5 Dan Callaghan 2012-08-09 08:06:33 UTC
Beaker 0.9.2 has been released.