Bug 838671 - Add testcase to cover default password
Add testcase to cover default password
Status: CLOSED CURRENTRELEASE
Product: Beaker
Classification: Community
Component: scheduler (Show other bugs)
0.9
Unspecified Unspecified
unspecified Severity unspecified (vote)
: 0.9.2
: ---
Assigned To: Steven Lawrance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2012-07-09 14:25 EDT by Bill Peck
Modified: 2012-08-09 04:06 EDT (History)
4 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2012-08-09 04:06:33 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Bill Peck 2012-07-09 14:25:18 EDT
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-05 23:51:20 EDT
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 10:09:26 EDT
(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 03:00:03 EDT
(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 05:57:02 EDT
(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 04:06:33 EDT
Beaker 0.9.2 has been released.

Note You need to log in before you can comment on or make changes to this bug.