-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create admin user #85
Conversation
70a3304
to
1501def
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you run the tests locally rather than in the CI env (where selinux is disabled), the idempotence test will fail, but it's an unrelated issue. When I apply the fix to that other issue locally in my test env, then all tests are passing.
I'm also trying to validate that the admin user/pass was created, but when I try:
[vagrant@centos8-64-1 ~]$ DJANGO_SETTINGS_MODULE=pulpcore.app.settings python3-django-admin dumpdata | grep "auth.user"
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/pulpcore/app/settings.py", line 242, in <module>
CONTENT_ORIGIN
NameError: name 'CONTENT_ORIGIN' is not defined
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/bin/python3-django-admin", line 11, in <module>
load_entry_point('Django==2.2.11', 'console_scripts', 'django-admin')()
File "/usr/lib/python3.6/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
utility.execute()
File "/usr/lib/python3.6/site-packages/django/core/management/__init__.py", line 357, in execute
django.setup()
File "/usr/lib/python3.6/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/usr/lib/python3.6/site-packages/django/apps/registry.py", line 122, in populate
app_config.ready()
File "/usr/lib/python3.6/site-packages/pulpcore/app/apps.py", line 75, in ready
self.import_viewsets()
File "/usr/lib/python3.6/site-packages/pulpcore/app/apps.py", line 102, in import_viewsets
from pulpcore.app.viewsets import NamedModelViewSet
File "/usr/lib/python3.6/site-packages/pulpcore/app/viewsets/__init__.py", line 1, in <module>
from .base import ( # noqa
File "/usr/lib/python3.6/site-packages/pulpcore/app/viewsets/base.py", line 15, in <module>
from pulpcore.app import tasks
File "/usr/lib/python3.6/site-packages/pulpcore/app/tasks/__init__.py", line 1, in <module>
from pulpcore.app.tasks import base, repository, upload # noqa
File "/usr/lib/python3.6/site-packages/pulpcore/app/tasks/repository.py", line 6, in <module>
from pulpcore.app import models, serializers
File "/usr/lib/python3.6/site-packages/pulpcore/app/serializers/__init__.py", line 42, in <module>
from .repository import ( # noqa
File "/usr/lib/python3.6/site-packages/pulpcore/app/serializers/repository.py", line 8, in <module>
from pulpcore.app import models, settings
File "/usr/lib/python3.6/site-packages/pulpcore/app/settings.py", line 244, in <module>
raise ImproperlyConfigured(_('You must specify the CONTENT_ORIGIN setting.'))
django.core.exceptions.ImproperlyConfigured: You must specify the CONTENT_ORIGIN setting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sjha4 could you add a test for this as well?
@wbclark : Can you try this: Added a test. Let me know if that is logical. I repeated the migrate --no-input test for this. |
@sjha4 same output when I try sudo as pulp user. I checked [vagrant@centos8-64-1 ~]$ sudo fgrep CONTENT_ORIGIN /etc/pulp/settings.py
CONTENT_ORIGIN = "http://centos8-64-1" From the documentation[1] added in the same commit that introduced [1] pulp/pulpcore@e027cd3#diff-572a386e0821364b3217fc84b059de24R212-R220 But I tried adding the port here on a separate branch and still faced the same issue. I also tried other |
spec/defines/admin_spec.rb
Outdated
@@ -50,6 +50,29 @@ | |||
.with_unless('/usr/bin/false') | |||
end | |||
end | |||
|
|||
context 'default parameters' do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
spec/defines/admin_spec.rb
is used to test that the pulpcore::admin
class compiles properly under various params.
In all the examples here, we're testing pulpcore::admin { 'help' }
as you can see when we defined the title
for the class here: https://github.com/theforeman/puppet-pulpcore/blob/master/spec/defines/admin_spec.rb#L7 , basically using help
as a dummy admin command we might to run, and then testing that it behaves properly with various combinations of unless
, refreshonly
, etc.
So probably this isn't the right test to use for our purposes. I'll suggest alternatives in another comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In spec/acceptance/basic_spec.rb
I think we could test that the admin user got created after running puppet-apply, using the same logic to test as in your unless
condition, adding after L55:
describe command("DJANGO_SETTINGS_MODULE=pulpcore.app.settings python3-django-admin dumpdata | grep "auth.user"") do
its(:exit_status) { is_expected.to eq 0 }
We have to fix the issue NameError: name 'CONTENT_ORIGIN' is not defined
that we saw previously before this will work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As @wbclark said, this probably belongs in spec/classes/pulpcore_spec.rb
sudo -u pulp DJANGO_SETTINGS_MODULE=pulpcore.app.settings PULP_SETTINGS=/etc/pulp/settings.py python3-django-admin dumpdata | grep "auth.user" |
Great, that worked for me! Thanks @sjha4 One more request, could you add a unit test in
I think at that point we are good to ACK and merge this :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks @sjha4 !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall 👍. Small comment on the test and I'll let you have a look at whether you want to address that.
We need to create the default admin user since pulpcore.app.authentication.PulpNoCreateRemoteUserBackend authentication backend does not create it automatically for us.