Jesus taught how to identify a relationship with God. At Matthew 7:22,23, he said:
Many will say to Me on that day, ‘Lord, Lord, did we not prophesy in Your name, and in Your name drive out demons and perform many miracles?’ Then I will tell them plainly, ‘I never knew you; depart from Me, you workers of lawlessness!’
Evidently, Jesus expected that some would genuinely believe that they had a relationship with God, but his response to some of them would be "I never knew you", clearly indicating that no relationship existed.
So, how does one know that they are on the right path, and that they have a real relationship with God? Context is always key, and the preceding verses to the ones quoted above show the context for this lesson of Jesus.
Matthew 7:15-20 says:
Beware of false prophets. They come to you in sheep’s clothing, but inwardly they are ravenous wolves. By their fruit you will recognize them. Are grapes gathered from thornbushes, or figs from thistles? Likewise, every good tree bears good fruit, but a bad tree bears bad fruit. A good tree cannot bear bad fruit, and a bad tree cannot bear good fruit. Every tree that does not bear good fruit is cut down and thrown into the fire. So then, by their fruit you will recognize them.
Regarding having the correct form of worship, Jesus said that firstly you would be able to distinguish those teaching falsehoods by their 'fruits', or the results of their work. Of course, in the verses we read first, Jesus indicated that these ones whom he did not know would have prophesied and even performed 'miracles'! So not all 'results' are evidence of a relationship, as the demons can provide power that would appear to be from God and mislead. So what 'fruits' do identify a relationship with God?
In Galatians chapter 5, Paul listed the 'fruits of the spirit' as well as the 'works of the flesh':
...the fruit of the Spirit is love, joy, peace, forbearance, kindness, goodness, faithfulness, gentleness and self-control.
Only someone working along with the flow and direction of the holy spirit and have a relationship with God, and these 'fruits' grow in a person that does so.
And conversely, someone who practices 'works of the flesh' cannot be in a relationship with God:
The acts of the flesh are obvious: sexual immorality, impurity and debauchery; idolatry and witchcraft; hatred, discord, jealousy, fits of rage, selfish ambition, dissensions, factions and envy; drunkenness, orgies, and the like. I warn you, as I did before, that those who live like this will not inherit the kingdom of God.
A Christian who resists the works of the flesh and sees the fruits of the spirit in their faith and in their lives has that assurance that they have God's blessing and can have a relationship with him.