(t *testing.T)
| 23 | ) |
| 24 | |
| 25 | func TestWriteUsersInPGAdmin(t *testing.T) { |
| 26 | ctx := context.Background() |
| 27 | cluster := &v1beta1.PostgresCluster{ |
| 28 | ObjectMeta: metav1.ObjectMeta{ |
| 29 | Name: "testcluster", |
| 30 | Namespace: "testnamespace", |
| 31 | }, |
| 32 | Spec: v1beta1.PostgresClusterSpec{ |
| 33 | Port: initialize.Int32(5432), |
| 34 | }, |
| 35 | } |
| 36 | |
| 37 | t.Run("Arguments", func(t *testing.T) { |
| 38 | expected := errors.New("pass-through") |
| 39 | exec := func( |
| 40 | _ context.Context, stdin io.Reader, stdout, stderr io.Writer, command ...string, |
| 41 | ) error { |
| 42 | assert.Assert(t, stdin != nil, "should send stdin") |
| 43 | assert.Assert(t, stdout != nil, "should capture stdout") |
| 44 | assert.Assert(t, stderr != nil, "should capture stderr") |
| 45 | |
| 46 | assert.Check(t, !strings.ContainsRune(strings.Join(command, ""), '\t'), |
| 47 | "Python should not be indented with tabs") |
| 48 | |
| 49 | assert.DeepEqual(t, command, []string{"python", "-c", ` |
| 50 | import sys |
| 51 | import types |
| 52 | |
| 53 | cluster = types.SimpleNamespace() |
| 54 | (cluster.name, cluster.hostname, cluster.port) = sys.argv[1:] |
| 55 | |
| 56 | import importlib.util |
| 57 | import os |
| 58 | import sys |
| 59 | |
| 60 | spec = importlib.util.find_spec('.pgadmin', ( |
| 61 | importlib.util.find_spec('pgadmin4') or |
| 62 | importlib.util.find_spec('pgadmin4-web') |
| 63 | ).name) |
| 64 | root = os.path.dirname(spec.submodule_search_locations[0]) |
| 65 | if sys.path[0] != root: |
| 66 | sys.path.insert(0, root) |
| 67 | |
| 68 | import copy |
| 69 | import json |
| 70 | import sys |
| 71 | |
| 72 | from pgadmin import create_app |
| 73 | from pgadmin.model import db, Role, User, Server, ServerGroup |
| 74 | from pgadmin.utils.constants import INTERNAL |
| 75 | from pgadmin.utils.crypto import encrypt |
| 76 | |
| 77 | with create_app().app_context(): |
| 78 | |
| 79 | admin = db.session.query(User).filter_by(id=1).first() |
| 80 | admin.active = False |
| 81 | admin.email = '' |
| 82 | admin.password = '' |
nothing calls this directly
no test coverage detected